[ox] Make OC and Claw writers take const values

This commit is contained in:
2023-06-08 21:38:02 -05:00
parent 23054c9f6f
commit 5a021043f4
6 changed files with 15 additions and 14 deletions

View File

@@ -158,7 +158,7 @@ static std::map<std::string_view, ox::Error(*)()> 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";

View File

@@ -72,7 +72,7 @@ constexpr int getTypeVersion(const T *t) noexcept {
}
template<typename T>
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<Buffer> writeClaw(
auto &t,
const auto &t,
ClawFormat fmt = ClawFormat::Metal,
std::size_t buffReserveSz = 2 * units::KB) noexcept {
Buffer out(buffReserveSz);