Abstract class defining a protcol for accessing characters in a text-storage object
Abstract class defining a protcol for accessing characters in a text-storage object.Examples:
Function processing characters, in this example simple output
. void processChar( UChar c ) . { . cout << " " << c; . }Traverse the text from start to finish. void traverseForward(CharacterIterator& iter) . { . for(UChar c = iter.first(); c != CharacterIterator.DONE; c = iter.next()) { . processChar(c); . } . }Traverse the text backwards, from end to start. void traverseBackward(CharacterIterator& iter) . { . for(UChar c = iter.last(); c != CharacterIterator.DONE; c = iter.previous()) { . processChar(c); . } . }Traverse both forward and backward from a given position in the text. Calls to notBoundary() in this example represents some additional stopping criteria.. void traverseOut(CharacterIterator& iter, UTextOffset pos) . { . UChar c; . for (c = iter.setIndex(pos); . c != CharacterIterator.DONE && (Unicode::isLetter(c) || Unicode::isDigit(c)); . c = iter.next()) {} . UTextOffset end = iter.getIndex(); . for (c = iter.setIndex(pos); . c != CharacterIterator.DONE && (Unicode::isLetter(c) || Unicode::isDigit(c)); . c = iter.previous()) {} . UTextOffset start = iter.getIndex() + 1; . . cout << "start: " << start << " end: " << end << endl; . for (c = iter.setIndex(start); iter.getIndex() < end; c = iter.next() ) { . processChar(c); . } . }Creating a StringCharacterIteratorand calling the test functions. void CharacterIterator_Example( void ) . { . cout << endl << "===== CharacterIterator_Example: =====" << endl; . UnicodeString text("Ein kleiner Satz."); . StringCharacterIterator iterator(text); . cout << "----- traverseForward: -----------" << endl; . traverseForward( iterator ); . cout << endl << endl << "----- traverseBackward: ----------" << endl; . traverseBackward( iterator ); . cout << endl << endl << "----- traverseOut: ---------------" << endl; . traverseOut( iterator, 7 ); . cout << endl << endl << "-----" << endl; . }
Despite the fact that this function is public,
DO NOT CONSIDER IT PART OF CHARACTERITERATOR'S API!
virtual ~CharacterIterator()
virtual bool_t operator==(const CharacterIterator& that) const
bool_t operator!=(const CharacterIterator& that) const
virtual CharacterIterator* clone(void) const
virtual int32_t hashCode(void) const
virtual UChar first(void)
virtual UChar last(void)
virtual UChar setIndex(UTextOffset position)
virtual UChar current(void) const
virtual UChar next(void)
virtual UChar previous(void)
virtual UTextOffset startIndex(void) const
virtual UTextOffset endIndex(void) const
virtual UTextOffset getIndex(void) const
virtual void getText(UnicodeString& result)
virtual ClassID getDynamicClassID(void) const
alphabetic index hierarchy of classes
this page has been generated automatically by doc++
(c)opyright by Malte Zöckler, Roland Wunderling
contact: doc++@zib.de