diff --git a/deps/ox/src/ox/oc/write.hpp b/deps/ox/src/ox/oc/write.hpp index 105f272c..006bfd63 100644 --- a/deps/ox/src/ox/oc/write.hpp +++ b/deps/ox/src/ox/oc/write.hpp @@ -24,9 +24,8 @@ namespace ox { class OrganicClawWriter { - template - friend Result writeOC(const auto &val) noexcept - requires(ox::is_same_v || ox::is_same_v); + friend Result writeOC(const auto &val) noexcept; + friend Result writeOCString(const auto &val) noexcept; protected: Json::Value m_json{Json::Value(Json::objectValue)}; @@ -249,16 +248,26 @@ Error OrganicClawWriter::field(const char *key, UnionView val) noexcep return OxError(0); } -template -Result writeOC(const auto &val) noexcept - requires(ox::is_same_v || ox::is_same_v) { +Result writeOC(const auto &val) noexcept { OrganicClawWriter writer; ModelHandlerInterface handler(&writer); oxReturnError(model(&handler, &val)); Json::StreamWriterBuilder const jsonBuilder; const auto str = Json::writeString(jsonBuilder, writer.m_json); - Result buff; - buff.value.resize(str.size() + ox::is_same_v); + Result buff; + buff.value.resize(str.size() + 1); + memcpy(buff.value.data(), str.data(), str.size() + 1); + return buff; +} + +Result writeOCString(const auto &val) noexcept { + OrganicClawWriter writer; + ModelHandlerInterface handler(&writer); + oxReturnError(model(&handler, &val)); + Json::StreamWriterBuilder const jsonBuilder; + const auto str = Json::writeString(jsonBuilder, writer.m_json); + Result buff; + buff.value.resize(str.size()); memcpy(buff.value.data(), str.data(), str.size() + 1); return buff; }