[turbine] Rework getClipboardObject to use ox::ModelTypeId_v
This commit is contained in:
parent
b968ec8a91
commit
5d89370cb0
@ -20,8 +20,8 @@ class BaseClipboardObject {
|
||||
virtual ox::String typeId() const noexcept = 0;
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr auto typeMatch(ox::StringView name, int version) const noexcept {
|
||||
return typeId() == ox::buildTypeId(name, version);
|
||||
constexpr auto typeMatch(ox::StringView typeId) const noexcept {
|
||||
return this->typeId() == typeId;
|
||||
}
|
||||
};
|
||||
|
||||
@ -39,11 +39,11 @@ void setClipboardText(Context &ctx, ox::CRStringView text) noexcept;
|
||||
|
||||
void setClipboardObject(Context &ctx, ox::UPtr<BaseClipboardObject> &&obj) noexcept;
|
||||
|
||||
ox::Result<BaseClipboardObject*> getClipboardData(Context &ctx, ox::StringView typeName, int typeVersion) noexcept;
|
||||
ox::Result<BaseClipboardObject*> getClipboardData(Context &ctx, ox::StringView typeId) noexcept;
|
||||
|
||||
template<typename T>
|
||||
ox::Result<T*> getClipboardObject(Context &ctx) noexcept {
|
||||
oxRequire(p, getClipboardData(ctx, T::TypeName, T::TypeVersion));
|
||||
oxRequire(p, getClipboardData(ctx, ox::ModelTypeId_v<T>));
|
||||
return dynamic_cast<T*>(p);
|
||||
}
|
||||
|
||||
|
@ -26,8 +26,8 @@ void setClipboardObject(Context &ctx, ox::UPtr<BaseClipboardObject> &&obj) noexc
|
||||
ctx.clipboard = std::move(obj);
|
||||
}
|
||||
|
||||
ox::Result<BaseClipboardObject*> getClipboardData(Context &ctx, ox::StringView typeName, int typeVersion) noexcept {
|
||||
if (ctx.clipboard && ctx.clipboard->typeMatch(typeName, typeVersion)) {
|
||||
ox::Result<BaseClipboardObject*> getClipboardData(Context &ctx, ox::StringView typeId) noexcept {
|
||||
if (ctx.clipboard && ctx.clipboard->typeMatch(typeId)) {
|
||||
return ctx.clipboard.get();
|
||||
}
|
||||
return OxError(1);
|
||||
|
Loading…
Reference in New Issue
Block a user