diff options
Diffstat (limited to 'include/fud_string.hpp')
-rw-r--r-- | include/fud_string.hpp | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/include/fud_string.hpp b/include/fud_string.hpp index 59c434a..86261c4 100644 --- a/include/fud_string.hpp +++ b/include/fud_string.hpp @@ -251,6 +251,17 @@ class String { return SsoBufSize - 1U; } + /** \brief Returns the remaining capacity for characters excluding the null + * terminating byte. */ + [[nodiscard]] size_t remainingCapacity() const + { + if (length() > capacity()) { + return 0; + } + + return capacity() - length(); + } + /** \brief The underlying data, guaranteed to have c string representation. */ [[nodiscard]] const utf8* data() const { @@ -263,6 +274,11 @@ class String { return reinterpret_cast<const char*>(data()); } + [[nodiscard]] inline StringView asView() const + { + return StringView(*this); + } + /** \brief Indicates if the contents of the string form a valid sequence of * UTF8 code points. */ [[nodiscard]] bool utf8Valid() const; @@ -274,22 +290,6 @@ class String { * greater than zero. */ [[nodiscard]] Option<utf8> back(); - /** \brief Returns the remaining capacity for characters excluding the null - * terminating byte. */ - [[nodiscard]] size_t remainingLength() const - { - if (length() > capacity()) { - return 0; - } - - return capacity() - length(); - } - - [[nodiscard]] inline StringView asView() const - { - return StringView(*this); - } - FudStatus pushBack(char letter); FudStatus pushBack(utf8 letter); @@ -358,6 +358,8 @@ class String { FudStatus resize(size_t newCapacity); + FudStatus grow(); + /** \brief The allocator used to get storage for characters when the string * is large. */ uintptr_t m_allocator{reinterpret_cast<uintptr_t>(&globalFudAllocator)}; |