From 6a27a2a4032e88fa9154ef0f0741edc584f7a701 Mon Sep 17 00:00:00 2001 From: Dominick Allen Date: Sun, 20 Oct 2024 10:48:19 -0500 Subject: Lots of work. --- source/fud_string_view.cpp | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) (limited to 'source/fud_string_view.cpp') 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 StringView::skipWhitespace() return RetType::error(FudStatus::NullPointer); } size_t index = 0; - while (m_length > 0 && char_is_space(static_cast(m_data[0]))) { + while (m_length > 0 && charIsSpace(static_cast(m_data[0]))) { m_data++; m_length--; index++; @@ -78,7 +78,7 @@ Result StringView::trimWhitespace() } size_t count = 0; - while (m_length > 0 && char_is_space(static_cast(m_data[m_length - 1]))) { + while (m_length > 0 && charIsSpace(static_cast(m_data[m_length - 1]))) { m_length--; count++; } @@ -86,6 +86,40 @@ Result 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) -- cgit v1.2.3