summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominick Allen <djallen@librehumanitas.org>2024-09-25 11:41:50 -0500
committerDominick Allen <djallen@librehumanitas.org>2024-09-25 11:41:50 -0500
commitdbb305fa27baada32d29d6f8904bdc02ac494e13 (patch)
tree982997034ad234f4d4e669b849ab6fb2c280bb21
parent255fa256b106506e0c951f704314c5c633217468 (diff)
Add iterator to string api.
-rw-r--r--include/fud_string.hpp4
-rw-r--r--source/fud_string.cpp10
2 files changed, 14 insertions, 0 deletions
diff --git a/include/fud_string.hpp b/include/fud_string.hpp
index f7e4813..97b7036 100644
--- a/include/fud_string.hpp
+++ b/include/fud_string.hpp
@@ -117,6 +117,10 @@ class String {
[[nodiscard]] String append(const String& rhs) const;
+ const utf8* begin() const;
+
+ const utf8* end() const;
+
private:
using BufType = Array<utf8, SSO_BUF_SIZE>;
union {
diff --git a/source/fud_string.cpp b/source/fud_string.cpp
index 57bf1e0..74742e1 100644
--- a/source/fud_string.cpp
+++ b/source/fud_string.cpp
@@ -287,6 +287,16 @@ String String::append(const String& rhs) const
return output;
}
+const utf8* String::begin() const
+{
+ return data();
+}
+
+const utf8* String::end() const
+{
+ return data() + size();
+}
+
bool StringView::nullTerminated() const
{
return m_data != nullptr && m_data[m_length] == '\0';