summaryrefslogtreecommitdiff
path: root/include/fud_string.hpp
diff options
context:
space:
mode:
authorDominick Allen <djallen@librehumanitas.org>2024-09-25 11:25:25 -0500
committerDominick Allen <djallen@librehumanitas.org>2024-09-25 11:25:25 -0500
commit255fa256b106506e0c951f704314c5c633217468 (patch)
treeacda2292f4ef315a64de763d4ee8e9a82f587a8c /include/fud_string.hpp
parent204dad55119df079ca54309bc4b740280fa54c31 (diff)
Further expansion of string api.
Diffstat (limited to 'include/fud_string.hpp')
-rw-r--r--include/fud_string.hpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/include/fud_string.hpp b/include/fud_string.hpp
index 5229f26..f7e4813 100644
--- a/include/fud_string.hpp
+++ b/include/fud_string.hpp
@@ -47,6 +47,11 @@ class String {
return m_length;
}
+ [[nodiscard]] constexpr bool empty() const
+ {
+ return m_length == 0;
+ }
+
[[nodiscard]] constexpr size_t size() const
{
return m_length + 1;
@@ -89,6 +94,8 @@ class String {
[[nodiscard]] FudStatus nullTerminate();
+ [[nodiscard]] std::optional<utf8> back();
+
[[nodiscard]] constexpr size_t remainingLength() const
{
if (m_length >= m_capacity) {
@@ -136,7 +143,7 @@ class StringView {
}
StringView(size_t strLen, const char* strData) :
- m_length(strLen), // line break
+ m_length(strLen), // line break
m_data{reinterpret_cast<const utf8*>(strData)} // NOLINT(cppcoreguidelines-pro-type-reinterpret-cast)
{
}