[ox/{mc,oc}] Cleanup
This commit is contained in:
parent
ceebc05ee9
commit
d01ff63527
6
deps/ox/src/ox/mc/write.hpp
vendored
6
deps/ox/src/ox/mc/write.hpp
vendored
@ -11,11 +11,11 @@
|
||||
#include <ox/model/optype.hpp>
|
||||
#include <ox/model/types.hpp>
|
||||
#include <ox/std/bit.hpp>
|
||||
#include <ox/std/buffer.hpp>
|
||||
#include <ox/std/byteswap.hpp>
|
||||
#include <ox/std/string.hpp>
|
||||
#include <ox/std/types.hpp>
|
||||
#include <ox/std/units.hpp>
|
||||
#include <ox/std/vector.hpp>
|
||||
|
||||
#include "intops.hpp"
|
||||
#include "err.hpp"
|
||||
@ -223,8 +223,8 @@ void MetalClawWriter::setTypeInfo(const char*, int fields) {
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
Result<Vector<char>> writeMC(T *val) {
|
||||
Vector<char> buff(10 * units::MB);
|
||||
Result<Buffer> writeMC(T *val) {
|
||||
Buffer buff(10 * units::MB);
|
||||
MetalClawWriter writer(bit_cast<uint8_t*>(buff.data()), buff.size());
|
||||
oxReturnError(model(&writer, val));
|
||||
buff.resize(writer.size());
|
||||
|
8
deps/ox/src/ox/oc/write.hpp
vendored
8
deps/ox/src/ox/oc/write.hpp
vendored
@ -12,16 +12,16 @@
|
||||
|
||||
#include <ox/model/optype.hpp>
|
||||
#include <ox/model/types.hpp>
|
||||
#include <ox/std/buffer.hpp>
|
||||
#include <ox/std/hashmap.hpp>
|
||||
#include <ox/std/string.hpp>
|
||||
#include <ox/std/vector.hpp>
|
||||
|
||||
namespace ox {
|
||||
|
||||
class OrganicClawWriter {
|
||||
|
||||
template<typename T>
|
||||
friend Result<Vector<char>> writeOC(T *val);
|
||||
friend Result<Buffer> writeOC(T *val);
|
||||
|
||||
protected:
|
||||
Json::Value m_json;
|
||||
@ -145,12 +145,12 @@ Error OrganicClawWriter::field(const char *key, ox::HashMap<String, T> *val) {
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
Result<Vector<char>> writeOC(T *val) {
|
||||
Result<Buffer> writeOC(T *val) {
|
||||
OrganicClawWriter writer;
|
||||
oxReturnError(model(&writer, val));
|
||||
Json::StreamWriterBuilder jsonBuilder;
|
||||
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);
|
||||
return buff;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user