From a00a0bd2ffe477f5889bb7fb55784d4f690db039 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Wed, 24 Apr 2024 00:54:02 -0500 Subject: [PATCH] [ox] Rename BString to IString --- deps/ox/src/ox/claw/test/tests.cpp | 4 +- deps/ox/src/ox/fs/filesystem/pathiterator.cpp | 4 +- deps/ox/src/ox/fs/filesystem/pathiterator.hpp | 2 +- deps/ox/src/ox/fs/test/tests.cpp | 2 +- deps/ox/src/ox/mc/read.hpp | 4 +- deps/ox/src/ox/mc/test/tests.cpp | 32 +++---- deps/ox/src/ox/mc/write.hpp | 4 +- deps/ox/src/ox/model/descwrite.hpp | 6 +- deps/ox/src/ox/model/metadata.hpp | 2 +- deps/ox/src/ox/model/typenamecatcher.hpp | 6 +- deps/ox/src/ox/model/types.hpp | 2 +- deps/ox/src/ox/oc/read.hpp | 4 +- deps/ox/src/ox/oc/test/tests.cpp | 2 +- deps/ox/src/ox/oc/write.hpp | 2 +- deps/ox/src/ox/std/CMakeLists.txt | 2 +- deps/ox/src/ox/std/cstringview.hpp | 4 +- deps/ox/src/ox/std/fmt.hpp | 4 +- .../src/ox/std/{bstring.hpp => istring.hpp} | 93 ++++++++++--------- deps/ox/src/ox/std/std.hpp | 2 +- deps/ox/src/ox/std/stringliteral.hpp | 3 +- deps/ox/src/ox/std/stringview.hpp | 4 +- deps/ox/src/ox/std/test/tests.cpp | 2 +- deps/ox/src/ox/std/trace.hpp | 4 +- deps/ox/src/ox/std/typetraits.hpp | 4 +- deps/ox/src/ox/std/uuid.hpp | 6 +- 25 files changed, 103 insertions(+), 101 deletions(-) rename deps/ox/src/ox/std/{bstring.hpp => istring.hpp} (64%) diff --git a/deps/ox/src/ox/claw/test/tests.cpp b/deps/ox/src/ox/claw/test/tests.cpp index d4023331..17a801c7 100644 --- a/deps/ox/src/ox/claw/test/tests.cpp +++ b/deps/ox/src/ox/claw/test/tests.cpp @@ -29,7 +29,7 @@ struct TestStructNest { static constexpr auto TypeVersion = 1; bool Bool = false; uint32_t Int = 0; - ox::BString<32> String = ""; + ox::IString<32> String = ""; }; struct TestStruct { @@ -47,7 +47,7 @@ struct TestStruct { int32_t Int8 = 0; int unionIdx = 1; TestUnion Union; - ox::BString<32> String = ""; + ox::IString<32> String = ""; uint32_t List[4] = {0, 0, 0, 0}; TestStructNest EmptyStruct; TestStructNest Struct; diff --git a/deps/ox/src/ox/fs/filesystem/pathiterator.cpp b/deps/ox/src/ox/fs/filesystem/pathiterator.cpp index 853cfe6f..1d330b0f 100644 --- a/deps/ox/src/ox/fs/filesystem/pathiterator.cpp +++ b/deps/ox/src/ox/fs/filesystem/pathiterator.cpp @@ -132,14 +132,14 @@ Error PathIterator::next(char *pathOut, std::size_t pathOutSize) { /** * @return 0 if no error */ -Error PathIterator::get(BString *fileName) { +Error PathIterator::get(IString *fileName) { return get(fileName->data(), fileName->cap()); } /** * @return 0 if no error */ -Error PathIterator::next(BString *fileName) { +Error PathIterator::next(IString *fileName) { return next(fileName->data(), fileName->cap()); } diff --git a/deps/ox/src/ox/fs/filesystem/pathiterator.hpp b/deps/ox/src/ox/fs/filesystem/pathiterator.hpp index e0a9b162..127198a9 100644 --- a/deps/ox/src/ox/fs/filesystem/pathiterator.hpp +++ b/deps/ox/src/ox/fs/filesystem/pathiterator.hpp @@ -13,7 +13,7 @@ namespace ox { constexpr std::size_t MaxFileNameLength = 255; -using FileName = BString; +using FileName = IString; class PathIterator { private: diff --git a/deps/ox/src/ox/fs/test/tests.cpp b/deps/ox/src/ox/fs/test/tests.cpp index 49fcd79b..b9bdc2d5 100644 --- a/deps/ox/src/ox/fs/test/tests.cpp +++ b/deps/ox/src/ox/fs/test/tests.cpp @@ -34,7 +34,7 @@ const std::map> tests = using BuffPtr_t = uint32_t; ox::Vector buff(5 * ox::units::MB); auto buffer = new (buff.data()) ox::ptrarith::NodeBuffer>(buff.size()); - using String = ox::BString<6>; + using String = ox::IString<6>; auto a1 = buffer->malloc(sizeof(String)).value; auto a2 = buffer->malloc(sizeof(String)).value; oxAssert(a1.valid(), "Allocation 1 failed."); diff --git a/deps/ox/src/ox/mc/read.hpp b/deps/ox/src/ox/mc/read.hpp index d5cd1688..5133f11c 100644 --- a/deps/ox/src/ox/mc/read.hpp +++ b/deps/ox/src/ox/mc/read.hpp @@ -77,7 +77,7 @@ class MetalClawReaderTemplate: public ModelHandlerBase *val) noexcept; template - constexpr Error field(const char*, BString *val) noexcept; + constexpr Error field(const char*, IString *val) noexcept; constexpr Error fieldCString(const char*, char *val, std::size_t buffLen) noexcept; @@ -336,7 +336,7 @@ constexpr Error MetalClawReaderTemplate::field(const char*, BasicString< template template -constexpr Error MetalClawReaderTemplate::field(const char *name, BString *val) noexcept { +constexpr Error MetalClawReaderTemplate::field(const char *name, IString *val) noexcept { return fieldCString(name, val->data(), val->cap()); } diff --git a/deps/ox/src/ox/mc/test/tests.cpp b/deps/ox/src/ox/mc/test/tests.cpp index 9408cfc7..24b66dc8 100644 --- a/deps/ox/src/ox/mc/test/tests.cpp +++ b/deps/ox/src/ox/mc/test/tests.cpp @@ -27,7 +27,7 @@ struct TestStructNest { static constexpr auto TypeVersion = 1; bool Bool = false; uint32_t Int = 0; - ox::BString<32> BString = ""; + ox::IString<32> IString = ""; }; struct TestStruct { @@ -46,7 +46,7 @@ struct TestStruct { int unionIdx = 1; TestUnion Union; ox::String String; - ox::BString<32> BString = ""; + ox::IString<32> IString = ""; uint32_t List[4] = {0, 0, 0, 0}; ox::Vector Vector = {1, 2, 3, 4, 5}; ox::Vector Vector2 = {1, 2, 3, 4, 5}; @@ -72,7 +72,7 @@ constexpr ox::Error model(T *io, ox::CommonPtrWith auto *obj) noexcep oxModelBegin(TestStructNest) oxModelField(Bool) oxModelField(Int) - oxModelField(BString) + oxModelField(IString) oxModelEnd() template @@ -95,7 +95,7 @@ constexpr ox::Error model(T *io, ox::CommonPtrWith auto *obj) noexce oxReturnError(io->field("Union", ox::UnionView{&obj->Union, obj->unionIdx})); } oxReturnError(io->field("String", &obj->String)); - oxReturnError(io->field("BString", &obj->BString)); + oxReturnError(io->field("IString", &obj->IString)); oxReturnError(io->field("List", obj->List, 4)); oxReturnError(io->field("Vector", &obj->Vector)); oxReturnError(io->field("Vector2", &obj->Vector2)); @@ -127,7 +127,7 @@ std::map tests = { TestStruct testIn, testOut; testIn.Bool = true; testIn.Int = 42; - testIn.BString = "Test String 1"; + testIn.IString = "Test String 1"; testIn.String = "Test String 2"; testIn.Vector = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, }; testIn.Vector2 = {}; @@ -137,7 +137,7 @@ std::map tests = { testIn.List[3] = 4; testIn.Struct.Bool = true; testIn.Struct.Int = 300; - testIn.Struct.BString = "Test String 3"; + testIn.Struct.IString = "Test String 3"; testIn.unionIdx = 1; testIn.Union.Int = 93; // run tests @@ -157,7 +157,7 @@ std::map tests = { oxAssert(testIn.Int8 == testOut.Int8, "Int8 value mismatch"); oxAssert(testIn.Union.Int == testOut.Union.Int, "Union.Int value mismatch"); oxAssert(testIn.String == testOut.String, "String value mismatch"); - oxAssert(testIn.BString == testOut.BString, "BString value mismatch"); + oxAssert(testIn.IString == testOut.IString, "IString value mismatch"); oxAssert(testIn.List[0] == testOut.List[0], "List[0] value mismatch"); oxAssert(testIn.List[1] == testOut.List[1], "List[1] value mismatch"); oxAssert(testIn.List[2] == testOut.List[2], "List[2] value mismatch"); @@ -171,9 +171,9 @@ std::map tests = { oxAssert(testIn.Map["aoeu"] == testOut.Map["aoeu"], "Map[\"aoeu\"] value mismatch"); oxAssert(testIn.EmptyStruct.Bool == testOut.EmptyStruct.Bool, "EmptyStruct.Bool value mismatch"); oxAssert(testIn.EmptyStruct.Int == testOut.EmptyStruct.Int, "EmptyStruct.Int value mismatch"); - oxAssert(testIn.EmptyStruct.BString == testOut.EmptyStruct.BString, "EmptyStruct.BString value mismatch"); + oxAssert(testIn.EmptyStruct.IString == testOut.EmptyStruct.IString, "EmptyStruct.IString value mismatch"); oxAssert(testIn.Struct.Int == testOut.Struct.Int, "Struct.Int value mismatch"); - oxAssert(testIn.Struct.BString == testOut.Struct.BString, "Struct.BString value mismatch"); + oxAssert(testIn.Struct.IString == testOut.Struct.IString, "Struct.IString value mismatch"); oxAssert(testIn.Struct.Bool == testOut.Struct.Bool, "Struct.Bool value mismatch"); return OxError(0); } @@ -303,14 +303,14 @@ std::map tests = { TestStruct testIn; testIn.Bool = true; testIn.Int = 42; - testIn.BString = "Test String 1"; + testIn.IString = "Test String 1"; testIn.List[0] = 1; testIn.List[1] = 2; testIn.List[2] = 3; testIn.List[3] = 4; testIn.Struct.Bool = true; testIn.Struct.Int = 300; - testIn.Struct.BString = "Test String 2"; + testIn.Struct.IString = "Test String 2"; testIn.unionIdx = 1; testIn.Union.Int = 93; oxAssert(ox::writeMC(dataBuff.data(), dataBuff.size(), testIn), "Data generation failed"); @@ -322,7 +322,7 @@ std::map tests = { oxAssert(ox::readMC(dataBuff.data(), dataBuff.size(), &testOut), "Data read failed"); oxAssert(testOut.at("Int").unwrap()->get() == testIn.Int, "testOut.Int failed"); oxAssert(testOut.at("Bool").unwrap()->get() == testIn.Bool, "testOut.Bool failed"); - oxAssert(testOut.at("BString").unwrap()->get() == testIn.BString.c_str(), "testOut.String failed"); + oxAssert(testOut.at("IString").unwrap()->get() == testIn.IString.c_str(), "testOut.String failed"); oxAssert(testOut.at("String").unwrap()->get() == testIn.String, "testOut.String failed"); auto &testOutStruct = testOut.at("Struct").unwrap()->get(); auto &testOutUnion = testOut.at("Union").unwrap()->get(); @@ -333,14 +333,14 @@ std::map tests = { oxAssert(testOutStruct.typeName() == TestStructNest::TypeName, "ModelObject TypeName failed"); oxAssert(testOutStruct.typeVersion() == TestStructNest::TypeVersion, "ModelObject TypeVersion failed"); oxAssert(testOutStruct.at("Bool").unwrap()->get() == testIn.Struct.Bool, "testOut.Struct.Bool failed"); - oxAssert(testOutStruct.at("BString").unwrap()->get() == testIn.Struct.BString.c_str(), "testOut.Struct.BString failed"); + oxAssert(testOutStruct.at("IString").unwrap()->get() == testIn.Struct.IString.c_str(), "testOut.Struct.IString failed"); oxAssert(testOut.at("unionIdx").unwrap()->get() == testIn.unionIdx, "testOut.unionIdx failed"); oxAssert(testOutUnion.unionIdx() == testIn.unionIdx, "testOut.Union idx wrong"); oxAssert(testOutUnion.at("Int").unwrap()->get() == testIn.Union.Int, "testOut.Union.Int failed"); oxAssert(testOutList[0].get() == testIn.List[0], "testOut.List[0] failed"); oxAssert(testOutList[1].get() == testIn.List[1], "testOut.Struct.List[1] failed"); oxAssert(testOutStructCopy.at("Bool").unwrap()->get() == testIn.Struct.Bool, "testOut.Struct.Bool (copy) failed"); - oxAssert(testOutStructCopy.at("BString").unwrap()->get() == testIn.Struct.BString.c_str(), "testOut.Struct.BString (copy) failed"); + oxAssert(testOutStructCopy.at("IString").unwrap()->get() == testIn.Struct.IString.c_str(), "testOut.Struct.IString (copy) failed"); oxAssert(testOutListCopy[0].get() == testIn.List[0], "testOut.Struct.List[0] (copy) failed"); oxAssert(testOutListCopy[1].get() == testIn.List[1], "testOut.Struct.List[1] (copy) failed"); return OxError(0); @@ -357,14 +357,14 @@ std::map tests = { TestStruct testIn, testOut; testIn.Bool = true; testIn.Int = 42; - testIn.BString = "Test String 1"; + testIn.IString = "Test String 1"; testIn.List[0] = 1; testIn.List[1] = 2; testIn.List[2] = 3; testIn.List[3] = 4; testIn.Struct.Bool = false; testIn.Struct.Int = 300; - testIn.Struct.BString = "Test String 2"; + testIn.Struct.IString = "Test String 2"; oxAssert(ox::writeMC(dataBuff, dataBuffLen, testIn), "Data generation failed"); ox::TypeStore typeStore; const auto [type, typeErr] = ox::buildTypeDef(&typeStore, &testIn); diff --git a/deps/ox/src/ox/mc/write.hpp b/deps/ox/src/ox/mc/write.hpp index 103b059a..fb1ed706 100644 --- a/deps/ox/src/ox/mc/write.hpp +++ b/deps/ox/src/ox/mc/write.hpp @@ -66,7 +66,7 @@ class MetalClawWriter { constexpr Error field(const char*, const BasicString *val) noexcept; template - constexpr Error field(const char*, const BString *val) noexcept; + constexpr Error field(const char*, const IString *val) noexcept; constexpr Error fieldCString(const char *name, const char *const*val, std::size_t buffLen) noexcept; @@ -206,7 +206,7 @@ constexpr Error MetalClawWriter::field(const char*, const BasicString template -constexpr Error MetalClawWriter::field(const char *name, const BString *val) noexcept { +constexpr Error MetalClawWriter::field(const char *name, const IString *val) noexcept { return fieldCString(name, val->data(), val->cap()); } diff --git a/deps/ox/src/ox/model/descwrite.hpp b/deps/ox/src/ox/model/descwrite.hpp index 81f89266..e0bf9844 100644 --- a/deps/ox/src/ox/model/descwrite.hpp +++ b/deps/ox/src/ox/model/descwrite.hpp @@ -9,7 +9,7 @@ #pragma once #include -#include +#include #include #include #include @@ -152,7 +152,7 @@ class TypeDescWriter { template [[nodiscard]] - constexpr const DescriptorType *type(const BString *val) const noexcept; + constexpr const DescriptorType *type(const IString *val) const noexcept; template [[nodiscard]] @@ -334,7 +334,7 @@ constexpr const DescriptorType *TypeDescWriter::type(const char*) const noexcept } template -constexpr const DescriptorType *TypeDescWriter::type(const BString*) const noexcept { +constexpr const DescriptorType *TypeDescWriter::type(const IString*) const noexcept { constexpr auto PT = PrimitiveType::String; return getType(types::BString, 0, PT, 0); } diff --git a/deps/ox/src/ox/model/metadata.hpp b/deps/ox/src/ox/model/metadata.hpp index ab21ffac..c11ebc53 100644 --- a/deps/ox/src/ox/model/metadata.hpp +++ b/deps/ox/src/ox/model/metadata.hpp @@ -9,7 +9,7 @@ #pragma once #include -#include +#include #include #include #include diff --git a/deps/ox/src/ox/model/typenamecatcher.hpp b/deps/ox/src/ox/model/typenamecatcher.hpp index f64377b2..0c6234a4 100644 --- a/deps/ox/src/ox/model/typenamecatcher.hpp +++ b/deps/ox/src/ox/model/typenamecatcher.hpp @@ -151,15 +151,15 @@ template constexpr auto ModelTypeVersionStr_v = [] { constexpr auto version = ModelTypeVersion_v; constexpr auto versionStr = ox::sfmt("{}", version); - return ox::BString{versionStr}; + return ox::IString{versionStr}; }; template constexpr auto ModelTypeId_v = [] { constexpr auto name = ModelTypeName_v; constexpr auto version = ModelTypeVersion_v; - constexpr auto versionStr = ox::sfmt>("{}", version); - return ox::sfmt>("{};{}", name, versionStr); + constexpr auto versionStr = ox::sfmt>("{}", version); + return ox::sfmt>("{};{}", name, versionStr); }(); } diff --git a/deps/ox/src/ox/model/types.hpp b/deps/ox/src/ox/model/types.hpp index 084cf7f5..5d54bfe8 100644 --- a/deps/ox/src/ox/model/types.hpp +++ b/deps/ox/src/ox/model/types.hpp @@ -21,7 +21,7 @@ #endif #include -#include +#include #include #include #include diff --git a/deps/ox/src/ox/oc/read.hpp b/deps/ox/src/ox/oc/read.hpp index 71a938fb..aa7b66c3 100644 --- a/deps/ox/src/ox/oc/read.hpp +++ b/deps/ox/src/ox/oc/read.hpp @@ -70,7 +70,7 @@ class OrganicClawReader { Error field(const char *key, BasicString *val) noexcept; template - Error field(const char *key, BString *val) noexcept; + Error field(const char *key, IString *val) noexcept; Error fieldCString(const char *key, char *val, std::size_t buffLen) noexcept; @@ -206,7 +206,7 @@ Error OrganicClawReader::field(const char *key, BasicString *val) noexcept { } template -Error OrganicClawReader::field(const char *key, BString *val) noexcept { +Error OrganicClawReader::field(const char *key, IString *val) noexcept { return fieldCString(key, val->data(), val->cap()); } diff --git a/deps/ox/src/ox/oc/test/tests.cpp b/deps/ox/src/ox/oc/test/tests.cpp index a6c088b9..ec33c37a 100644 --- a/deps/ox/src/ox/oc/test/tests.cpp +++ b/deps/ox/src/ox/oc/test/tests.cpp @@ -35,7 +35,7 @@ struct TestStructNest { static constexpr auto TypeVersion = 1; bool Bool = false; uint32_t Int = 0; - ox::BString<32> String = ""; + ox::IString<32> String = ""; }; struct TestStruct { diff --git a/deps/ox/src/ox/oc/write.hpp b/deps/ox/src/ox/oc/write.hpp index d436824c..af050404 100644 --- a/deps/ox/src/ox/oc/write.hpp +++ b/deps/ox/src/ox/oc/write.hpp @@ -132,7 +132,7 @@ class OrganicClawWriter { } template - Error field(char const*key, BString const*val) noexcept { + Error field(char const*key, IString const*val) noexcept { if (targetValid() && val->len()) { value(key) = val->c_str(); } diff --git a/deps/ox/src/ox/std/CMakeLists.txt b/deps/ox/src/ox/std/CMakeLists.txt index fbf8adb9..6c958be6 100644 --- a/deps/ox/src/ox/std/CMakeLists.txt +++ b/deps/ox/src/ox/std/CMakeLists.txt @@ -90,7 +90,7 @@ install( assert.hpp bit.hpp bounds.hpp - bstring.hpp + istring.hpp buffer.hpp buildinfo.hpp byteswap.hpp diff --git a/deps/ox/src/ox/std/cstringview.hpp b/deps/ox/src/ox/std/cstringview.hpp index 28155543..47435c17 100644 --- a/deps/ox/src/ox/std/cstringview.hpp +++ b/deps/ox/src/ox/std/cstringview.hpp @@ -9,7 +9,7 @@ #pragma once #include "basestringview.hpp" -#include "bstring.hpp" +#include "istring.hpp" #include "string.hpp" #include "stringliteral.hpp" @@ -27,7 +27,7 @@ class CStringView: public detail::BaseStringView { constexpr CStringView(BasicString const&str) noexcept: BaseStringView(str.data(), str.len()) {} template - constexpr CStringView(BString const&str) noexcept: BaseStringView(str.data(), str.len()) {} + constexpr CStringView(IString const&str) noexcept: BaseStringView(str.data(), str.len()) {} constexpr CStringView(std::nullptr_t) noexcept {} diff --git a/deps/ox/src/ox/std/fmt.hpp b/deps/ox/src/ox/std/fmt.hpp index fe714084..21493375 100644 --- a/deps/ox/src/ox/std/fmt.hpp +++ b/deps/ox/src/ox/std/fmt.hpp @@ -19,7 +19,7 @@ #include "realstd.hpp" #include "error.hpp" #include "ignore.hpp" -#include "bstring.hpp" +#include "istring.hpp" #include "string.hpp" #include "strops.hpp" #include "types.hpp" @@ -39,7 +39,7 @@ constexpr StringView toStringView(const char *s) noexcept { } template -constexpr StringView toStringView(const BString &s) noexcept { +constexpr StringView toStringView(const IString &s) noexcept { return s.c_str(); } diff --git a/deps/ox/src/ox/std/bstring.hpp b/deps/ox/src/ox/std/istring.hpp similarity index 64% rename from deps/ox/src/ox/std/bstring.hpp rename to deps/ox/src/ox/std/istring.hpp index 6686701d..eb02dc7a 100644 --- a/deps/ox/src/ox/std/bstring.hpp +++ b/deps/ox/src/ox/std/istring.hpp @@ -16,40 +16,41 @@ namespace ox { -// Bounded String +// Inline String template -class BString { +class IString { private: char m_buff[buffLen + 1]; + size_t m_size{}; public: - constexpr BString() noexcept; + constexpr IString() noexcept; - constexpr BString(StringView str) noexcept; + constexpr IString(StringView str) noexcept; - constexpr BString(const char *str) noexcept; + constexpr IString(const char *str) noexcept; - constexpr BString &operator=(CRStringView str) noexcept; + constexpr IString &operator=(CRStringView str) noexcept; - constexpr BString &operator=(const char *str) noexcept; + constexpr IString &operator=(const char *str) noexcept; - constexpr BString &operator=(char *str) noexcept; + constexpr IString &operator=(char *str) noexcept; - constexpr BString &operator=(Integer_c auto i) noexcept; + constexpr IString &operator=(Integer_c auto i) noexcept; - constexpr BString &operator+=(const char *str) noexcept; + constexpr IString &operator+=(const char *str) noexcept; - constexpr BString &operator+=(char *str) noexcept; + constexpr IString &operator+=(char *str) noexcept; - constexpr BString &operator+=(Integer_c auto i) noexcept; + constexpr IString &operator+=(Integer_c auto i) noexcept; - constexpr BString &operator+=(StringView s) noexcept; + constexpr IString &operator+=(StringView s) noexcept; - constexpr BString operator+(const char *str) const noexcept; + constexpr IString operator+(const char *str) const noexcept; - constexpr BString operator+(char *str) const noexcept; + constexpr IString operator+(char *str) const noexcept; - constexpr BString operator+(Integer_c auto i) const noexcept; + constexpr IString operator+(Integer_c auto i) const noexcept; constexpr bool operator==(const char *other) const noexcept; @@ -94,83 +95,85 @@ class BString { }; template -constexpr BString::BString() noexcept: m_buff{{0}} { +constexpr IString::IString() noexcept: m_buff{{0}} { } template -constexpr BString::BString(StringView str) noexcept: m_buff{{0}} { +constexpr IString::IString(StringView str) noexcept: m_buff{{0}} { operator=(str); } template -constexpr BString::BString(const char *str) noexcept: m_buff{{0}} { +constexpr IString::IString(const char *str) noexcept: m_buff{{0}} { operator=(str); } template -constexpr BString &BString::operator=(Integer_c auto i) noexcept { +constexpr IString &IString::operator=(Integer_c auto i) noexcept { char str[65] = {}; ox::itoa(i, str); return this->operator=(str); } template -constexpr BString &BString::operator=(ox::CRStringView str) noexcept { +constexpr IString &IString::operator=(ox::CRStringView str) noexcept { std::size_t strLen = str.bytes() + 1; if (cap() < strLen) { strLen = cap(); } - ox::memcpy(m_buff, str.data(), strLen); + m_size = strLen; + ox::listcpy(m_buff, str.data(), strLen); // make sure last element is a null terminator m_buff[strLen] = 0; return *this; } template -constexpr BString &BString::operator=(const char *str) noexcept { +constexpr IString &IString::operator=(const char *str) noexcept { std::size_t strLen = ox::strlen(str) + 1; if (cap() < strLen) { strLen = cap(); } - ox::memcpy(m_buff, str, strLen); + m_size = strLen; + ox::listcpy(m_buff, str, strLen); // make sure last element is a null terminator m_buff[cap()] = 0; return *this; } template -constexpr BString &BString::operator=(char *str) noexcept { +constexpr IString &IString::operator=(char *str) noexcept { return *this = static_cast(str); } template -constexpr BString &BString::operator+=(const char *str) noexcept { +constexpr IString &IString::operator+=(const char *str) noexcept { std::size_t strLen = ox::strlen(str) + 1; std::ignore = append(str, strLen); return *this; } template -constexpr BString &BString::operator+=(char *str) noexcept { +constexpr IString &IString::operator+=(char *str) noexcept { return *this += static_cast(str); } template -constexpr BString &BString::operator+=(Integer_c auto i) noexcept { +constexpr IString &IString::operator+=(Integer_c auto i) noexcept { char str[65] = {}; ox::itoa(i, str); return this->operator+=(str); } template -constexpr BString &BString::operator+=(StringView s) noexcept { +constexpr IString &IString::operator+=(StringView s) noexcept { std::size_t strLen = s.bytes(); std::ignore = append(s.data(), strLen); return *this; } template -constexpr BString BString::operator+(const char *str) const noexcept { +constexpr IString IString::operator+(const char *str) const noexcept { auto out = *this; std::size_t strLen = ox::strlen(str) + 1; std::ignore = out.append(str, strLen); @@ -178,49 +181,49 @@ constexpr BString BString::operator+(const char *str) const noexcept } template -constexpr BString BString::operator+(char *str) const noexcept { +constexpr IString IString::operator+(char *str) const noexcept { return *this + static_cast(str); } template -constexpr BString BString::operator+(Integer_c auto i) const noexcept { +constexpr IString IString::operator+(Integer_c auto i) const noexcept { char str[65] = {}; ox::itoa(i, str); return this->operator+(str); } template -constexpr bool BString::operator==(const char *other) const noexcept { +constexpr bool IString::operator==(const char *other) const noexcept { return ox::StringView(*this) == other; } template -constexpr bool BString::operator==(const OxString_c auto &other) const noexcept { +constexpr bool IString::operator==(const OxString_c auto &other) const noexcept { return ox::StringView(*this) == ox::StringView(other); } template -constexpr bool BString::operator!=(const char *other) const noexcept { +constexpr bool IString::operator!=(const char *other) const noexcept { return !operator==(other); } template -constexpr bool BString::operator!=(const OxString_c auto &other) noexcept { +constexpr bool IString::operator!=(const OxString_c auto &other) noexcept { return !operator==(other); } template -constexpr char BString::operator[](std::size_t i) const noexcept { +constexpr char IString::operator[](std::size_t i) const noexcept { return m_buff[i]; } template -constexpr char &BString::operator[](std::size_t i) noexcept { +constexpr char &IString::operator[](std::size_t i) noexcept { return m_buff[i]; } template -constexpr Error BString::append(const char *str, std::size_t strLen) noexcept { +constexpr Error IString::append(const char *str, std::size_t strLen) noexcept { Error err; auto currentLen = len(); if (cap() < currentLen + strLen + 1) { @@ -234,23 +237,23 @@ constexpr Error BString::append(const char *str, std::size_t strLen) no } template -constexpr const char *BString::data() const noexcept { +constexpr const char *IString::data() const noexcept { return static_cast(m_buff); } template -constexpr char *BString::data() noexcept { +constexpr char *IString::data() noexcept { return static_cast(m_buff); } template -constexpr const char *BString::c_str() const noexcept { +constexpr const char *IString::c_str() const noexcept { return static_cast(m_buff); } template -constexpr std::size_t BString::len() const noexcept { +constexpr std::size_t IString::len() const noexcept { std::size_t length = 0; for (std::size_t i = 0; i < buffLen; i++) { uint8_t b = static_cast(m_buff[i]); @@ -268,14 +271,14 @@ constexpr std::size_t BString::len() const noexcept { } template -constexpr std::size_t BString::bytes() const noexcept { +constexpr std::size_t IString::bytes() const noexcept { std::size_t i = 0; for (i = 0; i < buffLen && m_buff[i]; i++); return i + 1; // add one for null terminator } template -constexpr std::size_t BString::cap() const noexcept { +constexpr std::size_t IString::cap() const noexcept { return buffLen; } diff --git a/deps/ox/src/ox/std/std.hpp b/deps/ox/src/ox/std/std.hpp index 85e5fedb..be073120 100644 --- a/deps/ox/src/ox/std/std.hpp +++ b/deps/ox/src/ox/std/std.hpp @@ -13,7 +13,7 @@ #include "assert.hpp" #include "bit.hpp" #include "bounds.hpp" -#include "bstring.hpp" +#include "istring.hpp" #include "byteswap.hpp" #include "concepts.hpp" #include "cstringview.hpp" diff --git a/deps/ox/src/ox/std/stringliteral.hpp b/deps/ox/src/ox/std/stringliteral.hpp index 868a1c12..e6ddc4c2 100644 --- a/deps/ox/src/ox/std/stringliteral.hpp +++ b/deps/ox/src/ox/std/stringliteral.hpp @@ -32,8 +32,7 @@ class StringLiteral: public detail::BaseStringView { constexpr explicit StringLiteral(const char *str, std::size_t len) noexcept: BaseStringView(str, len) {} - template - constexpr explicit StringLiteral(char const (&str)[Sz]) noexcept: StringLiteral(str, Sz) { + constexpr explicit StringLiteral(char const *str) noexcept: StringLiteral(str, ox::strlen(str)) { } constexpr auto &operator=(StringLiteral const&other) noexcept { diff --git a/deps/ox/src/ox/std/stringview.hpp b/deps/ox/src/ox/std/stringview.hpp index 5ba7f802..1b3c83e9 100644 --- a/deps/ox/src/ox/std/stringview.hpp +++ b/deps/ox/src/ox/std/stringview.hpp @@ -20,7 +20,7 @@ namespace ox { template -class BString; +class IString; template class BasicString; @@ -41,7 +41,7 @@ class StringView: public detail::BaseStringView { constexpr StringView(const BasicString &str) noexcept: BaseStringView(str.data(), str.len()) {} template - constexpr StringView(const BString &str) noexcept: BaseStringView(str.data(), str.len()) {} + constexpr StringView(const IString &str) noexcept: BaseStringView(str.data(), str.len()) {} constexpr StringView(std::nullptr_t) noexcept {} diff --git a/deps/ox/src/ox/std/test/tests.cpp b/deps/ox/src/ox/std/test/tests.cpp index cf4d01ec..04a73639 100644 --- a/deps/ox/src/ox/std/test/tests.cpp +++ b/deps/ox/src/ox/std/test/tests.cpp @@ -68,7 +68,7 @@ static std::map tests = { { "BString", []() { - ox::BString<5> s; + ox::IString<5> s; s += "A"; s += "B"; s += 9; diff --git a/deps/ox/src/ox/std/trace.hpp b/deps/ox/src/ox/std/trace.hpp index 5740ccad..de7c5369 100644 --- a/deps/ox/src/ox/std/trace.hpp +++ b/deps/ox/src/ox/std/trace.hpp @@ -12,7 +12,7 @@ #include #endif -#include "bstring.hpp" +#include "istring.hpp" #include "def.hpp" #include "fmt.hpp" #include "hashmap.hpp" @@ -182,7 +182,7 @@ class OutStream { } template - constexpr OutStream &operator<<(const BString &v) noexcept { + constexpr OutStream &operator<<(const IString &v) noexcept { return operator<<(v.c_str()); } diff --git a/deps/ox/src/ox/std/typetraits.hpp b/deps/ox/src/ox/std/typetraits.hpp index 858c7176..3bfee6af 100644 --- a/deps/ox/src/ox/std/typetraits.hpp +++ b/deps/ox/src/ox/std/typetraits.hpp @@ -272,7 +272,7 @@ constexpr bool is_move_constructible_v = detail::is_move_constructible(0); template class BasicString; template -class BString; +class IString; class CStringView; class StringLiteral; class StringView; @@ -289,7 +289,7 @@ constexpr auto isOxString(const BasicString*) noexcept { } template -constexpr auto isOxString(const BString*) noexcept { +constexpr auto isOxString(const IString*) noexcept { return true; } diff --git a/deps/ox/src/ox/std/uuid.hpp b/deps/ox/src/ox/std/uuid.hpp index 5b910059..1d448ba1 100644 --- a/deps/ox/src/ox/std/uuid.hpp +++ b/deps/ox/src/ox/std/uuid.hpp @@ -9,7 +9,7 @@ #pragma once #include "array.hpp" -#include "bstring.hpp" +#include "istring.hpp" #include "buffer.hpp" #include "random.hpp" #include "ranges.hpp" @@ -17,7 +17,7 @@ namespace ox { -using UUIDStr = ox::BString<36>; +using UUIDStr = ox::IString<36>; namespace detail { @@ -61,7 +61,7 @@ constexpr ox::Result fromHex(ox::CRStringView v) noexcept { return out; } -constexpr ox::BString<2> toHex(uint8_t v) noexcept { +constexpr ox::IString<2> toHex(uint8_t v) noexcept { constexpr ox::Array valMap { '0', '1',