summaryrefslogtreecommitdiff
path: root/source/fud_string.cpp
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 /source/fud_string.cpp
parent204dad55119df079ca54309bc4b740280fa54c31 (diff)
Further expansion of string api.
Diffstat (limited to 'source/fud_string.cpp')
-rw-r--r--source/fud_string.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/source/fud_string.cpp b/source/fud_string.cpp
index 27496ff..57bf1e0 100644
--- a/source/fud_string.cpp
+++ b/source/fud_string.cpp
@@ -157,6 +157,20 @@ FudStatus String::nullTerminate()
return FudStatus::StringInvalid;
}
+[[nodiscard]] std::optional<utf8> String::back()
+{
+ if (!valid()) {
+ return std::nullopt;
+ }
+
+ utf8 backChar = data()[m_length - 1];
+ if (Ascii::valid(backChar)) {
+ return backChar;
+ }
+
+ return std::nullopt;
+}
+
std::optional<utf8> String::pop()
{
if (m_length < 1) {