diff --git a/deps/ox/src/ox/claw/test/tests.cpp b/deps/ox/src/ox/claw/test/tests.cpp index beefb8a6..25eaa909 100644 --- a/deps/ox/src/ox/claw/test/tests.cpp +++ b/deps/ox/src/ox/claw/test/tests.cpp @@ -158,7 +158,7 @@ static std::map tests = { testIn.Struct.Bool = false; testIn.Struct.Int = 300; testIn.Struct.String = "Test String 2"; - const auto [buff, err] = ox::writeMC(&testIn); + const auto [buff, err] = ox::writeMC(testIn); oxAssert(err, "writeClaw failed"); oxAssert(ox::readMC(buff.data(), buff.size(), &testOut), "readClaw failed"); //std::cout << testIn.Union.Int << "|" << testOut.Union.Int << "|\n"; diff --git a/deps/ox/src/ox/claw/write.hpp b/deps/ox/src/ox/claw/write.hpp index 231ac689..88b23331 100644 --- a/deps/ox/src/ox/claw/write.hpp +++ b/deps/ox/src/ox/claw/write.hpp @@ -72,7 +72,7 @@ constexpr int getTypeVersion(const T *t) noexcept { } template -ox::Error writeClawHeader(Writer_c auto &writer, T *t, ClawFormat fmt) noexcept { +ox::Error writeClawHeader(Writer_c auto &writer, const T *t, ClawFormat fmt) noexcept { switch (fmt) { case ClawFormat::Metal: oxReturnError(write(&writer, "M2;")); @@ -96,7 +96,7 @@ ox::Error writeClawHeader(Writer_c auto &writer, T *t, ClawFormat fmt) noexcept } Result writeClaw( - auto &t, + const auto &t, ClawFormat fmt = ClawFormat::Metal, std::size_t buffReserveSz = 2 * units::KB) noexcept { Buffer out(buffReserveSz); diff --git a/deps/ox/src/ox/logconn/logconn.hpp b/deps/ox/src/ox/logconn/logconn.hpp index d7723b42..51037ee2 100644 --- a/deps/ox/src/ox/logconn/logconn.hpp +++ b/deps/ox/src/ox/logconn/logconn.hpp @@ -45,7 +45,7 @@ class LoggerConn: public trace::Logger { ox::Error send(trace::MsgId msgId, const auto &msg) noexcept { ox::Array buff; std::size_t sz = 0; - oxReturnError(ox::writeMC(&buff[0], buff.size(), &msg, &sz)); + oxReturnError(ox::writeMC(&buff[0], buff.size(), msg, &sz)); //std::printf("sz: %lu\n", sz); oxRequire(szBuff, serialize(static_cast(sz))); std::unique_lock buffLk(m_buffMut); diff --git a/deps/ox/src/ox/mc/test/tests.cpp b/deps/ox/src/ox/mc/test/tests.cpp index a140a4d8..6d01965f 100644 --- a/deps/ox/src/ox/mc/test/tests.cpp +++ b/deps/ox/src/ox/mc/test/tests.cpp @@ -113,7 +113,8 @@ std::map tests = { static constexpr size_t buffLen = 1024; char buff[buffLen]; TestStruct ts; - oxReturnError(ox::writeMC(buff, buffLen, &ts)); + oxReturnError(ox::writeMC(buff, buffLen, ts)); + oxReturnError(ox::writeMC(ts)); return OxError(0); } }, @@ -138,7 +139,7 @@ std::map tests = { testIn.Struct.Int = 300; testIn.Struct.BString = "Test String 2"; // run tests - const auto [buff, err] = ox::writeMC(&testIn); + const auto [buff, err] = ox::writeMC(testIn); oxAssert(err, "writeMC failed"); oxAssert(ox::readMC(buff.data(), buff.size(), &testOut), "readMC failed"); //std::cout << testIn.Union.Int << "|" << testOut.Union.Int << "|\n"; @@ -306,7 +307,7 @@ std::map tests = { testIn.Struct.BString = "Test String 2"; testIn.unionIdx = 1; testIn.Union.Int = 93; - oxAssert(ox::writeMC(dataBuff.data(), dataBuff.size(), &testIn), "Data generation failed"); + oxAssert(ox::writeMC(dataBuff.data(), dataBuff.size(), testIn), "Data generation failed"); ox::TypeStore typeStore; const auto [type, typeErr] = ox::buildTypeDef(&typeStore, &testIn); oxAssert(typeErr, "Descriptor write failed"); @@ -358,7 +359,7 @@ std::map tests = { testIn.Struct.Bool = false; testIn.Struct.Int = 300; testIn.Struct.BString = "Test String 2"; - oxAssert(ox::writeMC(dataBuff, dataBuffLen, &testIn), "Data generation failed"); + oxAssert(ox::writeMC(dataBuff, dataBuffLen, testIn), "Data generation failed"); ox::TypeStore typeStore; const auto [type, typeErr] = ox::buildTypeDef(&typeStore, &testIn); oxAssert(typeErr, "Descriptor write failed"); diff --git a/deps/ox/src/ox/mc/write.hpp b/deps/ox/src/ox/mc/write.hpp index 78031420..4ca71022 100644 --- a/deps/ox/src/ox/mc/write.hpp +++ b/deps/ox/src/ox/mc/write.hpp @@ -414,17 +414,17 @@ Result writeMC(Writer_c auto &writer, const auto &val) noexcept { return {}; } -Result writeMC(const auto *val, std::size_t buffReserveSz = 2 * units::KB) noexcept { +Result writeMC(const auto &val, std::size_t buffReserveSz = 2 * units::KB) noexcept { Buffer buff(buffReserveSz); BufferWriter bw(&buff, 0); - oxReturnError(writeMC(bw, *val)); + oxReturnError(writeMC(bw, val)); buff.resize(bw.tellp()); return buff; } -Error writeMC(char *buff, std::size_t buffLen, const auto *val, std::size_t *sizeOut = nullptr) noexcept { +Error writeMC(char *buff, std::size_t buffLen, const auto &val, std::size_t *sizeOut = nullptr) noexcept { CharBuffWriter bw(buff, buffLen); - oxReturnError(writeMC(bw, *val)); + oxReturnError(writeMC(bw, val)); if (sizeOut) { *sizeOut = bw.tellp(); } diff --git a/deps/ox/src/ox/oc/write.hpp b/deps/ox/src/ox/oc/write.hpp index 4881ce87..b4458439 100644 --- a/deps/ox/src/ox/oc/write.hpp +++ b/deps/ox/src/ox/oc/write.hpp @@ -24,7 +24,7 @@ namespace ox { class OrganicClawWriter { - friend Result writeOC(auto &val) noexcept; + friend Result writeOC(const auto &val) noexcept; protected: Json::Value m_json; @@ -248,7 +248,7 @@ Error OrganicClawWriter::field(const char *key, UnionView val) noexcep return OxError(0); } -Result writeOC(auto &val) noexcept { +Result writeOC(const auto &val) noexcept { OrganicClawWriter writer; ModelHandlerInterface handler(&writer); oxReturnError(model(&handler, &val));