[ox] Make model system's setTypeInfo return an Error
This commit is contained in:
6
deps/ox/src/ox/claw/test/tests.cpp
vendored
6
deps/ox/src/ox/claw/test/tests.cpp
vendored
@@ -66,7 +66,7 @@ struct TestStruct {
|
||||
|
||||
template<typename T>
|
||||
constexpr ox::Error model(T *io, ox::CommonPtrWith<TestUnion> auto *obj) {
|
||||
io->template setTypeInfo<TestUnion>();
|
||||
oxReturnError(io->template setTypeInfo<TestUnion>());
|
||||
oxReturnError(io->field("Bool", &obj->Bool));
|
||||
oxReturnError(io->field("Int", &obj->Int));
|
||||
oxReturnError(io->fieldCString("String", &obj->String));
|
||||
@@ -75,7 +75,7 @@ constexpr ox::Error model(T *io, ox::CommonPtrWith<TestUnion> auto *obj) {
|
||||
|
||||
template<typename T>
|
||||
constexpr ox::Error model(T *io, ox::CommonPtrWith<TestStructNest> auto *obj) {
|
||||
io->template setTypeInfo<TestStructNest>();
|
||||
oxReturnError(io->template setTypeInfo<TestStructNest>());
|
||||
oxReturnError(io->field("Bool", &obj->Bool));
|
||||
oxReturnError(io->field("Int", &obj->Int));
|
||||
oxReturnError(io->field("String", &obj->String));
|
||||
@@ -84,7 +84,7 @@ constexpr ox::Error model(T *io, ox::CommonPtrWith<TestStructNest> auto *obj) {
|
||||
|
||||
template<typename T>
|
||||
constexpr ox::Error model(T *io, ox::CommonPtrWith<TestStruct> auto *obj) {
|
||||
io->template setTypeInfo<TestStruct>();
|
||||
oxReturnError(io->template setTypeInfo<TestStruct>());
|
||||
oxReturnError(io->field("Bool", &obj->Bool));
|
||||
oxReturnError(io->field("Int", &obj->Int));
|
||||
oxReturnError(io->field("Int1", &obj->Int1));
|
||||
|
13
deps/ox/src/ox/claw/write.hpp
vendored
13
deps/ox/src/ox/claw/write.hpp
vendored
@@ -27,14 +27,15 @@ struct TypeInfoCatcher {
|
||||
const char *name = nullptr;
|
||||
int version = 0;
|
||||
|
||||
template<typename T = void>
|
||||
constexpr void setTypeInfo(
|
||||
const char *name = T::TypeName,
|
||||
int v = T::TypeVersion,
|
||||
template<typename T>
|
||||
constexpr ox::Error setTypeInfo(
|
||||
const char *pName = T::TypeName,
|
||||
int pVersion = T::TypeVersion,
|
||||
const Vector<String>& = {},
|
||||
std::size_t = 0) noexcept {
|
||||
this->name = name;
|
||||
this->version = v;
|
||||
this->name = pName;
|
||||
this->version = pVersion;
|
||||
return {};
|
||||
}
|
||||
|
||||
constexpr Error field(...) noexcept {
|
||||
|
Reference in New Issue
Block a user