diff --git a/deps/ox/src/ox/clargs/clargs.cpp b/deps/ox/src/ox/clargs/clargs.cpp index 854a88ee..1976f25f 100644 --- a/deps/ox/src/ox/clargs/clargs.cpp +++ b/deps/ox/src/ox/clargs/clargs.cpp @@ -17,14 +17,14 @@ ClArgs::ClArgs(ox::SpanView args) noexcept { for (auto i = 0u; i < args.size(); ++i) { auto arg = StringView{args[i]}; if (arg[0] == '-') { - while (arg[0] == '-' && arg.len()) { + while (arg[0] == '-' && arg.size()) { arg = substr(arg, 1); } m_bools[arg] = true; // parse additional arguments if (i < args.size() && args[i + 1]) { auto const val = StringView{args[i + 1]}; - if (val.len() && val[0] != '-') { + if (val.size() && val[0] != '-') { if (val == "false") { m_bools[arg] = false; } diff --git a/deps/ox/src/ox/claw/test/tests.cpp b/deps/ox/src/ox/claw/test/tests.cpp index a6ef919e..fc6661ca 100644 --- a/deps/ox/src/ox/claw/test/tests.cpp +++ b/deps/ox/src/ox/claw/test/tests.cpp @@ -109,7 +109,7 @@ static std::map tests = { "ClawHeaderReader", [] { constexpr auto hdr = ox::StringLiteral("O1;com.drinkingtea.ox.claw.test.Header;2;"); - auto [ch, err] = ox::readClawHeader({hdr.c_str(), hdr.len() + 1}); + auto [ch, err] = ox::readClawHeader({hdr.c_str(), hdr.size() + 1}); oxAssert(err, "Error parsing header"); oxAssert(ch.fmt == ox::ClawFormat::Organic, "Format wrong"); oxAssert(ch.typeName == "com.drinkingtea.ox.claw.test.Header", "Type name wrong"); @@ -121,7 +121,7 @@ static std::map tests = { "ClawHeaderReader2", [] { constexpr auto hdr = ox::StringLiteral("M2;com.drinkingtea.ox.claw.test.Header2;3;"); - auto [ch, err] = ox::readClawHeader({hdr.c_str(), hdr.len() + 1}); + auto [ch, err] = ox::readClawHeader({hdr.c_str(), hdr.size() + 1}); oxAssert(err, "Error parsing header"); oxAssert(ch.fmt == ox::ClawFormat::Metal, "Format wrong"); oxAssert(ch.typeName == "com.drinkingtea.ox.claw.test.Header2", "Type name wrong"); @@ -134,7 +134,7 @@ static std::map tests = { [] { constexpr auto hdr = ox::StringLiteral("M2;com.drinkingtea.ox.claw.test.Header2;3;awefawf"); constexpr auto expected = ox::StringLiteral("com.drinkingtea.ox.claw.test.Header2;3"); - OX_REQUIRE(actual, ox::readClawTypeId({hdr.data(), hdr.len() + 1})); + OX_REQUIRE(actual, ox::readClawTypeId({hdr.data(), hdr.size() + 1})); oxExpect(actual, expected); return ox::Error{}; } diff --git a/deps/ox/src/ox/fs/filesystem/directory.hpp b/deps/ox/src/ox/fs/filesystem/directory.hpp index 540ba7ac..23bf6db7 100644 --- a/deps/ox/src/ox/fs/filesystem/directory.hpp +++ b/deps/ox/src/ox/fs/filesystem/directory.hpp @@ -52,7 +52,7 @@ struct OX_PACKED DirectoryEntry { if (d.valid()) { d->inode = inode; auto const maxStrSz = bufferSize - 1 - sizeof(*this); - ox::strncpy(d->name, name.data(), ox::min(maxStrSz, name.len())); + ox::strncpy(d->name, name.data(), ox::min(maxStrSz, name.size())); return {}; } return ox::Error(1); @@ -219,7 +219,7 @@ Error Directory::write(PathIterator path, uint64_t inode64 oxTrace("ox.fs.Directory.write.fail", "Could not read existing version of Directory"); return ox::Error(1, "Could not read existing version of Directory"); } - const auto pathSize = name.len() + 1; + const auto pathSize = name.size() + 1; const auto entryDataSize = DirectoryEntry::DirectoryEntryData::spaceNeeded(pathSize); const auto newSize = oldStat.size + Buffer::spaceNeeded(entryDataSize); auto cpy = ox_malloca(newSize, Buffer, *old, oldStat.size); diff --git a/deps/ox/src/ox/fs/filesystem/passthroughfs.cpp b/deps/ox/src/ox/fs/filesystem/passthroughfs.cpp index f1f8d07c..f7cab7d9 100644 --- a/deps/ox/src/ox/fs/filesystem/passthroughfs.cpp +++ b/deps/ox/src/ox/fs/filesystem/passthroughfs.cpp @@ -206,7 +206,7 @@ Error PassThroughFS::writeFileInode(uint64_t, const void*, uint64_t, FileType) n } std::string_view PassThroughFS::stripSlash(StringView path) noexcept { - for (auto i = 0u; i < path.len() && path[0] == '/'; i++) { + for (auto i = 0u; i < path.size() && path[0] == '/'; i++) { path = substr(path, 1); } return {path.data(), path.bytes()}; diff --git a/deps/ox/src/ox/fs/filesystem/pathiterator.cpp b/deps/ox/src/ox/fs/filesystem/pathiterator.cpp index bd423833..39cf99aa 100644 --- a/deps/ox/src/ox/fs/filesystem/pathiterator.cpp +++ b/deps/ox/src/ox/fs/filesystem/pathiterator.cpp @@ -74,7 +74,7 @@ Error PathIterator::get(StringView &fileName) { if (size && fileName[size - 1] == '/') { fileName = ox::substr(m_path, start, start + size - 1); } - oxAssert(fileName[fileName.len()-1] != '/', "name ends in /"); + oxAssert(fileName[fileName.size()-1] != '/', "name ends in /"); return {}; } @@ -104,11 +104,11 @@ Error PathIterator::next(StringView &fileName) { } fileName = ox::substr(m_path, start, start + size); // truncate trailing / - while (fileName.len() && fileName[fileName.len() - 1] == '/') { + while (fileName.size() && fileName[fileName.size() - 1] == '/') { fileName = ox::substr(m_path, start, start + size); } m_iterator += size; - oxAssert(fileName.len() == 0 || fileName[fileName.len()-1] != '/', "name ends in /"); + oxAssert(fileName.size() == 0 || fileName[fileName.size()-1] != '/', "name ends in /"); } return retval; } diff --git a/deps/ox/src/ox/fs/test/tests.cpp b/deps/ox/src/ox/fs/test/tests.cpp index dfacd244..9c69afe7 100644 --- a/deps/ox/src/ox/fs/test/tests.cpp +++ b/deps/ox/src/ox/fs/test/tests.cpp @@ -59,7 +59,7 @@ const std::map> tests = "PathIterator::next1", [](ox::StringView) { auto constexpr path = ox::StringLiteral("/usr/share/charset.gbag"); - ox::PathIterator it(path.c_str(), path.len()); + ox::PathIterator it(path.c_str(), path.size()); ox::StringView buff; oxAssert(it.next(buff) == 0 && buff == "usr", "PathIterator shows wrong next"); oxAssert(it.next(buff) == 0 && buff == "share", "PathIterator shows wrong next"); @@ -84,7 +84,7 @@ const std::map> tests = "PathIterator::next3", [](ox::StringView) { auto const path = ox::String("/"); - ox::PathIterator it(path.c_str(), path.len()); + ox::PathIterator it(path.c_str(), path.size()); ox::StringView buff; oxAssert(it.next(buff) == 0 && buff == "\0", "PathIterator shows wrong next"); return ox::Error(0); @@ -106,7 +106,7 @@ const std::map> tests = "PathIterator::next5", [](ox::StringView) { auto const path = ox::String("usr/share/"); - ox::PathIterator it(path.c_str(), path.len()); + ox::PathIterator it(path.c_str(), path.size()); ox::StringView buff; oxAssert(it.next(buff) == 0 && buff == "usr", "PathIterator shows wrong next"); oxAssert(it.next(buff) == 0 && buff == "share", "PathIterator shows wrong next"); @@ -117,10 +117,10 @@ const std::map> tests = "PathIterator::dirPath", [] (ox::StringView) { auto constexpr path = ox::StringLiteral("/usr/share/charset.gbag"); - ox::PathIterator it(path.c_str(), path.len()); - auto buff = static_cast(ox_alloca(path.len() + 1)); + ox::PathIterator it(path.c_str(), path.size()); + auto buff = static_cast(ox_alloca(path.size() + 1)); OX_ALLOW_UNSAFE_BUFFERS_BEGIN - oxAssert(it.dirPath(buff, path.len()) == 0 && ox::strcmp(buff, "/usr/share/") == 0, "PathIterator shows incorrect dir path"); + oxAssert(it.dirPath(buff, path.size()) == 0 && ox::strcmp(buff, "/usr/share/") == 0, "PathIterator shows incorrect dir path"); OX_ALLOW_UNSAFE_BUFFERS_END return ox::Error(0); } diff --git a/deps/ox/src/ox/mc/test/tests.cpp b/deps/ox/src/ox/mc/test/tests.cpp index 180d8ef6..8d5a46d6 100644 --- a/deps/ox/src/ox/mc/test/tests.cpp +++ b/deps/ox/src/ox/mc/test/tests.cpp @@ -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"); - oxDebugf("{}", testOut.IString.len()); + oxDebugf("{}", testOut.IString.size()); oxExpect(testIn.IString, testOut.IString); oxAssert(testIn.List[0] == testOut.List[0], "List[0] value mismatch"); oxAssert(testIn.List[1] == testOut.List[1], "List[1] value mismatch"); diff --git a/deps/ox/src/ox/mc/write.hpp b/deps/ox/src/ox/mc/write.hpp index dfab98c6..4c836ff7 100644 --- a/deps/ox/src/ox/mc/write.hpp +++ b/deps/ox/src/ox/mc/write.hpp @@ -191,12 +191,12 @@ template template constexpr Error MetalClawWriter::field(const char*, const BasicString *val) noexcept { bool fieldSet = false; - if (val->len() && (!m_unionIdx.has_value() || *m_unionIdx == m_field)) { + if (val->size() && (!m_unionIdx.has_value() || *m_unionIdx == m_field)) { // write the length - const auto strLen = mc::encodeInteger(val->len()); + const auto strLen = mc::encodeInteger(val->size()); OX_RETURN_ERROR(m_writer.write(reinterpret_cast(strLen.data.data()), strLen.length)); // write the string - OX_RETURN_ERROR(m_writer.write(val->c_str(), static_cast(val->len()))); + OX_RETURN_ERROR(m_writer.write(val->c_str(), static_cast(val->size()))); fieldSet = true; } OX_RETURN_ERROR(m_fieldPresence.set(static_cast(m_field), fieldSet)); @@ -207,7 +207,7 @@ constexpr Error MetalClawWriter::field(const char*, const BasicString template constexpr Error MetalClawWriter::field(const char *name, const IString *val) noexcept { - return fieldCString(name, val->data(), val->len()); + return fieldCString(name, val->data(), val->size()); } template @@ -339,7 +339,7 @@ constexpr Error MetalClawWriter::field(const char*, const HashMap ox::Error { - const auto keyLen = key.len(); + const auto keyLen = key.size(); auto wkey = ox_malloca(keyLen + 1, char, 0); memcpy(wkey.get(), key.c_str(), keyLen + 1); OX_RETURN_ERROR(handler.fieldCString("", wkey.get(), keyLen)); diff --git a/deps/ox/src/ox/model/desctypes.hpp b/deps/ox/src/ox/model/desctypes.hpp index 4bbb7367..b436416b 100644 --- a/deps/ox/src/ox/model/desctypes.hpp +++ b/deps/ox/src/ox/model/desctypes.hpp @@ -43,7 +43,7 @@ static constexpr auto buildTypeId( for (const auto &p : typeParams) { tp += p + ","; } - tp.resize(tp.len() - 1); + tp.resize(tp.size() - 1); tp += "#"; } return ox::sfmt("{}{};{}", name, tp, version); diff --git a/deps/ox/src/ox/model/typenamecatcher.hpp b/deps/ox/src/ox/model/typenamecatcher.hpp index 418a2e08..4c5cd773 100644 --- a/deps/ox/src/ox/model/typenamecatcher.hpp +++ b/deps/ox/src/ox/model/typenamecatcher.hpp @@ -144,7 +144,7 @@ template [[nodiscard]] consteval auto requireModelTypeName() noexcept { constexpr auto name = getModelTypeName(); - static_assert(ox::StringView{name}.len(), "Type lacks required TypeName"); + static_assert(ox::StringView{name}.size(), "Type lacks required TypeName"); return name; } @@ -159,7 +159,7 @@ 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); + return ox::sfmt>("{};{}", name, versionStr); }(); } diff --git a/deps/ox/src/ox/oc/read.hpp b/deps/ox/src/ox/oc/read.hpp index 60593acb..81a12cd1 100644 --- a/deps/ox/src/ox/oc/read.hpp +++ b/deps/ox/src/ox/oc/read.hpp @@ -307,7 +307,7 @@ Result readOC(BufferView buff) noexcept { template Result readOC(ox::StringView json) noexcept { - return readOC(ox::BufferView{json.data(), json.len()}); + return readOC(ox::BufferView{json.data(), json.size()}); } } diff --git a/deps/ox/src/ox/oc/write.cpp b/deps/ox/src/ox/oc/write.cpp index 392cbf48..3e27a03e 100644 --- a/deps/ox/src/ox/oc/write.cpp +++ b/deps/ox/src/ox/oc/write.cpp @@ -32,7 +32,7 @@ Error OrganicClawWriter::fieldCString(const char *key, const char *const*val) no Error OrganicClawWriter::field(const char *key, const UUID *uuid) noexcept { const auto uuidStr = uuid->toString(); - if (targetValid() && uuidStr.len()) { + if (targetValid() && uuidStr.size()) { value(key) = uuidStr.c_str(); } ++m_fieldIt; diff --git a/deps/ox/src/ox/oc/write.hpp b/deps/ox/src/ox/oc/write.hpp index f7358c1c..b8ca98e9 100644 --- a/deps/ox/src/ox/oc/write.hpp +++ b/deps/ox/src/ox/oc/write.hpp @@ -138,7 +138,7 @@ class OrganicClawWriter { template Error field(char const*key, IString const*val) noexcept { - if (targetValid() && val->len()) { + if (targetValid() && val->size()) { value(key) = val->c_str(); } ++m_fieldIt; @@ -147,7 +147,7 @@ class OrganicClawWriter { template Error field(char const*key, BasicString const*val) noexcept { - if (targetValid() && val->len()) { + if (targetValid() && val->size()) { value(key) = val->c_str(); } ++m_fieldIt; diff --git a/deps/ox/src/ox/std/assert.cpp b/deps/ox/src/ox/std/assert.cpp index aacd0f72..53843519 100644 --- a/deps/ox/src/ox/std/assert.cpp +++ b/deps/ox/src/ox/std/assert.cpp @@ -33,6 +33,9 @@ void panic(StringViewCR file, int const line, StringViewCR panicMsg, Error const #endif } +#if __GNUC__ +__attribute__((weak)) +#endif void panic(const char *file, int const line, char const*panicMsg, Error const&err) noexcept { panic(StringView{file}, line, StringView{panicMsg}, err); } diff --git a/deps/ox/src/ox/std/basestringview.hpp b/deps/ox/src/ox/std/basestringview.hpp index 3d50cc91..92b68a7b 100644 --- a/deps/ox/src/ox/std/basestringview.hpp +++ b/deps/ox/src/ox/std/basestringview.hpp @@ -185,7 +185,7 @@ class BaseStringView { } [[nodiscard]] - constexpr auto len() const noexcept { + constexpr auto size() const noexcept { return m_len; } diff --git a/deps/ox/src/ox/std/cstringview.hpp b/deps/ox/src/ox/std/cstringview.hpp index d356f2b1..f37c23a7 100644 --- a/deps/ox/src/ox/std/cstringview.hpp +++ b/deps/ox/src/ox/std/cstringview.hpp @@ -21,13 +21,13 @@ class CStringView: public detail::BaseStringView { constexpr CStringView(CStringView const&sv) noexcept = default; - constexpr CStringView(StringLiteral const&str) noexcept: BaseStringView(str.data(), str.len()) {} + constexpr CStringView(StringLiteral const&str) noexcept: BaseStringView(str.data(), str.size()) {} template - constexpr CStringView(BasicString const&str) noexcept: BaseStringView(str.data(), str.len()) {} + constexpr CStringView(BasicString const&str) noexcept: BaseStringView(str.data(), str.size()) {} template - constexpr CStringView(IString const&str) noexcept: BaseStringView(str.data(), str.len()) {} + constexpr CStringView(IString const&str) noexcept: BaseStringView(str.data(), str.size()) {} constexpr CStringView(std::nullptr_t) noexcept {} @@ -37,7 +37,7 @@ class CStringView: public detail::BaseStringView { constexpr auto &operator=(CStringView const&other) noexcept { if (&other != this) { - set(other.data(), other.len()); + set(other.data(), other.size()); } return *this; } diff --git a/deps/ox/src/ox/std/istring.hpp b/deps/ox/src/ox/std/istring.hpp index 3ba1c9b0..a21a586c 100644 --- a/deps/ox/src/ox/std/istring.hpp +++ b/deps/ox/src/ox/std/istring.hpp @@ -72,7 +72,7 @@ class IString { * Returns the number of characters in this string. */ [[nodiscard]] - constexpr std::size_t len() const noexcept; + constexpr std::size_t size() const noexcept; /** * Returns the number of bytes used for this string. @@ -121,7 +121,7 @@ constexpr IString &IString::operator=(Integer_c auto i) noexcept { template constexpr IString &IString::operator=(ox::StringViewCR str) noexcept { - std::size_t strLen = str.len(); + std::size_t strLen = str.size(); if (cap() < strLen) { strLen = cap(); } @@ -171,7 +171,7 @@ constexpr char &IString::operator[](std::size_t i) noexcept { template constexpr Error IString::append(const char *str, std::size_t strLen) noexcept { Error err{}; - auto const currentLen = len(); + auto const currentLen = size(); if (cap() < currentLen + strLen) { strLen = cap() - currentLen; err = ox::Error(1, "Insufficient space for full string"); @@ -187,7 +187,7 @@ OX_CLANG_NOWARN_END template constexpr Error IString::append(ox::StringView str) noexcept { - return append(str.data(), str.len()); + return append(str.data(), str.size()); } template @@ -207,7 +207,7 @@ constexpr const char *IString::c_str() const noexcept { template -constexpr std::size_t IString::len() const noexcept { +constexpr std::size_t IString::size() const noexcept { return m_size; } diff --git a/deps/ox/src/ox/std/reader.cpp b/deps/ox/src/ox/std/reader.cpp index b29c4b5e..13acc66a 100644 --- a/deps/ox/src/ox/std/reader.cpp +++ b/deps/ox/src/ox/std/reader.cpp @@ -30,13 +30,15 @@ constexpr std::ios_base::seekdir sdMap(ox::ios_base::seekdir in) noexcept { ox::Result StreamReader::peek() const noexcept { try { + if (m_strm.eof()) { + return Error{1, "EOF"}; + } char c{}; m_strm.get(c); - auto const ok = c != EOF; - if (ok && m_strm.unget()) [[unlikely]] { - return ox::Error(1, "Unable to unget character"); + if (m_strm.unget()) [[unlikely]] { + return ox::Error{1, "Unable to unget character"}; } - return {static_cast(c), ox::Error(!ok, "File peek failed")}; + return static_cast(c); } catch (std::exception const&) { return ox::Error(1, "peek failed"); } diff --git a/deps/ox/src/ox/std/string.hpp b/deps/ox/src/ox/std/string.hpp index 615e6219..8a1cb7d0 100644 --- a/deps/ox/src/ox/std/string.hpp +++ b/deps/ox/src/ox/std/string.hpp @@ -176,7 +176,7 @@ class BasicString { constexpr char &operator[](std::size_t i) noexcept; constexpr Error append(const char *str, std::size_t strLen) noexcept { - auto currentLen = len(); + auto currentLen = size(); m_buff.resize(m_buff.size() + strLen); ox::listcpy(&m_buff[currentLen], str, strLen); // make sure last element is a null terminator @@ -186,7 +186,7 @@ class BasicString { } constexpr Error append(ox::StringView sv) noexcept { - return append(sv.data(), sv.len()); + return append(sv.data(), sv.size()); } [[nodiscard]] @@ -237,7 +237,7 @@ class BasicString { * Returns the number of characters in this string. */ [[nodiscard]] - constexpr std::size_t len() const noexcept; + constexpr std::size_t size() const noexcept; /** * Returns the number of bytes used for this string. @@ -277,7 +277,7 @@ constexpr BasicString::BasicString(const char *str, std::size template constexpr BasicString::BasicString(StringLiteral const&str) noexcept: - BasicString(StringView{str.data(), str.len()}) { + BasicString(StringView{str.data(), str.size()}) { } template @@ -384,14 +384,14 @@ constexpr BasicString &BasicString::operat template constexpr BasicString &BasicString::operator+=(BasicString const&src) noexcept { - std::ignore = append(src.c_str(), src.len()); + std::ignore = append(src.c_str(), src.size()); return *this; } template constexpr BasicString BasicString::operator+(const char *str) const noexcept { const std::size_t strLen = ox::strlen(str); - const auto currentLen = len(); + const auto currentLen = size(); BasicString cpy; cpy.m_buff.resize(m_buff.size() + strLen); ox::listcpy(&cpy.m_buff[0], m_buff.data(), currentLen); @@ -420,8 +420,8 @@ constexpr BasicString BasicString::operato template constexpr BasicString BasicString::operator+(StringViewCR src) const noexcept { - const std::size_t strLen = src.len(); - const auto currentLen = len(); + const std::size_t strLen = src.size(); + const auto currentLen = size(); BasicString cpy(currentLen + strLen); cpy.m_buff.resize(m_buff.size() + strLen); ox::listcpy(&cpy.m_buff[0], m_buff.data(), currentLen); @@ -432,8 +432,8 @@ constexpr BasicString BasicString::operato template constexpr BasicString BasicString::operator+(BasicString const&src) const noexcept { - const std::size_t strLen = src.len(); - const auto currentLen = len(); + const std::size_t strLen = src.size(); + const auto currentLen = size(); BasicString cpy(currentLen + strLen); cpy.m_buff.resize(m_buff.size() + strLen); ox::listcpy(&cpy.m_buff[0], m_buff.data(), currentLen); @@ -521,7 +521,7 @@ constexpr std::size_t BasicString::bytes() const noexcept { } template -constexpr std::size_t BasicString::len() const noexcept { +constexpr std::size_t BasicString::size() const noexcept { return m_buff.size() - 1; } diff --git a/deps/ox/src/ox/std/stringliteral.hpp b/deps/ox/src/ox/std/stringliteral.hpp index ec5d4631..f78b9462 100644 --- a/deps/ox/src/ox/std/stringliteral.hpp +++ b/deps/ox/src/ox/std/stringliteral.hpp @@ -32,7 +32,7 @@ class StringLiteral: public detail::BaseStringView { OX_ALLOW_UNSAFE_BUFFERS_END constexpr StringLiteral &operator=(StringLiteral const &other) noexcept { - set(other.data(), other.len()); + set(other.data(), other.size()); return *this; } diff --git a/deps/ox/src/ox/std/stringview.hpp b/deps/ox/src/ox/std/stringview.hpp index 6fc955c6..0b8b24cb 100644 --- a/deps/ox/src/ox/std/stringview.hpp +++ b/deps/ox/src/ox/std/stringview.hpp @@ -40,10 +40,10 @@ class StringView: public detail::BaseStringView { constexpr StringView(BaseStringView const&str) noexcept: BaseStringView(str.data(), str.bytes()) {} template - constexpr StringView(const BasicString &str) noexcept: BaseStringView(str.data(), str.len()) {} + constexpr StringView(const BasicString &str) noexcept: BaseStringView(str.data(), str.size()) {} template - constexpr StringView(const IString &str) noexcept: BaseStringView(str.data(), str.len()) {} + constexpr StringView(const IString &str) noexcept: BaseStringView(str.data(), str.size()) {} constexpr StringView(std::nullptr_t) noexcept {} @@ -53,7 +53,7 @@ class StringView: public detail::BaseStringView { constexpr auto &operator=(StringView const&other) noexcept { if (&other != this) { - set(other.data(), other.len()); + set(other.data(), other.size()); } return *this; } @@ -63,14 +63,14 @@ class StringView: public detail::BaseStringView { using StringViewCR = StringView const&; constexpr auto operator==(StringViewCR s1, StringViewCR s2) noexcept { - if (s2.len() != s1.len()) { + if (s2.size() != s1.size()) { return false; } - return ox::strncmp(s1.data(), s2.data(), s1.len()) == 0; + return ox::strncmp(s1.data(), s2.data(), s1.size()) == 0; } constexpr auto operator<=>(StringViewCR s1, StringViewCR s2) noexcept { - const auto maxLen = ox::min(s1.len(), s2.len()); + const auto maxLen = ox::min(s1.size(), s2.size()); const auto a = &s1.front(); const auto b = &s2.front(); for (std::size_t i = 0; i < maxLen && (a[i] || b[i]); ++i) { @@ -80,9 +80,9 @@ constexpr auto operator<=>(StringViewCR s1, StringViewCR s2) noexcept { return 1; } } - if (s1.len() > s2.len()) { + if (s1.size() > s2.size()) { return 1; - } else if (s1.len() < s2.len()) { + } else if (s1.size() < s2.size()) { return -1; } else { return 0; @@ -104,10 +104,10 @@ constexpr ox::Result strToInt(StringViewCR str) noexcept { OX_ALLOW_UNSAFE_BUFFERS_BEGIN int total = 0; int multiplier = 1; - if (str.len() == 0) [[unlikely]] { + if (str.size() == 0) [[unlikely]] { return Error{1, "Empty string passed to strToInt"}; } - for (auto i = static_cast(str.len()) - 1; i != -1; --i) { + for (auto i = static_cast(str.size()) - 1; i != -1; --i) { auto s = static_cast(i); if (str[s] >= '0' && str[s] <= '9') { total += (str[s] - '0') * multiplier; diff --git a/deps/ox/src/ox/std/strops.hpp b/deps/ox/src/ox/std/strops.hpp index db85d4c8..b2f3ec99 100644 --- a/deps/ox/src/ox/std/strops.hpp +++ b/deps/ox/src/ox/std/strops.hpp @@ -22,15 +22,15 @@ namespace ox { [[nodiscard]] constexpr ox::StringView substr(ox::StringView const&str, std::size_t pos) noexcept { - if (str.len() >= pos) { - return {&str[pos], str.len() - pos}; + if (str.size() >= pos) { + return {&str[pos], str.size() - pos}; } return {}; } [[nodiscard]] constexpr ox::StringView substr(ox::StringView const&str, std::size_t start, std::size_t end) noexcept { - if (str.len() >= start && end >= start) { + if (str.size() >= start && end >= start) { return {&str[start], end - start}; } return {}; @@ -38,20 +38,20 @@ constexpr ox::StringView substr(ox::StringView const&str, std::size_t start, std [[nodiscard]] constexpr bool beginsWith(StringViewCR base, StringViewCR beginning) noexcept { - const auto beginningLen = ox::min(beginning.len(), base.len()); - return base.len() >= beginning.len() && ox::strncmp(base.data(), beginning, beginningLen) == 0; + const auto beginningLen = ox::min(beginning.size(), base.size()); + return base.size() >= beginning.size() && ox::strncmp(base.data(), beginning, beginningLen) == 0; } [[nodiscard]] constexpr bool endsWith(StringViewCR base, StringViewCR ending) noexcept { - const auto endingLen = ending.len(); - return base.len() >= endingLen && ox::strcmp(base.data() + (base.len() - endingLen), ending) == 0; + const auto endingLen = ending.size(); + return base.size() >= endingLen && ox::strcmp(base.data() + (base.size() - endingLen), ending) == 0; } [[nodiscard]] constexpr std::size_t find(StringViewCR str, char search) noexcept { std::size_t i = 0; - for (; i < str.len(); ++i) { + for (; i < str.size(); ++i) { if (str[i] == search) { break; } @@ -62,7 +62,7 @@ constexpr std::size_t find(StringViewCR str, char search) noexcept { [[nodiscard]] constexpr std::size_t find(StringViewCR str, StringViewCR search) noexcept { std::size_t i = 0; - for (; i < str.len(); ++i) { + for (; i < str.size(); ++i) { if (beginsWith(substr(str, i), search)) { break; } @@ -77,9 +77,9 @@ constexpr ox::Vector split(StringViewCR str, char del) constexpr auto nextSeg = [](StringViewCR current, char del) { return substr(current, find(current, del) + 1); }; - for (auto current = str; current.len(); current = nextSeg(current, del)) { + for (auto current = str; current.size(); current = nextSeg(current, del)) { const auto next = find(current, del); - if (const auto s = substr(current, 0, next); s.len()) { + if (const auto s = substr(current, 0, next); s.size()) { out.emplace_back(s); } current = substr(current, next); @@ -92,11 +92,11 @@ template constexpr ox::Vector split(StringViewCR str, StringViewCR del) noexcept { ox::Vector out; constexpr auto nextSeg = [](StringViewCR current, StringViewCR del) { - return substr(current, find(current, del) + del.len()); + return substr(current, find(current, del) + del.size()); }; - for (auto current = str; current.len(); current = nextSeg(current, del)) { + for (auto current = str; current.size(); current = nextSeg(current, del)) { const auto next = find(current, del); - if (const auto s = substr(current, 0, next); s.len()) { + if (const auto s = substr(current, 0, next); s.size()) { out.emplace_back(s); } current = substr(current, next); diff --git a/deps/ox/src/ox/std/test/tests.cpp b/deps/ox/src/ox/std/test/tests.cpp index 77071999..b44c6b7f 100644 --- a/deps/ox/src/ox/std/test/tests.cpp +++ b/deps/ox/src/ox/std/test/tests.cpp @@ -183,7 +183,7 @@ OX_CLANG_NOWARN_END s = "asdf"; oxAssert(s == "asdf", "String assign broken"); oxAssert(s != "aoeu", "String assign broken"); - oxAssert(s.len() == 4, "String assign broken"); + oxAssert(s.size() == 4, "String assign broken"); return ox::Error(0); } }, diff --git a/deps/ox/src/ox/std/trace.hpp b/deps/ox/src/ox/std/trace.hpp index c33cf821..7dbaaea1 100644 --- a/deps/ox/src/ox/std/trace.hpp +++ b/deps/ox/src/ox/std/trace.hpp @@ -166,7 +166,7 @@ class OutStream { constexpr OutStream &operator<<(Integer_c auto v) noexcept; constexpr OutStream &operator<<(char v) noexcept { - if (m_msg.msg.len()) { + if (m_msg.msg.size()) { m_msg.msg += m_delimiter; } m_msg.msg += v; @@ -174,7 +174,7 @@ class OutStream { } constexpr OutStream &operator<<(StringViewCR v) noexcept { - if (m_msg.msg.len()) { + if (m_msg.msg.size()) { m_msg.msg += m_delimiter; } m_msg.msg += v; @@ -209,7 +209,7 @@ class OutStream { private: constexpr OutStream &appendSignedInt(int64_t v) noexcept { - if (m_msg.msg.len()) { + if (m_msg.msg.size()) { m_msg.msg += m_delimiter; } m_msg.msg += static_cast(v); @@ -217,7 +217,7 @@ class OutStream { } constexpr OutStream &appendUnsignedInt(uint64_t v) noexcept { - if (m_msg.msg.len()) { + if (m_msg.msg.size()) { m_msg.msg += m_delimiter; } m_msg.msg += static_cast(v); @@ -227,7 +227,7 @@ class OutStream { }; constexpr OutStream &OutStream::operator<<(Integer_c auto v) noexcept { - if (m_msg.msg.len()) { + if (m_msg.msg.size()) { m_msg.msg += m_delimiter; } m_msg.msg += v; diff --git a/deps/ox/src/ox/std/uuid.hpp b/deps/ox/src/ox/std/uuid.hpp index 76bd1365..325cf0c9 100644 --- a/deps/ox/src/ox/std/uuid.hpp +++ b/deps/ox/src/ox/std/uuid.hpp @@ -58,7 +58,7 @@ constexpr ox::Result fromHex(ox::StringViewCR v) noexcept { if (!detail::isHexChar(v[0]) || !detail::isHexChar(v[1])) { return ox::Error(1, "Invalid UUID"); } - if (v.len() != 2) { + if (v.size() != 2) { return ox::Error(2); } uint8_t out = 0; @@ -133,18 +133,18 @@ class UUID { } static constexpr ox::Result fromString(ox::StringViewCR s) noexcept { - if (s.len() < 36) { + if (s.size() < 36) { return ox::Error(1, "Insufficient data to contain a complete UUID"); } UUID out; auto valueI = 0u; - for (size_t i = 0; i < s.len();) { + for (size_t i = 0; i < s.size();) { if (s[i] == '-') { ++i; continue; } const auto seg = substr(s, i, i + 2); - if (seg.len() != 2) { + if (seg.size() != 2) { return ox::Error(1, "Invalid UUID"); } OX_REQUIRE(val, detail::fromHex(seg)); @@ -174,7 +174,7 @@ class UUID { for (auto i = 0u; i < cnt; ++i) { const auto v = value[valueI]; const auto h = detail::toHex(v); - std::ignore = writer.write(h.c_str(), h.len()); + std::ignore = writer.write(h.c_str(), h.size()); ++valueI; } };