From be32d575f530647054bced118926865eab9f72ff Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Sun, 17 May 2026 14:29:43 -0500 Subject: [PATCH] [ox/claw] Add writeClaw Writer_c variant --- deps/oxlib/src/claw/include/ox/claw/write.hpp | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/deps/oxlib/src/claw/include/ox/claw/write.hpp b/deps/oxlib/src/claw/include/ox/claw/write.hpp index 8a62a1d0..3d7e6bba 100644 --- a/deps/oxlib/src/claw/include/ox/claw/write.hpp +++ b/deps/oxlib/src/claw/include/ox/claw/write.hpp @@ -120,4 +120,25 @@ Result writeClaw( return out; } +Error writeClaw( + auto const &obj, + Writer_c auto &writer, + ClawFormat const fmt = ClawFormat::Metal) noexcept { + OX_RETURN_ERROR(detail::writeClawHeader(writer, &obj, fmt)); +#ifdef OX_USE_STDLIB + 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())); + } +#else + if (fmt != ClawFormat::Metal) { + return ox::Error(1, "OC is not supported in this build"); + } + OX_RETURN_ERROR(writeMC(writer, obj)); +#endif + return {}; +} + }