diff options
Diffstat (limited to 'source/fud_string_view.cpp')
-rw-r--r-- | source/fud_string_view.cpp | 38 |
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) |