Public Member Functions | Private Attributes

IcuStringIterator Class Reference

String iterator using ICU as a backend. More...

Inheritance diagram for IcuStringIterator:
StringIterator

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.
const char * string
 Iteration string in UTF-8.
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.

Detailed Description

String iterator using ICU as a backend.

Definition at line 661 of file string.cpp.


Member Function Documentation

virtual size_t IcuStringIterator::Next ( IterType  what  )  [inline, virtual]

Advance the cursor by one iteration unit.

Returns:
New cursor position (in bytes) or END if the cursor is already at the end of the string.

Implements StringIterator.

Definition at line 742 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.

virtual size_t IcuStringIterator::Prev ( IterType  what  )  [inline, virtual]

Move the cursor back by one iteration unit.

Returns:
New cursor position (in bytes) or END if the cursor is already at the start of the string.

Implements StringIterator.

Definition at line 774 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.

virtual size_t IcuStringIterator::SetCurPosition ( size_t  pos  )  [inline, virtual]

Change the current string cursor.

Parameters:
p New cursor position.
Returns:
Actual new cursor position at the next valid character boundary.
Precondition:
p has to be inside the current string.

Implements StringIterator.

Definition at line 724 of file string.cpp.

References char_itr, SmallVector< T, S >::Length(), and utf16_to_utf8.

virtual void IcuStringIterator::SetString ( const char *  s  )  [inline, virtual]

Set a new iteration string.

Must also be called if the string contents changed. The cursor is reset to the start of the string.

Parameters:
s New string.

Implements StringIterator.

Definition at line 687 of file string.cpp.

References SmallVector< T, S >::Append(), SmallVector< T, S >::Begin(), char_itr, SmallVector< T, S >::Clear(), SmallVector< T, S >::Length(), string, utf16_str, utf16_to_utf8, and word_itr.


The documentation for this class was generated from the following file: