From faaddd12341c9127aae6df94d6f851ebd56b3810 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Sat, 16 May 2020 22:35:33 -0500 Subject: [PATCH] [ox/claw] Fix TypeVersion writing --- deps/ox/src/ox/claw/CMakeLists.txt | 1 + deps/ox/src/ox/claw/write.hpp | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/deps/ox/src/ox/claw/CMakeLists.txt b/deps/ox/src/ox/claw/CMakeLists.txt index 65519a9c..bab204df 100644 --- a/deps/ox/src/ox/claw/CMakeLists.txt +++ b/deps/ox/src/ox/claw/CMakeLists.txt @@ -2,6 +2,7 @@ add_library( OxClaw read.cpp + write.cpp ) target_link_libraries( diff --git a/deps/ox/src/ox/claw/write.hpp b/deps/ox/src/ox/claw/write.hpp index 5c1968bb..0dc60d91 100644 --- a/deps/ox/src/ox/claw/write.hpp +++ b/deps/ox/src/ox/claw/write.hpp @@ -43,6 +43,16 @@ template return -1; } +template +struct type_version { + static constexpr auto value = -1; +}; + +template +struct type_version { + static constexpr auto value = T::TypeVersion; +}; + template constexpr const char *getTypeName(T *t) noexcept { TypeInfoCatcher tnc; @@ -65,7 +75,7 @@ ValErr writeClawHeader(T *t, ClawFormat fmt) noexcept { } out += detail::getTypeName(t); out += ";"; - const auto tn = detail::getTypeVersion(t); + const auto tn = detail::type_version::value; if (tn > -1) { out += tn; } @@ -76,7 +86,7 @@ ValErr writeClawHeader(T *t, ClawFormat fmt) noexcept { } template -constexpr ValErr> writeClaw(T *t, ClawFormat fmt) { +ValErr> writeClaw(T *t, ClawFormat fmt) { auto [header, headerErr] = detail::writeClawHeader(t, fmt); oxReturnError(headerErr); const auto [data, dataErr] = fmt == ClawFormat::Metal ? writeMC(t) : writeOC(t);