Main Page   Class Hierarchy   Compound List   File List   Header Files   Sources   Compound Members   File Members  

ForwardCharacterIterator Class Reference

Abstract class that defines an API for forward-only iteration on text objects. More...

#include <chariter.h>

Class diagram for ForwardCharacterIterator:

CharacterIterator UCharCharacterIterator StringCharacterIterator

List of all members.


Public Members

enum  { DONE }
Value returned by most of ForwardCharacterIterator's functions when the iterator has reached the limits of its iteration. More...

virtual ~ForwardCharacterIterator ()
Destructor. More...

virtual UBool operator== (const ForwardCharacterIterator& that) const = 0
Returns true when both iterators refer to the same character in the same character-storage object. More...

UBool operator!= (const ForwardCharacterIterator& that) const
Returns true when the iterators refer to different text-storage objects, or to different characters in the same text-storage object. More...

virtual int32_t hashCode (void) const = 0
Generates a hash code for this iterator. More...

virtual UClassID getDynamicClassID (void) const = 0
Returns a UClassID for this ForwardCharacterIterator ("poor man's RTTI").

Despite the fact that this function is public, DO NOT CONSIDER IT PART OF CHARACTERITERATOR'S API! More...

virtual UChar nextPostInc (void) = 0
Gets the current code unit for returning and advances to the next code unit in the iteration range (toward endIndex()). More...

virtual UChar32 next32PostInc (void) = 0
Gets the current code point for returning and advances to the next code point in the iteration range (toward endIndex()). More...

virtual UBool hasNext () = 0
Returns FALSE if there are no more code units or code points at or after the current position in the iteration range. More...


Protected Members

 ForwardCharacterIterator ()
 ForwardCharacterIterator (const ForwardCharacterIterator&)
ForwardCharacterIterator& operator= (const ForwardCharacterIterator&)

Detailed Description

Abstract class that defines an API for forward-only iteration on text objects.

This is a minimal interface for iteration without random access or backwards iteration. It is especially useful for wrapping streams with converters into an object for collation or normalization.

Characters can be accessed in two ways: as code units or as code points. Unicode code points are 21-bit integers and are the scalar values of Unicode characters. ICU uses the type UChar32 for them. Unicode code units are the storage units of a given Unicode/UCS Transformation Format (a character encoding scheme). With UTF-16, all code points can be represented with either one or two code units ("surrogates"). String storage is typically based on code units, while properties of characters are typically determined using code point values. Some processes may be designed to work with sequences of code units, or it may be known that all characters that are important to an algorithm can be represented with single code units. Other processes will need to use the code point access functions.

ForwardCharacterIterator provides nextPostInc() to access a code unit and advance an internal position into the text object, similar to a return text[position++].
It provides next32PostInc() to access a code point and advance an internal position.

next32PostInc() assumes that the current position is that of the beginning of a code point, i.e., of its first code unit. After next32PostInc(), this will be true again. In general, access to code units and code points in the same iteration loop should not be mixed. In UTF-16, if the current position is on a second code unit (Low Surrogate), then only that code unit is returned even by next32PostInc().

For iteration with either function, there are two ways to check for the end of the iteration. When there are no more characters in the text object:

Example:

 &#32; void function1(ForwardCharacterIterator &it) {
 &#32;     UChar32 c;
 &#32;     while(it.hasNext()) {
 &#32;         c=it.next32PostInc();
 &#32;         // use c
 &#32;     }
 &#32; }

 &#32; void function1(ForwardCharacterIterator &it) {
 &#32;     UChar c;
 &#32;     while((c=it.nextPostInc())!=ForwardCharacterIterator::DONE) {
 &#32;         // use c
 &#32;     }
 &#32; }
 

Definition at line 80 of file chariter.h.


Enumeration Value Documentation

ForwardCharacterIterator::DONE


Member Function Documentation

virtual ForwardCharacterIterator::~ForwardCharacterIterator () [inline, virtual]

Destructor.

Stable:

Definition at line 91 of file chariter.h.

virtual UBool ForwardCharacterIterator::operator== (const ForwardCharacterIterator & that) const [pure virtual]

Returns true when both iterators refer to the same character in the same character-storage object.

Stable:

Reimplemented in StringCharacterIterator, and UCharCharacterIterator.

UBool ForwardCharacterIterator::operator!= (const ForwardCharacterIterator & that) const [inline]

Returns true when the iterators refer to different text-storage objects, or to different characters in the same text-storage object.

Stable:

Definition at line 538 of file chariter.h.

virtual int32_t ForwardCharacterIterator::hashCode (void) const [pure virtual]

Generates a hash code for this iterator.

Stable:

Reimplemented in UCharCharacterIterator.

virtual UClassID ForwardCharacterIterator::getDynamicClassID (void) const [pure virtual]

Returns a UClassID for this ForwardCharacterIterator ("poor man's RTTI").

Despite the fact that this function is public, DO NOT CONSIDER IT PART OF CHARACTERITERATOR'S API!

Stable:

Reimplemented in StringCharacterIterator, and UCharCharacterIterator.

virtual UChar ForwardCharacterIterator::nextPostInc (void) [pure virtual]

Gets the current code unit for returning and advances to the next code unit in the iteration range (toward endIndex()).

If there are no more code units to return, returns DONE.

Draft:

Reimplemented in UCharCharacterIterator.

virtual UChar32 ForwardCharacterIterator::next32PostInc (void) [pure virtual]

Gets the current code point for returning and advances to the next code point in the iteration range (toward endIndex()).

If there are no more code points to return, returns DONE.

Draft:

Reimplemented in UCharCharacterIterator.

virtual UBool ForwardCharacterIterator::hasNext () [pure virtual]

Returns FALSE if there are no more code units or code points at or after the current position in the iteration range.

This is used with nextPostInc() or next32PostInc() in forward iteration.

Reimplemented in UCharCharacterIterator.

ForwardCharacterIterator::ForwardCharacterIterator () [inline, protected]

Definition at line 149 of file chariter.h.

ForwardCharacterIterator::ForwardCharacterIterator (const ForwardCharacterIterator &) [inline, protected]

Definition at line 150 of file chariter.h.

ForwardCharacterIterator & ForwardCharacterIterator::operator= (const ForwardCharacterIterator &) [inline, protected]

Definition at line 151 of file chariter.h.


The documentation for this class was generated from the following file:
Generated at Mon Jun 5 12:53:16 2000 for ICU1.5 by doxygen 1.0.0 written by Dimitri van Heesch, © 1997-1999