aboutsummaryrefslogtreecommitdiff
path: root/include/cru/common
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2021-11-15 16:26:25 +0800
committercrupest <crupest@outlook.com>2021-11-15 16:26:25 +0800
commit4ac58d91bac0cebe2bdf5e11b9d63b9c41e6b39e (patch)
tree7a4a8f587ffadb9f722b33badf2568e1d325b818 /include/cru/common
parent63b4956c3a802ee1c0fd92d1ce56e9330b6de4d2 (diff)
downloadcru-4ac58d91bac0cebe2bdf5e11b9d63b9c41e6b39e.tar.gz
cru-4ac58d91bac0cebe2bdf5e11b9d63b9c41e6b39e.tar.bz2
cru-4ac58d91bac0cebe2bdf5e11b9d63b9c41e6b39e.zip
...
Diffstat (limited to 'include/cru/common')
-rw-r--r--include/cru/common/String.hpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/include/cru/common/String.hpp b/include/cru/common/String.hpp
index 9996f617..264a44ff 100644
--- a/include/cru/common/String.hpp
+++ b/include/cru/common/String.hpp
@@ -395,6 +395,21 @@ inline bool Utf16IsValidInsertPosition(StringView str, Index position) {
return Utf16IsValidInsertPosition(str.data(), str.size(), position);
}
+// Return position after the character making predicate returns true or 0 if no
+// character doing so.
+inline Index CRU_BASE_API
+Utf16BackwardUntil(StringView str, Index position,
+ const std::function<bool(CodePoint)>& predicate) {
+ return Utf16BackwardUntil(str.data(), str.size(), position, predicate);
+}
+// Return position before the character making predicate returns true or
+// str.size() if no character doing so.
+inline Index CRU_BASE_API
+Utf16ForwardUntil(StringView str, Index position,
+ const std::function<bool(CodePoint)>& predicate) {
+ return Utf16ForwardUntil(str.data(), str.size(), position, predicate);
+}
+
inline Index Utf16PreviousWord(StringView str, Index position,
bool* is_space = nullptr) {
return Utf16PreviousWord(str.data(), str.size(), position, is_space);