[ox] Make model type version mandatory

This commit is contained in:
2022-05-29 22:21:05 -05:00
parent 3834de3318
commit c4a1655a8f
14 changed files with 89 additions and 76 deletions

View File

@@ -77,7 +77,7 @@ class MetalClawWriter {
Error field(const char*, UnionView<U> val) noexcept;
template<typename T = std::nullptr_t>
void setTypeInfo(const char *name = T::TypeName, int fields = countFields<T>()) noexcept;
void setTypeInfo(const char *name = T::TypeName, int version = T::TypeVersion, int fields = ModelFieldCount_v<T>) noexcept;
[[nodiscard]]
std::size_t size() const noexcept;
@@ -171,7 +171,7 @@ Error MetalClawWriter::field(const char*, T *val, std::size_t len) noexcept {
}
MetalClawWriter writer(m_buff + m_buffIt, m_buffLen - m_buffIt);
writer.setTypeInfo<T>("List", len);
writer.setTypeInfo<T>("List", 0, len);
// write the array
for (std::size_t i = 0; i < len; i++) {
@@ -205,7 +205,7 @@ Error MetalClawWriter::field(const char*, HashMap<String, T> *val) noexcept {
MetalClawWriter writer(m_buff + m_buffIt, m_buffLen - m_buffIt);
// double len for both key and value
writer.setTypeInfo("Map", len * 2);
writer.setTypeInfo("Map", 0, len * 2);
// write the array
for (std::size_t i = 0; i < len; i++) {
@@ -245,7 +245,7 @@ Error MetalClawWriter::appendInteger(I val) noexcept {
}
template<typename T>
void MetalClawWriter::setTypeInfo(const char*, int fields) noexcept {
void MetalClawWriter::setTypeInfo(const char*, int, int fields) noexcept {
m_fields = fields;
m_fieldPresence.setFields(fields);
m_buffIt = static_cast<std::size_t>(m_fieldPresence.getMaxLen());