summaryrefslogtreecommitdiff
path: root/source/fud_string_view.cpp
diff options
context:
space:
mode:
authorDominick Allen <djallen@librehumanitas.org>2024-10-20 10:48:19 -0500
committerDominick Allen <djallen@librehumanitas.org>2024-10-20 10:48:19 -0500
commit6a27a2a4032e88fa9154ef0f0741edc584f7a701 (patch)
tree92ca58cbcdd2c1d11b7d69deb0d4925d0f979a3f /source/fud_string_view.cpp
parente94db4695e236b42ae1be44b2605075161d5144f (diff)
Lots of work.
Diffstat (limited to 'source/fud_string_view.cpp')
-rw-r--r--source/fud_string_view.cpp38
1 files changed, 36 insertions, 2 deletions
diff --git a/source/fud_string_view.cpp b/source/fud_string_view.cpp
index 23a4671..fdb63b3 100644
--- a/source/fud_string_view.cpp
+++ b/source/fud_string_view.cpp
@@ -61,7 +61,7 @@ Result<size_t, FudStatus> StringView::skipWhitespace()
return RetType::error(FudStatus::NullPointer);
}
size_t index = 0;
- while (m_length > 0 && char_is_space(static_cast<char>(m_data[0]))) {
+ while (m_length > 0 && charIsSpace(static_cast<char>(m_data[0]))) {
m_data++;
m_length--;
index++;
@@ -78,7 +78,7 @@ Result<size_t, FudStatus> StringView::trimWhitespace()
}
size_t count = 0;
- while (m_length > 0 && char_is_space(static_cast<char>(m_data[m_length - 1]))) {
+ while (m_length > 0 && charIsSpace(static_cast<char>(m_data[m_length - 1]))) {
m_length--;
count++;
}
@@ -86,6 +86,40 @@ Result<size_t, FudStatus> StringView::trimWhitespace()
return RetType::okay(count);
}
+bool StringView::advance()
+{
+ if (m_length < 1) {
+ return false;
+ }
+ m_length--;
+ m_data++;
+ return true;
+}
+
+void StringView::advanceUnsafe()
+{
+ fudAssert(m_length > 0);
+ m_length--;
+ m_data++;
+}
+
+bool StringView::advance(size_t size)
+{
+ if (size > m_length) {
+ return false;
+ }
+ m_length -= size;
+ m_data += size;
+ return true;
+}
+
+void StringView::advanceUnsafe(size_t size)
+{
+ fudAssert(size <= m_length);
+ m_length -= size;
+ m_data += size;
+}
+
#if 0
FudStatus fud_string_truncate(ExtBasicString* source, ssize_t newLength)