diff --git a/deps/oxlib/src/claw/include/ox/claw/write.hpp b/deps/oxlib/src/claw/include/ox/claw/write.hpp index 3d7e6bba..e05e9b12 100644 --- a/deps/oxlib/src/claw/include/ox/claw/write.hpp +++ b/deps/oxlib/src/claw/include/ox/claw/write.hpp @@ -129,8 +129,7 @@ Error writeClaw( if (fmt == ClawFormat::Metal) { OX_RETURN_ERROR(writeMC(writer, obj)); } else if (fmt == ClawFormat::Organic) { - OX_REQUIRE(data, writeOC(obj)); - OX_RETURN_ERROR(writer.write(data.data(), data.size())); + OX_RETURN_ERROR(writeOC(writer, obj)); } #else if (fmt != ClawFormat::Metal) { diff --git a/deps/oxlib/src/oc/include/ox/oc/write.hpp b/deps/oxlib/src/oc/include/ox/oc/write.hpp index 2fd2426d..f315aae8 100644 --- a/deps/oxlib/src/oc/include/ox/oc/write.hpp +++ b/deps/oxlib/src/oc/include/ox/oc/write.hpp @@ -28,6 +28,7 @@ namespace ox { class OrganicClawWriter { + friend Error writeOC(Writer_c auto &writer, auto const &val) noexcept; friend Result writeOC(const auto &val) noexcept; friend Result writeOCString(const auto &val) noexcept; @@ -254,9 +255,19 @@ Error OrganicClawWriter::field(CString key, UnionView val) noexcept { return {}; } +Error writeOC(Writer_c auto &writer, auto const &val) noexcept { + OrganicClawWriter ocWriter; + ModelHandlerInterface handler(ocWriter); + OX_RETURN_ERROR(model(&handler, &val)); + Json::StreamWriterBuilder const jsonBuilder; + auto const str = Json::writeString(jsonBuilder, ocWriter.m_json); + writer.write(str.data(), str.size()); + return {}; +} + Result writeOC(auto const &val) noexcept { OrganicClawWriter writer; - ModelHandlerInterface handler(writer); + ModelHandlerInterface handler(writer); OX_RETURN_ERROR(model(&handler, &val)); Json::StreamWriterBuilder const jsonBuilder; auto const str = Json::writeString(jsonBuilder, writer.m_json); @@ -270,7 +281,7 @@ Result writeOC(auto const &val) noexcept { Result writeOCString(auto const &val) noexcept { OrganicClawWriter writer; - ModelHandlerInterface handler(writer); + ModelHandlerInterface handler(writer); OX_RETURN_ERROR(model(&handler, &val)); Json::StreamWriterBuilder const jsonBuilder; auto const str = Json::writeString(jsonBuilder, writer.m_json);