aboutsummaryrefslogtreecommitdiff
path: root/include/cru/base
diff options
context:
space:
mode:
authorYuqian Yang <crupest@crupest.life>2025-10-17 12:06:14 +0800
committerYuqian Yang <crupest@crupest.life>2025-10-17 12:06:14 +0800
commit32aa6f116acc6e3e20a1ec76cef45b29f7005ad7 (patch)
tree892b71060a88b58d9293d78033000b05818783df /include/cru/base
parentfaf77949e19dc0d01f75bf8abb783eda70328048 (diff)
downloadcru-32aa6f116acc6e3e20a1ec76cef45b29f7005ad7.tar.gz
cru-32aa6f116acc6e3e20a1ec76cef45b29f7005ad7.tar.bz2
cru-32aa6f116acc6e3e20a1ec76cef45b29f7005ad7.zip
Remove String stage 1.
Diffstat (limited to 'include/cru/base')
-rw-r--r--include/cru/base/StringUtil.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/include/cru/base/StringUtil.h b/include/cru/base/StringUtil.h
index 0ce3802f..2b1b5914 100644
--- a/include/cru/base/StringUtil.h
+++ b/include/cru/base/StringUtil.h
@@ -269,4 +269,28 @@ Utf8CodePointIterator CRU_BASE_API CreateUtf8Iterator(const std::byte* buffer,
Utf8CodePointIterator CRU_BASE_API
CreateUtf8Iterator(const std::vector<std::byte>& buffer);
+CodePoint CRU_BASE_API Utf8NextCodePoint(std::string_view str, Index current,
+ Index* next_position);
+CodePoint CRU_BASE_API Utf8PreviousCodePoint(std::string_view str,
+ Index current,
+ Index* next_position);
+// Return position after the character making predicate returns true or 0 if no
+// character doing so.
+Index CRU_BASE_API
+Utf8BackwardUntil(std::string_view str, Index position,
+ const std::function<bool(CodePoint)>& predicate);
+// Return position before the character making predicate returns true or
+// str.size() if no character doing so.
+Index CRU_BASE_API
+Utf8ForwardUntil(std::string_view str, Index position,
+ const std::function<bool(CodePoint)>& predicate);
+
+bool CRU_BASE_API Utf8IsValidInsertPosition(std::string_view str,
+ Index position);
+
+Index CRU_BASE_API Utf8PreviousWord(std::string_view str, Index position,
+ bool* is_space = nullptr);
+Index CRU_BASE_API Utf8NextWord(std::string_view str, Index position,
+ bool* is_space = nullptr);
+
} // namespace cru