[ox/oc] Fix Linux build
This commit is contained in:
parent
bdfb5e972a
commit
e8a1ff0643
25
deps/ox/src/ox/oc/write.hpp
vendored
25
deps/ox/src/ox/oc/write.hpp
vendored
@ -24,9 +24,8 @@ namespace ox {
|
|||||||
|
|
||||||
class OrganicClawWriter {
|
class OrganicClawWriter {
|
||||||
|
|
||||||
template<typename T>
|
friend Result<ox::Buffer> writeOC(const auto &val) noexcept;
|
||||||
friend Result<T> writeOC(const auto &val) noexcept
|
friend Result<ox::String> writeOCString(const auto &val) noexcept;
|
||||||
requires(ox::is_same_v<T, ox::Buffer> || ox::is_same_v<T, ox::String>);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Json::Value m_json{Json::Value(Json::objectValue)};
|
Json::Value m_json{Json::Value(Json::objectValue)};
|
||||||
@ -249,16 +248,26 @@ Error OrganicClawWriter::field(const char *key, UnionView<U, force> val) noexcep
|
|||||||
return OxError(0);
|
return OxError(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T = ox::Buffer>
|
Result<ox::Buffer> writeOC(const auto &val) noexcept {
|
||||||
Result<T> writeOC(const auto &val) noexcept
|
|
||||||
requires(ox::is_same_v<T, ox::Buffer> || ox::is_same_v<T, ox::String>) {
|
|
||||||
OrganicClawWriter writer;
|
OrganicClawWriter writer;
|
||||||
ModelHandlerInterface<OrganicClawWriter, OpType::Write> handler(&writer);
|
ModelHandlerInterface<OrganicClawWriter, OpType::Write> handler(&writer);
|
||||||
oxReturnError(model(&handler, &val));
|
oxReturnError(model(&handler, &val));
|
||||||
Json::StreamWriterBuilder const jsonBuilder;
|
Json::StreamWriterBuilder const jsonBuilder;
|
||||||
const auto str = Json::writeString(jsonBuilder, writer.m_json);
|
const auto str = Json::writeString(jsonBuilder, writer.m_json);
|
||||||
Result<T> buff;
|
Result<Buffer> buff;
|
||||||
buff.value.resize(str.size() + ox::is_same_v<T, ox::Buffer>);
|
buff.value.resize(str.size() + 1);
|
||||||
|
memcpy(buff.value.data(), str.data(), str.size() + 1);
|
||||||
|
return buff;
|
||||||
|
}
|
||||||
|
|
||||||
|
Result<ox::String> writeOCString(const auto &val) noexcept {
|
||||||
|
OrganicClawWriter writer;
|
||||||
|
ModelHandlerInterface<OrganicClawWriter, OpType::Write> handler(&writer);
|
||||||
|
oxReturnError(model(&handler, &val));
|
||||||
|
Json::StreamWriterBuilder const jsonBuilder;
|
||||||
|
const auto str = Json::writeString(jsonBuilder, writer.m_json);
|
||||||
|
Result<ox::String> buff;
|
||||||
|
buff.value.resize(str.size());
|
||||||
memcpy(buff.value.data(), str.data(), str.size() + 1);
|
memcpy(buff.value.data(), str.data(), str.size() + 1);
|
||||||
return buff;
|
return buff;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user