[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;
|
virtual ox::String typeId() const noexcept = 0;
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
constexpr auto typeMatch(ox::StringView name, int version) const noexcept {
|
constexpr auto typeMatch(ox::StringView typeId) const noexcept {
|
||||||
return typeId() == ox::buildTypeId(name, version);
|
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;
|
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>
|
template<typename T>
|
||||||
ox::Result<T*> getClipboardObject(Context &ctx) noexcept {
|
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);
|
return dynamic_cast<T*>(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,8 +26,8 @@ void setClipboardObject(Context &ctx, ox::UPtr<BaseClipboardObject> &&obj) noexc
|
|||||||
ctx.clipboard = std::move(obj);
|
ctx.clipboard = std::move(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
ox::Result<BaseClipboardObject*> getClipboardData(Context &ctx, ox::StringView typeName, int typeVersion) noexcept {
|
ox::Result<BaseClipboardObject*> getClipboardData(Context &ctx, ox::StringView typeId) noexcept {
|
||||||
if (ctx.clipboard && ctx.clipboard->typeMatch(typeName, typeVersion)) {
|
if (ctx.clipboard && ctx.clipboard->typeMatch(typeId)) {
|
||||||
return ctx.clipboard.get();
|
return ctx.clipboard.get();
|
||||||
}
|
}
|
||||||
return OxError(1);
|
return OxError(1);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user