diff options
author | crupest <crupest@outlook.com> | 2021-11-14 22:27:08 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2021-11-14 22:27:08 +0800 |
commit | a744ed1fea0eaf4d946909da7fdc0a4c0f9c5ec0 (patch) | |
tree | 7f22783f8e0c7f61362ef64e879b50729536fea3 /include/cru/common/String.hpp | |
parent | 7045737332f742cec36c3d35f48fad82cd41a04b (diff) | |
download | cru-a744ed1fea0eaf4d946909da7fdc0a4c0f9c5ec0.tar.gz cru-a744ed1fea0eaf4d946909da7fdc0a4c0f9c5ec0.tar.bz2 cru-a744ed1fea0eaf4d946909da7fdc0a4c0f9c5ec0.zip |
...
Diffstat (limited to 'include/cru/common/String.hpp')
-rw-r--r-- | include/cru/common/String.hpp | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/include/cru/common/String.hpp b/include/cru/common/String.hpp index 544d24a4..0a8d88a0 100644 --- a/include/cru/common/String.hpp +++ b/include/cru/common/String.hpp @@ -174,8 +174,7 @@ class CRU_BASE_API String { void AppendCodePoint(CodePoint code_point); Utf16CodePointIterator CodePointIterator() const { - return Utf16CodePointIterator( - std::u16string_view(reinterpret_cast<char16_t*>(buffer_), size_)); + return Utf16CodePointIterator(buffer_, size_); } Index IndexFromCodeUnitToCodePoint(Index code_unit_index) const; @@ -378,6 +377,31 @@ inline void String::append(StringView str) { inline String String::From(StringView str) { return str.ToString(); } inline String ToString(StringView value) { return value.ToString(); } + +inline CodePoint Utf16PreviousCodePoint(StringView str, Index current, + Index* previous_position) { + return Utf16PreviousCodePoint(str.data(), str.size(), current, + previous_position); +} + +inline CodePoint Utf16NextCodePoint(StringView str, Index current, + Index* next_position) { + return Utf16NextCodePoint(str.data(), str.size(), current, next_position); +} + +inline bool Utf16IsValidInsertPosition(StringView str, Index position) { + return Utf16IsValidInsertPosition(str.data(), str.size(), position); +} + +inline Index Utf16PreviousWord(StringView str, Index position, + bool* is_space = nullptr) { + return Utf16PreviousWord(str.data(), str.size(), position, is_space); +} + +inline Index Utf16NextWord(StringView str, Index position, + bool* is_space = nullptr) { + return Utf16NextWord(str.data(), str.size(), position, is_space); +} } // namespace cru template <> |