1ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/*
2ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru********************************************************************
3ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru*
483a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius*   Copyright (C) 1997-2011, International Business Machines
5ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru*   Corporation and others.  All Rights Reserved.
6ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru*
7ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru********************************************************************
8ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru*/
9ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
10ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#ifndef CHARITER_H
11ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define CHARITER_H
12ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
13ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "unicode/utypes.h"
14ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "unicode/uobject.h"
15ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "unicode/unistr.h"
16ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/**
17ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * \file
18ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * \brief C++ API: Character Iterator
19ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */
20ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
21ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruU_NAMESPACE_BEGIN
22ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/**
23ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Abstract class that defines an API for forward-only iteration
24ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * on text objects.
25ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * This is a minimal interface for iteration without random access
26ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * or backwards iteration. It is especially useful for wrapping
27ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * streams with converters into an object for collation or
28ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * normalization.
29ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
30ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>Characters can be accessed in two ways: as code units or as
31ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * code points.
32ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Unicode code points are 21-bit integers and are the scalar values
33ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * of Unicode characters. ICU uses the type UChar32 for them.
34ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Unicode code units are the storage units of a given
35ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Unicode/UCS Transformation Format (a character encoding scheme).
36ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * With UTF-16, all code points can be represented with either one
37ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * or two code units ("surrogates").
38ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * String storage is typically based on code units, while properties
39ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * of characters are typically determined using code point values.
40ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Some processes may be designed to work with sequences of code units,
41ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * or it may be known that all characters that are important to an
42ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * algorithm can be represented with single code units.
43ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Other processes will need to use the code point access functions.</p>
44ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
45ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>ForwardCharacterIterator provides nextPostInc() to access
46ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * a code unit and advance an internal position into the text object,
47ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * similar to a <code>return text[position++]</code>.<br>
48ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * It provides next32PostInc() to access a code point and advance an internal
49ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * position.</p>
50ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
51ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>next32PostInc() assumes that the current position is that of
52ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * the beginning of a code point, i.e., of its first code unit.
53ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * After next32PostInc(), this will be true again.
54ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * In general, access to code units and code points in the same
55ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * iteration loop should not be mixed. In UTF-16, if the current position
56ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * is on a second code unit (Low Surrogate), then only that code unit
57ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * is returned even by next32PostInc().</p>
58ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
59ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>For iteration with either function, there are two ways to
60ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * check for the end of the iteration. When there are no more
61ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * characters in the text object:
62ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <ul>
63ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <li>The hasNext() function returns FALSE.</li>
64ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <li>nextPostInc() and next32PostInc() return DONE
65ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *     when one attempts to read beyond the end of the text object.</li>
66ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * </ul>
67ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
68ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Example:
69ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * \code
70ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * void function1(ForwardCharacterIterator &it) {
71ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *     UChar32 c;
72ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *     while(it.hasNext()) {
73ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *         c=it.next32PostInc();
74ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *         // use c
75ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *     }
76ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * }
77ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
78ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * void function1(ForwardCharacterIterator &it) {
79ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *     UChar c;
80ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *     while((c=it.nextPostInc())!=ForwardCharacterIterator::DONE) {
81ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *         // use c
82ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *      }
83ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *  }
84ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * \endcode
85ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * </p>
86ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
87ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0
88ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */
89ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruclass U_COMMON_API ForwardCharacterIterator : public UObject {
90ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querupublic:
91ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
92ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Value returned by most of ForwardCharacterIterator's functions
93ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * when the iterator has reached the limits of its iteration.
94ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @stable ICU 2.0
95ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
96ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    enum { DONE = 0xffff };
97ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
98ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
99ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Destructor.
100ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @stable ICU 2.0
101ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
102ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    virtual ~ForwardCharacterIterator();
103ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
104ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
105ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Returns true when both iterators refer to the same
106ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * character in the same character-storage object.
107ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param that The ForwardCharacterIterator to be compared for equality
108ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @return true when both iterators refer to the same
109ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * character in the same character-storage object
110ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @stable ICU 2.0
111ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
112ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    virtual UBool operator==(const ForwardCharacterIterator& that) const = 0;
113ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
114ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
115ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Returns true when the iterators refer to different
116ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * text-storage objects, or to different characters in the
117ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * same text-storage object.
118ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param that The ForwardCharacterIterator to be compared for inequality
119ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @return true when the iterators refer to different
120ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * text-storage objects, or to different characters in the
121ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * same text-storage object
122ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @stable ICU 2.0
123ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
124ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    inline UBool operator!=(const ForwardCharacterIterator& that) const;
125ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
126ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
127ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Generates a hash code for this iterator.
128ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @return the hash code.
129ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @stable ICU 2.0
130ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
131ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    virtual int32_t hashCode(void) const = 0;
132ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
133ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
134ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Returns a UClassID for this ForwardCharacterIterator ("poor man's
135ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * RTTI").<P> Despite the fact that this function is public,
136ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * DO NOT CONSIDER IT PART OF CHARACTERITERATOR'S API!
137ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @return a UClassID for this ForwardCharacterIterator
138ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @stable ICU 2.0
139ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
140ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    virtual UClassID getDynamicClassID(void) const = 0;
141ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
142ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
143ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Gets the current code unit for returning and advances to the next code unit
144ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * in the iteration range
145ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * (toward endIndex()).  If there are
146ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * no more code units to return, returns DONE.
147ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @return the current code unit.
148ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @stable ICU 2.0
149ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
150ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    virtual UChar         nextPostInc(void) = 0;
151ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
152ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
153ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Gets the current code point for returning and advances to the next code point
154ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * in the iteration range
155ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * (toward endIndex()).  If there are
156ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * no more code points to return, returns DONE.
157ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @return the current code point.
158ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @stable ICU 2.0
159ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
160ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    virtual UChar32       next32PostInc(void) = 0;
161ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
162ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
163ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Returns FALSE if there are no more code units or code points
164ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * at or after the current position in the iteration range.
165ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * This is used with nextPostInc() or next32PostInc() in forward
166ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * iteration.
167ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @returns FALSE if there are no more code units or code points
168ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * at or after the current position in the iteration range.
169ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @stable ICU 2.0
170ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
171ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    virtual UBool        hasNext() = 0;
172ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
173ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruprotected:
174ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /** Default constructor to be overridden in the implementing class. @stable ICU 2.0*/
175ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    ForwardCharacterIterator();
176ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
177ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /** Copy constructor to be overridden in the implementing class. @stable ICU 2.0*/
178ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    ForwardCharacterIterator(const ForwardCharacterIterator &other);
179ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
180ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
181ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Assignment operator to be overridden in the implementing class.
182ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @stable ICU 2.0
183ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
184ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    ForwardCharacterIterator &operator=(const ForwardCharacterIterator&) { return *this; }
185ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru};
186ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
187ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/**
188ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Abstract class that defines an API for iteration
189ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * on text objects.
190ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * This is an interface for forward and backward iteration
191ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * and random access into a text object.
192ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
193ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>The API provides backward compatibility to the Java and older ICU
194ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * CharacterIterator classes but extends them significantly:
195ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <ol>
196ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <li>CharacterIterator is now a subclass of ForwardCharacterIterator.</li>
197ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <li>While the old API functions provided forward iteration with
198ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *     "pre-increment" semantics, the new one also provides functions
199ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *     with "post-increment" semantics. They are more efficient and should
200ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *     be the preferred iterator functions for new implementations.
201ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *     The backward iteration always had "pre-decrement" semantics, which
202ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *     are efficient.</li>
203ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <li>Just like ForwardCharacterIterator, it provides access to
204ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *     both code units and code points. Code point access versions are available
205ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *     for the old and the new iteration semantics.</li>
206ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <li>There are new functions for setting and moving the current position
207ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *     without returning a character, for efficiency.</li>
208ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * </ol>
209ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
210ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * See ForwardCharacterIterator for examples for using the new forward iteration
211ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * functions. For backward iteration, there is also a hasPrevious() function
212ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * that can be used analogously to hasNext().
213ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * The old functions work as before and are shown below.</p>
214ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
215ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>Examples for some of the new functions:</p>
216ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
217ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Forward iteration with hasNext():
218ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * \code
219ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * void forward1(CharacterIterator &it) {
220ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *     UChar32 c;
221ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *     for(it.setToStart(); it.hasNext();) {
222ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *         c=it.next32PostInc();
223ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *         // use c
224ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *     }
225ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *  }
226ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * \endcode
227ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Forward iteration more similar to loops with the old forward iteration,
228ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * showing a way to convert simple for() loops:
229ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * \code
230ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * void forward2(CharacterIterator &it) {
231ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *     UChar c;
232ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *     for(c=it.firstPostInc(); c!=CharacterIterator::DONE; c=it.nextPostInc()) {
233ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *          // use c
234ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *      }
235ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * }
236ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * \endcode
237ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Backward iteration with setToEnd() and hasPrevious():
238ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * \code
239ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *  void backward1(CharacterIterator &it) {
240ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *      UChar32 c;
241ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *      for(it.setToEnd(); it.hasPrevious();) {
242ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *         c=it.previous32();
243ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *          // use c
244ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *      }
245ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *  }
246ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * \endcode
247ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Backward iteration with a more traditional for() loop:
248ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * \code
249ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * void backward2(CharacterIterator &it) {
250ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *     UChar c;
251ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *     for(c=it.last(); c!=CharacterIterator::DONE; c=it.previous()) {
252ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *         // use c
253ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *      }
254ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *  }
255ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * \endcode
256ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
257ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Example for random access:
258ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * \code
259ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *  void random(CharacterIterator &it) {
260ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *      // set to the third code point from the beginning
261ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *      it.move32(3, CharacterIterator::kStart);
262ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *      // get a code point from here without moving the position
263ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *      UChar32 c=it.current32();
264ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *      // get the position
265ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *      int32_t pos=it.getIndex();
266ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *      // get the previous code unit
267ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *      UChar u=it.previous();
268ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *      // move back one more code unit
269ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *      it.move(-1, CharacterIterator::kCurrent);
270ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *      // set the position back to where it was
271ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *      // and read the same code point c and move beyond it
272ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *      it.setIndex(pos);
273ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *      if(c!=it.next32PostInc()) {
274ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *          exit(1); // CharacterIterator inconsistent
275ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *      }
276ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *  }
277ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * \endcode
278ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
279ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>Examples, especially for the old API:</p>
280ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
281ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Function processing characters, in this example simple output
282ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <pre>
283ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * \code
284ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *  void processChar( UChar c )
285ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *  {
286ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *      cout << " " << c;
287ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *  }
288ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * \endcode
289ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * </pre>
290ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Traverse the text from start to finish
291ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <pre>
292ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * \code
293ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *  void traverseForward(CharacterIterator& iter)
294ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *  {
295ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *      for(UChar c = iter.first(); c != CharacterIterator.DONE; c = iter.next()) {
296ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *          processChar(c);
297ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *      }
298ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *  }
299ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * \endcode
300ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * </pre>
301ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Traverse the text backwards, from end to start
302ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <pre>
303ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * \code
304ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *  void traverseBackward(CharacterIterator& iter)
305ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *  {
306ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *      for(UChar c = iter.last(); c != CharacterIterator.DONE; c = iter.previous()) {
307ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *          processChar(c);
308ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *      }
309ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *  }
310ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * \endcode
311ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * </pre>
312ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Traverse both forward and backward from a given position in the text.
313ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Calls to notBoundary() in this example represents some additional stopping criteria.
314ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <pre>
315ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * \code
316ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * void traverseOut(CharacterIterator& iter, int32_t pos)
317ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * {
318ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *      UChar c;
319ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *      for (c = iter.setIndex(pos);
320ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *      c != CharacterIterator.DONE && (Unicode::isLetter(c) || Unicode::isDigit(c));
321ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *          c = iter.next()) {}
322ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *      int32_t end = iter.getIndex();
323ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *      for (c = iter.setIndex(pos);
324ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *          c != CharacterIterator.DONE && (Unicode::isLetter(c) || Unicode::isDigit(c));
325ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *          c = iter.previous()) {}
326ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *      int32_t start = iter.getIndex() + 1;
327ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
328ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *      cout << "start: " << start << " end: " << end << endl;
329ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *      for (c = iter.setIndex(start); iter.getIndex() < end; c = iter.next() ) {
330ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *          processChar(c);
331ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *     }
332ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *  }
333ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * \endcode
334ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * </pre>
335ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Creating a StringCharacterIterator and calling the test functions
336ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <pre>
337ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * \code
338ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *  void CharacterIterator_Example( void )
339ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *   {
340ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *       cout << endl << "===== CharacterIterator_Example: =====" << endl;
341ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *       UnicodeString text("Ein kleiner Satz.");
342ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *       StringCharacterIterator iterator(text);
343ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *       cout << "----- traverseForward: -----------" << endl;
344ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *       traverseForward( iterator );
345ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *       cout << endl << endl << "----- traverseBackward: ----------" << endl;
346ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *       traverseBackward( iterator );
347ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *       cout << endl << endl << "----- traverseOut: ---------------" << endl;
348ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *       traverseOut( iterator, 7 );
349ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *       cout << endl << endl << "-----" << endl;
350ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *   }
351ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * \endcode
352ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * </pre>
353ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
354ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0
355ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */
356ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruclass U_COMMON_API CharacterIterator : public ForwardCharacterIterator {
357ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querupublic:
358ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
359ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Origin enumeration for the move() and move32() functions.
360ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @stable ICU 2.0
361ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
362ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    enum EOrigin { kStart, kCurrent, kEnd };
363ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
364ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
36583a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius     * Destructor.
36683a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius     * @stable ICU 2.0
36783a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius     */
36883a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius    virtual ~CharacterIterator();
36983a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius
37083a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius    /**
371ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Returns a pointer to a new CharacterIterator of the same
372ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * concrete class as this one, and referring to the same
373ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * character in the same text-storage object as this one.  The
374ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * caller is responsible for deleting the new clone.
375ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @return a pointer to a new CharacterIterator
376ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @stable ICU 2.0
377ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
378ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    virtual CharacterIterator* clone(void) const = 0;
379ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
380ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
381ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Sets the iterator to refer to the first code unit in its
382ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * iteration range, and returns that code unit.
383ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * This can be used to begin an iteration with next().
384ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @return the first code unit in its iteration range.
385ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @stable ICU 2.0
386ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
387ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    virtual UChar         first(void) = 0;
388ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
389ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
390ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Sets the iterator to refer to the first code unit in its
391ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * iteration range, returns that code unit, and moves the position
392ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * to the second code unit. This is an alternative to setToStart()
393ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * for forward iteration with nextPostInc().
394ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @return the first code unit in its iteration range.
395ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @stable ICU 2.0
396ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
397ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    virtual UChar         firstPostInc(void);
398ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
399ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
400ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Sets the iterator to refer to the first code point in its
401ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * iteration range, and returns that code unit,
402ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * This can be used to begin an iteration with next32().
403ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Note that an iteration with next32PostInc(), beginning with,
404ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * e.g., setToStart() or firstPostInc(), is more efficient.
405ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @return the first code point in its iteration range.
406ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @stable ICU 2.0
407ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
408ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    virtual UChar32       first32(void) = 0;
409ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
410ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
411ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Sets the iterator to refer to the first code point in its
412ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * iteration range, returns that code point, and moves the position
413ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * to the second code point. This is an alternative to setToStart()
414ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * for forward iteration with next32PostInc().
415ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @return the first code point in its iteration range.
416ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @stable ICU 2.0
417ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
418ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    virtual UChar32       first32PostInc(void);
419ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
420ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
421ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Sets the iterator to refer to the first code unit or code point in its
422ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * iteration range. This can be used to begin a forward
423ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * iteration with nextPostInc() or next32PostInc().
424ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @return the start position of the iteration range
425ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @stable ICU 2.0
426ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
427ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    inline int32_t    setToStart();
428ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
429ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
430ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Sets the iterator to refer to the last code unit in its
431ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * iteration range, and returns that code unit.
432ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * This can be used to begin an iteration with previous().
433ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @return the last code unit.
434ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @stable ICU 2.0
435ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
436ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    virtual UChar         last(void) = 0;
437ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
438ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
439ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Sets the iterator to refer to the last code point in its
440ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * iteration range, and returns that code unit.
441ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * This can be used to begin an iteration with previous32().
442ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @return the last code point.
443ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @stable ICU 2.0
444ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
445ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    virtual UChar32       last32(void) = 0;
446ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
447ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
448ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Sets the iterator to the end of its iteration range, just behind
449ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * the last code unit or code point. This can be used to begin a backward
450ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * iteration with previous() or previous32().
451ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @return the end position of the iteration range
452ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @stable ICU 2.0
453ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
454ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    inline int32_t    setToEnd();
455ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
456ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
457ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Sets the iterator to refer to the "position"-th code unit
458ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * in the text-storage object the iterator refers to, and
459ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * returns that code unit.
460ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param position the "position"-th code unit in the text-storage object
461ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @return the "position"-th code unit.
462ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @stable ICU 2.0
463ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
464ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    virtual UChar         setIndex(int32_t position) = 0;
465ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
466ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
467ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Sets the iterator to refer to the beginning of the code point
468ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * that contains the "position"-th code unit
469ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * in the text-storage object the iterator refers to, and
470ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * returns that code point.
471ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * The current position is adjusted to the beginning of the code point
472ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * (its first code unit).
473ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param position the "position"-th code unit in the text-storage object
474ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @return the "position"-th code point.
475ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @stable ICU 2.0
476ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
477ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    virtual UChar32       setIndex32(int32_t position) = 0;
478ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
479ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
480ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Returns the code unit the iterator currently refers to.
481ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @return the current code unit.
482ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @stable ICU 2.0
483ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
484ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    virtual UChar         current(void) const = 0;
485ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
486ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
487ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Returns the code point the iterator currently refers to.
488ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @return the current code point.
489ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @stable ICU 2.0
490ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
491ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    virtual UChar32       current32(void) const = 0;
492ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
493ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
494ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Advances to the next code unit in the iteration range
495ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * (toward endIndex()), and returns that code unit.  If there are
496ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * no more code units to return, returns DONE.
497ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @return the next code unit.
498ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @stable ICU 2.0
499ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
500ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    virtual UChar         next(void) = 0;
501ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
502ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
503ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Advances to the next code point in the iteration range
504ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * (toward endIndex()), and returns that code point.  If there are
505ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * no more code points to return, returns DONE.
506ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Note that iteration with "pre-increment" semantics is less
507ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * efficient than iteration with "post-increment" semantics
508ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * that is provided by next32PostInc().
509ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @return the next code point.
510ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @stable ICU 2.0
511ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
512ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    virtual UChar32       next32(void) = 0;
513ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
514ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
515ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Advances to the previous code unit in the iteration range
516ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * (toward startIndex()), and returns that code unit.  If there are
517ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * no more code units to return, returns DONE.
518ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @return the previous code unit.
519ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @stable ICU 2.0
520ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
521ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    virtual UChar         previous(void) = 0;
522ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
523ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
524ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Advances to the previous code point in the iteration range
525ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * (toward startIndex()), and returns that code point.  If there are
526ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * no more code points to return, returns DONE.
527ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @return the previous code point.
528ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @stable ICU 2.0
529ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
530ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    virtual UChar32       previous32(void) = 0;
531ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
532ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
533ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Returns FALSE if there are no more code units or code points
534ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * before the current position in the iteration range.
535ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * This is used with previous() or previous32() in backward
536ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * iteration.
537ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @return FALSE if there are no more code units or code points
538ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * before the current position in the iteration range, return TRUE otherwise.
539ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @stable ICU 2.0
540ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
541ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    virtual UBool        hasPrevious() = 0;
542ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
543ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
544ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Returns the numeric index in the underlying text-storage
545ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * object of the character returned by first().  Since it's
546ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * possible to create an iterator that iterates across only
547ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * part of a text-storage object, this number isn't
548ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * necessarily 0.
549ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @returns the numeric index in the underlying text-storage
550ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * object of the character returned by first().
551ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @stable ICU 2.0
552ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
553ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    inline int32_t       startIndex(void) const;
554ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
555ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
556ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Returns the numeric index in the underlying text-storage
557ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * object of the position immediately BEYOND the character
558ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * returned by last().
559ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @return the numeric index in the underlying text-storage
560ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * object of the position immediately BEYOND the character
561ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * returned by last().
562ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @stable ICU 2.0
563ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
564ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    inline int32_t       endIndex(void) const;
565ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
566ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
567ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Returns the numeric index in the underlying text-storage
568ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * object of the character the iterator currently refers to
569ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * (i.e., the character returned by current()).
570ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @return the numberic index in the text-storage object of
571ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * the character the iterator currently refers to
572ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @stable ICU 2.0
573ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
574ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    inline int32_t       getIndex(void) const;
575ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
576ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
577ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Returns the length of the entire text in the underlying
578ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * text-storage object.
579ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @return the length of the entire text in the text-storage object
580ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @stable ICU 2.0
581ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
582ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    inline int32_t           getLength() const;
583ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
584ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
585ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Moves the current position relative to the start or end of the
586ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * iteration range, or relative to the current position itself.
587ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * The movement is expressed in numbers of code units forward
588ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * or backward by specifying a positive or negative delta.
589ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param delta the position relative to origin. A positive delta means forward;
590ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * a negative delta means backward.
591ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param origin Origin enumeration {kStart, kCurrent, kEnd}
592ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @return the new position
593ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @stable ICU 2.0
594ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
595ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    virtual int32_t      move(int32_t delta, EOrigin origin) = 0;
596ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
597ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
598ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Moves the current position relative to the start or end of the
599ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * iteration range, or relative to the current position itself.
600ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * The movement is expressed in numbers of code points forward
601ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * or backward by specifying a positive or negative delta.
602ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param delta the position relative to origin. A positive delta means forward;
603ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * a negative delta means backward.
604ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param origin Origin enumeration {kStart, kCurrent, kEnd}
605ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @return the new position
606ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @stable ICU 2.0
607ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
608ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    virtual int32_t      move32(int32_t delta, EOrigin origin) = 0;
609ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
610ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
611ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Copies the text under iteration into the UnicodeString
612ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * referred to by "result".
613ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param result Receives a copy of the text under iteration.
614ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @stable ICU 2.0
615ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
616ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    virtual void            getText(UnicodeString&  result) = 0;
617ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
618ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruprotected:
619ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
620ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Empty constructor.
621ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @stable ICU 2.0
622ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
623ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    CharacterIterator();
624ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
625ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
626ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Constructor, just setting the length field in this base class.
627ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @stable ICU 2.0
628ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
629ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    CharacterIterator(int32_t length);
630ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
631ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
632ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Constructor, just setting the length and position fields in this base class.
633ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @stable ICU 2.0
634ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
635ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    CharacterIterator(int32_t length, int32_t position);
636ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
637ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
638ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Constructor, just setting the length, start, end, and position fields in this base class.
639ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @stable ICU 2.0
640ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
641ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    CharacterIterator(int32_t length, int32_t textBegin, int32_t textEnd, int32_t position);
642ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
643ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
644ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Copy constructor.
645ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *
646ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param that The CharacterIterator to be copied
647ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @stable ICU 2.0
648ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
649ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    CharacterIterator(const CharacterIterator &that);
650ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
651ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
652ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Assignment operator.  Sets this CharacterIterator to have the same behavior,
653ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * as the one passed in.
654ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param that The CharacterIterator passed in.
655ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @return the newly set CharacterIterator.
656ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @stable ICU 2.0
657ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
658ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    CharacterIterator &operator=(const CharacterIterator &that);
659ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
660ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
661ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Base class text length field.
662ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Necessary this for correct getText() and hashCode().
663ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @stable ICU 2.0
664ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
665ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    int32_t textLength;
666ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
667ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
668ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Base class field for the current position.
669ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @stable ICU 2.0
670ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
671ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    int32_t  pos;
672ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
673ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
674ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Base class field for the start of the iteration range.
675ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @stable ICU 2.0
676ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
677ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    int32_t  begin;
678ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
679ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
680ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Base class field for the end of the iteration range.
681ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @stable ICU 2.0
682ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
683ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    int32_t  end;
684ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru};
685ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
686ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruinline UBool
687ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruForwardCharacterIterator::operator!=(const ForwardCharacterIterator& that) const {
688ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    return !operator==(that);
689ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
690ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
691ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruinline int32_t
692ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruCharacterIterator::setToStart() {
693ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    return move(0, kStart);
694ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
695ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
696ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruinline int32_t
697ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruCharacterIterator::setToEnd() {
698ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    return move(0, kEnd);
699ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
700ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
701ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruinline int32_t
702ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruCharacterIterator::startIndex(void) const {
703ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    return begin;
704ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
705ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
706ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruinline int32_t
707ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruCharacterIterator::endIndex(void) const {
708ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    return end;
709ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
710ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
711ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruinline int32_t
712ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruCharacterIterator::getIndex(void) const {
713ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    return pos;
714ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
715ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
716ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruinline int32_t
717ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruCharacterIterator::getLength(void) const {
718ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    return textLength;
719ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
720ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
721ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruU_NAMESPACE_END
722ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#endif
723