[ox] Make setTypeInfo functions in model handlers consistent

This commit is contained in:
Gary Talent 2022-12-01 00:09:05 -06:00
parent 50e2fadcd1
commit 593a57a0ce
6 changed files with 15 additions and 13 deletions

View File

@ -26,7 +26,7 @@ class ModelHandlerInterface {
template<typename T = std::nullptr_t>
constexpr void setTypeInfo(const char *name = T::TypeName, int version = T::TypeVersion,
const Vector<String> &typeParams = {}, int fields = ModelFieldCount_v<T>) noexcept {
m_handler->setTypeInfo(name, version, typeParams, fields);
m_handler->template setTypeInfo<T>(name, version, typeParams, fields);
}
template<std::size_t len>

View File

@ -744,7 +744,7 @@ class ModelUnion {
};
constexpr Error model(auto *h, CommonPtrWith<ModelObject> auto *obj) noexcept {
h->setTypeInfo(obj->m_typeName.c_str(), obj->m_typeVersion, {}, static_cast<int>(obj->m_fieldsOrder.size()));
h->template setTypeInfo<ModelObject>(obj->m_typeName.c_str(), obj->m_typeVersion, {}, static_cast<int>(obj->m_fieldsOrder.size()));
for (auto &f : obj->m_fieldsOrder) {
oxReturnError(h->field(f->name.c_str(), &f->value));
}
@ -752,7 +752,7 @@ constexpr Error model(auto *h, CommonPtrWith<ModelObject> auto *obj) noexcept {
}
constexpr Error model(auto *h, CommonPtrWith<ModelUnion> auto *obj) noexcept {
h->setTypeInfo(obj->m_typeName.c_str(), obj->m_typeVersion, {}, static_cast<int>(obj->m_fieldsOrder.size()));
h->template setTypeInfo<ModelUnion>(obj->m_typeName.c_str(), obj->m_typeVersion, {}, static_cast<int>(obj->m_fieldsOrder.size()));
for (auto &f : obj->m_fieldsOrder) {
oxReturnError(h->field(f->name.c_str(), &f->value));
}

View File

@ -25,9 +25,9 @@ template<typename PlatSpec>
struct AlignmentCatcher: public ModelHandlerBase<AlignmentCatcher<PlatSpec>> {
std::size_t biggestAlignment = 1;
template<typename ...T>
constexpr void setTypeInfo(T&&...) const noexcept {
}
template<typename T>
constexpr void setTypeInfo(const char* = T::TypeName, int = T::TypeVersion,
const Vector<String>& = {}, int = ModelFieldCount_v<T>) noexcept {}
template<typename T, bool force>
constexpr ox::Error field(CRStringView name, const UnionView<T, force> val) noexcept {

View File

@ -58,7 +58,9 @@ class Preloader: public ModelHandlerBase<Preloader<PlatSpec>> {
constexpr static ox::Result<ox::UniquePtr<Preloader>> make(ox::ios_base::seekdir anchor = ox::ios_base::cur,
std::size_t sz = 0) noexcept;
constexpr void setTypeInfo(CRStringView, int, const ox::Vector<String>& = {}, int = 0) noexcept {}
template<typename T>
constexpr void setTypeInfo(const char* = T::TypeName, int = T::TypeVersion,
const Vector<String>& = {}, int = ModelFieldCount_v<T>) noexcept {}
template<typename U, bool force>
constexpr ox::Error field(CRStringView, const ox::UnionView<U, force> val) noexcept;

View File

@ -31,9 +31,9 @@ class SizeCatcher: public ModelHandlerBase<SizeCatcher<PlatSpec>> {
public:
constexpr explicit SizeCatcher() noexcept = default;
template<typename ...T>
constexpr void setTypeInfo(T&&...) const noexcept {
}
template<typename T>
constexpr void setTypeInfo(const char* = T::TypeName, int = T::TypeVersion,
const Vector<String>& = {}, int = ModelFieldCount_v<T>) noexcept {}
template<typename T, bool force>
constexpr ox::Error field(const char*, UnionView<T, force>) noexcept;

View File

@ -19,9 +19,9 @@ class UnionSizeCatcher: public ModelHandlerBase<UnionSizeCatcher<PlatSpec>> {
std::size_t m_size = 0;
public:
template<typename ...T>
constexpr void setTypeInfo(T&&...) const noexcept {
}
template<typename T>
constexpr void setTypeInfo(const char* = T::TypeName, int = T::TypeVersion,
const Vector<String>& = {}, int = ModelFieldCount_v<T>) noexcept {}
template<typename T, bool force>
constexpr ox::Error field(CRStringView, const UnionView<T, force> val) noexcept {