[ox/{mc,oc}] Cleanup

This commit is contained in:
Gary Talent 2021-05-03 14:52:36 -04:00
parent ceebc05ee9
commit d01ff63527
2 changed files with 7 additions and 7 deletions

View File

@ -11,11 +11,11 @@
#include <ox/model/optype.hpp> #include <ox/model/optype.hpp>
#include <ox/model/types.hpp> #include <ox/model/types.hpp>
#include <ox/std/bit.hpp> #include <ox/std/bit.hpp>
#include <ox/std/buffer.hpp>
#include <ox/std/byteswap.hpp> #include <ox/std/byteswap.hpp>
#include <ox/std/string.hpp> #include <ox/std/string.hpp>
#include <ox/std/types.hpp> #include <ox/std/types.hpp>
#include <ox/std/units.hpp> #include <ox/std/units.hpp>
#include <ox/std/vector.hpp>
#include "intops.hpp" #include "intops.hpp"
#include "err.hpp" #include "err.hpp"
@ -223,8 +223,8 @@ void MetalClawWriter::setTypeInfo(const char*, int fields) {
} }
template<typename T> template<typename T>
Result<Vector<char>> writeMC(T *val) { Result<Buffer> writeMC(T *val) {
Vector<char> buff(10 * units::MB); Buffer buff(10 * units::MB);
MetalClawWriter writer(bit_cast<uint8_t*>(buff.data()), buff.size()); MetalClawWriter writer(bit_cast<uint8_t*>(buff.data()), buff.size());
oxReturnError(model(&writer, val)); oxReturnError(model(&writer, val));
buff.resize(writer.size()); buff.resize(writer.size());

View File

@ -12,16 +12,16 @@
#include <ox/model/optype.hpp> #include <ox/model/optype.hpp>
#include <ox/model/types.hpp> #include <ox/model/types.hpp>
#include <ox/std/buffer.hpp>
#include <ox/std/hashmap.hpp> #include <ox/std/hashmap.hpp>
#include <ox/std/string.hpp> #include <ox/std/string.hpp>
#include <ox/std/vector.hpp>
namespace ox { namespace ox {
class OrganicClawWriter { class OrganicClawWriter {
template<typename T> template<typename T>
friend Result<Vector<char>> writeOC(T *val); friend Result<Buffer> writeOC(T *val);
protected: protected:
Json::Value m_json; Json::Value m_json;
@ -145,12 +145,12 @@ Error OrganicClawWriter::field(const char *key, ox::HashMap<String, T> *val) {
} }
template<typename T> template<typename T>
Result<Vector<char>> writeOC(T *val) { Result<Buffer> writeOC(T *val) {
OrganicClawWriter writer; OrganicClawWriter writer;
oxReturnError(model(&writer, val)); oxReturnError(model(&writer, val));
Json::StreamWriterBuilder jsonBuilder; Json::StreamWriterBuilder jsonBuilder;
auto str = Json::writeString(jsonBuilder, writer.m_json); auto str = Json::writeString(jsonBuilder, writer.m_json);
Vector<char> buff(str.size() + 1); Buffer buff(str.size() + 1);
memcpy(buff.data(), str.c_str(), str.size() + 1); memcpy(buff.data(), str.c_str(), str.size() + 1);
return buff; return buff;
} }