summaryrefslogtreecommitdiff
path: root/include/fud_string.hpp
diff options
context:
space:
mode:
authorDominick Allen <djallen@librehumanitas.org>2024-09-23 07:36:16 -0500
committerDominick Allen <djallen@librehumanitas.org>2024-09-23 07:36:16 -0500
commit0b860bb5dd6d2007db605291d239a6a9d41f57d1 (patch)
treefab140e03a3665236503d1405de9d33ba58ccc4a /include/fud_string.hpp
parent7da829d48f9059c83ab9cada2c850621e8bbd3f3 (diff)
Installable library.
Diffstat (limited to 'include/fud_string.hpp')
-rw-r--r--include/fud_string.hpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/include/fud_string.hpp b/include/fud_string.hpp
index 42009b4..5229f26 100644
--- a/include/fud_string.hpp
+++ b/include/fud_string.hpp
@@ -54,7 +54,7 @@ class String {
[[nodiscard]] constexpr size_t capacity() const
{
- return m_capacity;
+ return m_capacity - 1;
}
/** \brier The underlying data, guaranteed to have c string representation. */
@@ -87,7 +87,7 @@ class String {
[[nodiscard]] bool utf8Valid() const;
- [[nodiscard]] FudStatus nullTerminate() const;
+ [[nodiscard]] FudStatus nullTerminate();
[[nodiscard]] constexpr size_t remainingLength() const
{
@@ -117,11 +117,11 @@ class String {
utf8* m_data;
};
size_t m_length{0};
- size_t m_capacity{0};
+ size_t m_capacity{SSO_BUF_SIZE};
[[nodiscard]] constexpr bool isLarge() const
{
- return m_capacity > SSO_BUF_LENGTH;
+ return m_capacity > SSO_BUF_SIZE;
}
};
@@ -131,12 +131,12 @@ class StringView {
{
}
- constexpr StringView(size_t strLen, const utf8* strData) : m_length(0), m_data{strData}
+ constexpr StringView(size_t strLen, const utf8* strData) : m_length(strLen), m_data{strData}
{
}
StringView(size_t strLen, const char* strData) :
- m_length(0), // line break
+ m_length(strLen), // line break
m_data{reinterpret_cast<const utf8*>(strData)} // NOLINT(cppcoreguidelines-pro-type-reinterpret-cast)
{
}