OpenTTD
|
String iterator using ICU as a backend. More...
Public Member Functions | |
virtual void | SetString (const char *s) |
Set a new iteration string. | |
virtual size_t | SetCurPosition (size_t pos) |
Change the current string cursor. | |
virtual size_t | Next (IterType what) |
Advance the cursor by one iteration unit. | |
virtual size_t | Prev (IterType what) |
Move the cursor back by one iteration unit. |
Private Attributes | |
icu::BreakIterator * | char_itr |
ICU iterator for characters. | |
icu::BreakIterator * | word_itr |
ICU iterator for words. | |
SmallVector< UChar, 32 > | utf16_str |
UTF-16 copy of the string. | |
SmallVector< size_t, 32 > | utf16_to_utf8 |
Mapping from UTF-16 code point position to index in the UTF-8 source string. |
Additional Inherited Members | |
![]() | |
enum | IterType { ITER_CHARACTER, ITER_WORD } |
Type of the iterator. More... | |
![]() | |
static StringIterator * | Create () |
Create a new iterator instance. | |
![]() | |
static const size_t | END = SIZE_MAX |
Sentinel to indicate end-of-iteration. |
String iterator using ICU as a backend.
Definition at line 594 of file string.cpp.
|
inlinevirtual |
Advance the cursor by one iteration unit.
Implements StringIterator.
Definition at line 674 of file string.cpp.
References char_itr, StringIterator::END, IsWhitespace(), StringIterator::ITER_CHARACTER, StringIterator::ITER_WORD, utf16_str, utf16_to_utf8, Utf16DecodeChar(), and word_itr.
|
inlinevirtual |
Move the cursor back by one iteration unit.
Implements StringIterator.
Definition at line 706 of file string.cpp.
References char_itr, StringIterator::END, IsWhitespace(), StringIterator::ITER_CHARACTER, StringIterator::ITER_WORD, utf16_str, utf16_to_utf8, Utf16DecodeChar(), and word_itr.
|
inlinevirtual |
Change the current string cursor.
p | New cursor position. |
Implements StringIterator.
Definition at line 656 of file string.cpp.
References char_itr, SmallVector< T, S >::Length(), and utf16_to_utf8.
|
inlinevirtual |
Set a new iteration string.
Must also be called if the string contents changed. The cursor is reset to the start of the string.
s | New string. |
Implements StringIterator.
Definition at line 619 of file string.cpp.
References SmallVector< T, S >::Append(), SmallVector< T, S >::Begin(), char_itr, SmallVector< T, S >::Clear(), SmallVector< T, S >::Length(), utf16_str, utf16_to_utf8, and word_itr.