diff --git a/deps/ox/src/ox/std/istring.hpp b/deps/ox/src/ox/std/istring.hpp index 5c97cf49..0e2f55de 100644 --- a/deps/ox/src/ox/std/istring.hpp +++ b/deps/ox/src/ox/std/istring.hpp @@ -8,6 +8,7 @@ #pragma once +#include "array.hpp" #include "ignore.hpp" #include "memops.hpp" #include "ox/std/error.hpp" @@ -20,7 +21,7 @@ namespace ox { template class IString { private: - char m_buff[StrCap + 1]; + ox::Array m_buff; size_t m_size{}; public: @@ -112,9 +113,9 @@ constexpr IString::IString(const char *str) noexcept: m_buff{{0}} { template constexpr IString &IString::operator=(Integer_c auto i) noexcept { - char str[65] = {}; - ox::itoa(i, str); - return this->operator=(str); + ox::Array str{}; + ox::itoa(i, str.data()); + return this->operator=(str.data()); } template @@ -124,7 +125,7 @@ constexpr IString &IString::operator=(ox::CRStringView str) noexcept strLen = cap(); } m_size = strLen; - ox::listcpy(m_buff, str.data(), strLen); + ox::listcpy(m_buff.data(), str.data(), strLen); // make sure last element is a null terminator m_buff[strLen] = 0; return *this; @@ -137,7 +138,7 @@ constexpr IString &IString::operator=(const char *str) noexcept { strLen = cap(); } m_size = strLen; - ox::listcpy(m_buff, str, strLen); + ox::listcpy(m_buff.data(), str, strLen); // make sure last element is a null terminator m_buff[cap()] = 0; return *this; @@ -162,9 +163,9 @@ constexpr IString &IString::operator+=(char *str) noexcept { template constexpr IString &IString::operator+=(Integer_c auto i) noexcept { - char str[65] = {}; - ox::itoa(i, str); - return this->operator+=(str); + ox::Array str{}; + ox::itoa(i, str.data()); + return this->operator+=(str.data()); } template @@ -189,9 +190,9 @@ constexpr IString IString::operator+(char *str) const noexcept { template constexpr IString IString::operator+(Integer_c auto i) const noexcept { - char str[65] = {}; - ox::itoa(i, str); - return this->operator+(str); + ox::Array str{}; + ox::itoa(i, str.data()); + return this->operator+(str.data()); } template @@ -232,7 +233,7 @@ constexpr Error IString::append(const char *str, std::size_t strLen) noe strLen = cap() - currentLen; err = OxError(1, "Insufficient space for full string"); } - ox::strncpy(m_buff + currentLen, str, strLen); + ox::strncpy(m_buff.data() + currentLen, str, strLen); // make sure last element is a null terminator m_buff[currentLen + strLen] = 0; return err; @@ -240,17 +241,17 @@ constexpr Error IString::append(const char *str, std::size_t strLen) noe template constexpr const char *IString::data() const noexcept { - return static_cast(m_buff); + return static_cast(m_buff.data()); } template constexpr char *IString::data() noexcept { - return static_cast(m_buff); + return static_cast(m_buff.data()); } template constexpr const char *IString::c_str() const noexcept { - return static_cast(m_buff); + return static_cast(m_buff.data()); } @@ -258,7 +259,7 @@ template constexpr std::size_t IString::len() const noexcept { std::size_t length = 0; for (std::size_t i = 0; i < StrCap; i++) { - uint8_t b = static_cast(m_buff[i]); + auto const b = static_cast(m_buff[i]); if (b) { const auto asciiChar = (b & 128) == 0; const auto utf8Char = (b & (256 << 6)) == (256 << 6);