|
|
|
@@ -19,7 +19,7 @@ class Wrap {
|
|
|
|
|
public:
|
|
|
|
|
virtual ~Wrap() = default;
|
|
|
|
|
[[nodiscard]]
|
|
|
|
|
virtual ox::CStringView typeName() const noexcept = 0;
|
|
|
|
|
virtual ox::StringLiteral typeName() const noexcept = 0;
|
|
|
|
|
[[nodiscard]]
|
|
|
|
|
virtual int typeVersion() const noexcept = 0;
|
|
|
|
|
[[nodiscard]]
|
|
|
|
@@ -48,7 +48,7 @@ class WrapRef final: public WrapT<T> {
|
|
|
|
|
constexpr explicit WrapRef(T &obj): m_obj{obj} {}
|
|
|
|
|
|
|
|
|
|
[[nodiscard]]
|
|
|
|
|
ox::CStringView typeName() const noexcept override {
|
|
|
|
|
ox::StringLiteral typeName() const noexcept override {
|
|
|
|
|
return ox::ModelTypeName_v<T>;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -77,7 +77,7 @@ class WrapInline final: public WrapT<T> {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[[nodiscard]]
|
|
|
|
|
ox::CStringView typeName() const noexcept override {
|
|
|
|
|
ox::StringLiteral typeName() const noexcept override {
|
|
|
|
|
return ox::ModelTypeName_v<T>;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -108,7 +108,7 @@ class BaseConverter {
|
|
|
|
|
constexpr virtual ~BaseConverter() noexcept = default;
|
|
|
|
|
|
|
|
|
|
[[nodiscard]]
|
|
|
|
|
constexpr virtual ox::StringView srcTypeName() const noexcept = 0;
|
|
|
|
|
constexpr virtual ox::StringLiteral srcTypeName() const noexcept = 0;
|
|
|
|
|
|
|
|
|
|
[[nodiscard]]
|
|
|
|
|
constexpr virtual int srcTypeVersion() const noexcept = 0;
|
|
|
|
@@ -154,7 +154,7 @@ class ConverterFunc final: public BaseConverter {
|
|
|
|
|
using DstType = typename decltype(extractParams(Func))::Dst;
|
|
|
|
|
|
|
|
|
|
[[nodiscard]]
|
|
|
|
|
constexpr ox::StringView srcTypeName() const noexcept override {
|
|
|
|
|
constexpr ox::StringLiteral srcTypeName() const noexcept override {
|
|
|
|
|
return ox::ModelTypeName_v<SrcType>;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -253,19 +253,22 @@ template<typename DstType>
|
|
|
|
|
ox::Result<DstType> convertObjToObj(
|
|
|
|
|
Context &ctx,
|
|
|
|
|
auto &src) noexcept {
|
|
|
|
|
OX_REQUIRE_M(out, convert(ctx, WrapRef{src}, ox::ModelTypeName_v<DstType>, ox::ModelTypeVersion_v<DstType>));
|
|
|
|
|
OX_REQUIRE_M(out,
|
|
|
|
|
convert(ctx, WrapRef{src}, ox::ModelTypeName_v<DstType>, ox::ModelTypeVersion_v<DstType>));
|
|
|
|
|
return std::move(wrapCast(*out));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template<typename DstType>
|
|
|
|
|
ox::Result<DstType> convert(Context &ctx, ox::BufferView const &src) noexcept {
|
|
|
|
|
OX_REQUIRE(out, convert(ctx, src, ox::ModelTypeName_v<DstType>, ox::ModelTypeVersion_v<DstType>));
|
|
|
|
|
OX_REQUIRE(out,
|
|
|
|
|
convert(ctx, src, ox::ModelTypeName_v<DstType>, ox::ModelTypeVersion_v<DstType>));
|
|
|
|
|
return std::move(wrapCast<DstType>(*out));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template<typename DstType>
|
|
|
|
|
ox::Error convert(Context &ctx, ox::BufferView const &buff, DstType &outObj) noexcept {
|
|
|
|
|
OX_REQUIRE(out, convert(ctx, buff, ox::ModelTypeName_v<DstType>, ox::ModelTypeVersion_v<DstType>));
|
|
|
|
|
OX_REQUIRE(out,
|
|
|
|
|
convert(ctx, buff, ox::ModelTypeName_v<DstType>, ox::ModelTypeVersion_v<DstType>));
|
|
|
|
|
outObj = std::move(wrapCast<DstType>(*out));
|
|
|
|
|
return {};
|
|
|
|
|
}
|
|
|
|
@@ -280,7 +283,8 @@ ox::Error convertObjToObj(Context &ctx, auto &src, DstType &outObj) noexcept {
|
|
|
|
|
template<typename DstType>
|
|
|
|
|
ox::Result<ox::Buffer> convertBuffToBuff(
|
|
|
|
|
Context &ctx, ox::BufferView const &src, ox::ClawFormat const fmt) noexcept {
|
|
|
|
|
OX_REQUIRE(out, convert(ctx, src, ox::ModelTypeName_v<DstType>, ox::ModelTypeVersion_v<DstType>));
|
|
|
|
|
OX_REQUIRE(out,
|
|
|
|
|
convert(ctx, src, ox::ModelTypeName_v<DstType>, ox::ModelTypeVersion_v<DstType>));
|
|
|
|
|
return ox::writeClaw<DstType>(wrapCast<DstType>(*out), fmt);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|