Compare commits

...

2 Commits

Author SHA1 Message Date
gary d10a71f06d [studio] Add missing include
Build / build (push) Failing after 1m6s
2026-05-17 15:36:57 -05:00
gary 9593e7eef9 [ox] Add writeOC Writer_c variant 2026-05-17 15:31:56 -05:00
3 changed files with 16 additions and 4 deletions
+1 -2
View File
@@ -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) {
+13 -2
View File
@@ -28,6 +28,7 @@ namespace ox {
class OrganicClawWriter {
friend Error writeOC(Writer_c auto &writer, auto const &val) noexcept;
friend Result<Buffer> writeOC(const auto &val) noexcept;
friend Result<String> writeOCString(const auto &val) noexcept;
@@ -254,9 +255,19 @@ Error OrganicClawWriter::field(CString key, UnionView<U, force> 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<Buffer> writeOC(auto const &val) noexcept {
OrganicClawWriter writer;
ModelHandlerInterface<OrganicClawWriter, OpType::Write> 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<Buffer> writeOC(auto const &val) noexcept {
Result<String> writeOCString(auto const &val) noexcept {
OrganicClawWriter writer;
ModelHandlerInterface<OrganicClawWriter, OpType::Write> handler(writer);
ModelHandlerInterface handler(writer);
OX_RETURN_ERROR(model(&handler, &val));
Json::StreamWriterBuilder const jsonBuilder;
auto const str = Json::writeString(jsonBuilder, writer.m_json);
@@ -4,6 +4,8 @@
#pragma once
#include <studio/project.hpp>
namespace studio {
ox::Error cmdChangeFormat(Project &project, ox::SpanView<ox::CString> args) noexcept;