164339d36f8bd4db5025fe2988eda22b491a9219cFredrik Roubert// Copyright (C) 2016 and later: Unicode, Inc. and others.
264339d36f8bd4db5025fe2988eda22b491a9219cFredrik Roubert// License & terms of use: http://www.unicode.org/copyright.html
3ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/*
4ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru**********************************************************************
5ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru*   Copyright (C) 1998-2005, International Business Machines
6ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru*   Corporation and others.  All Rights Reserved.
7ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru**********************************************************************
8ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru*/
9ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
10ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#ifndef UCHRITER_H
11ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define UCHRITER_H
12ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
13ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "unicode/utypes.h"
14ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "unicode/chariter.h"
15ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
16ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/**
17ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * \file
18ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * \brief C++ API: UChar Character Iterator
19ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */
20ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
21ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruU_NAMESPACE_BEGIN
22ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
23ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/**
24ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * A concrete subclass of CharacterIterator that iterates over the
25ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * characters (code units or code points) in a UChar array.
26ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * It's possible not only to create an
27ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * iterator that iterates over an entire UChar array, but also to
28ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * create one that iterates over only a subrange of a UChar array
29ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * (iterators over different subranges of the same UChar array don't
30ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * compare equal).
31ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see CharacterIterator
32ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see ForwardCharacterIterator
33ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0
34ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */
35ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruclass U_COMMON_API UCharCharacterIterator : public CharacterIterator {
36ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querupublic:
37ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  /**
38ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * Create an iterator over the UChar array referred to by "textPtr".
39ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * The iteration range is 0 to <code>length-1</code>.
40ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * text is only aliased, not adopted (the
41ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * destructor will not delete it).
42ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @param textPtr The UChar array to be iterated over
43ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @param length The length of the UChar array
44ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @stable ICU 2.0
45ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   */
46ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  UCharCharacterIterator(const UChar* textPtr, int32_t length);
47ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
48ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  /**
49ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * Create an iterator over the UChar array referred to by "textPtr".
50ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * The iteration range is 0 to <code>length-1</code>.
51ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * text is only aliased, not adopted (the
52ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * destructor will not delete it).
53ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * The starting
54ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * position is specified by "position". If "position" is outside the valid
55ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * iteration range, the behavior of this object is undefined.
56ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @param textPtr The UChar array to be iteratd over
57ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @param length The length of the UChar array
58ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @param position The starting position of the iteration
59ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @stable ICU 2.0
60ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   */
61ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  UCharCharacterIterator(const UChar* textPtr, int32_t length,
62ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                         int32_t position);
63ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
64ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  /**
65ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * Create an iterator over the UChar array referred to by "textPtr".
66ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * The iteration range is 0 to <code>end-1</code>.
67ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * text is only aliased, not adopted (the
68ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * destructor will not delete it).
69ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * The starting
70ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * position is specified by "position". If begin and end do not
71ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * form a valid iteration range or "position" is outside the valid
72ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * iteration range, the behavior of this object is undefined.
73ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @param textPtr The UChar array to be iterated over
74ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @param length The length of the UChar array
75ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @param textBegin  The begin position of the iteration range
76ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @param textEnd    The end position of the iteration range
77ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @param position    The starting position of the iteration
78ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @stable ICU 2.0
79ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   */
80ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  UCharCharacterIterator(const UChar* textPtr, int32_t length,
81ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                         int32_t textBegin,
82ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                         int32_t textEnd,
83ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                         int32_t position);
84ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
85ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  /**
86ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * Copy constructor.  The new iterator iterates over the same range
87ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * of the same string as "that", and its initial position is the
88ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * same as "that"'s current position.
89ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @param that The UCharCharacterIterator to be copied
90ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @stable ICU 2.0
91ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   */
92ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  UCharCharacterIterator(const UCharCharacterIterator&  that);
93ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
94ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  /**
95ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * Destructor.
96ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @stable ICU 2.0
97ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   */
98ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  virtual ~UCharCharacterIterator();
99ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
100ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  /**
101ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * Assignment operator.  *this is altered to iterate over the sane
102ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * range of the same string as "that", and refers to the same
103ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * character within that string as "that" does.
104ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @param that The object to be copied
105ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @return the newly created object
106ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @stable ICU 2.0
107ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   */
108ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  UCharCharacterIterator&
109ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  operator=(const UCharCharacterIterator&    that);
110ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
111ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  /**
112ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * Returns true if the iterators iterate over the same range of the
113ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * same string and are pointing at the same character.
114ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @param that The ForwardCharacterIterator used to be compared for equality
115ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @return true if the iterators iterate over the same range of the
116ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * same string and are pointing at the same character.
117ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @stable ICU 2.0
118ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   */
119ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  virtual UBool          operator==(const ForwardCharacterIterator& that) const;
120ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
121ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  /**
122ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * Generates a hash code for this iterator.
123ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @return the hash code.
124ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @stable ICU 2.0
125ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   */
126ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  virtual int32_t         hashCode(void) const;
127ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
128ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  /**
129ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * Returns a new UCharCharacterIterator referring to the same
130ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * character in the same range of the same string as this one.  The
131ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * caller must delete the new iterator.
132ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @return the CharacterIterator newly created
133ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @stable ICU 2.0
134ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   */
135ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  virtual CharacterIterator* clone(void) const;
136ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
137ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  /**
138ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * Sets the iterator to refer to the first code unit in its
139ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * iteration range, and returns that code unit.
140ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * This can be used to begin an iteration with next().
141ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @return the first code unit in its iteration range.
142ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @stable ICU 2.0
143ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   */
144ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  virtual UChar         first(void);
145ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
146ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  /**
147ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * Sets the iterator to refer to the first code unit in its
148ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * iteration range, returns that code unit, and moves the position
149ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * to the second code unit. This is an alternative to setToStart()
150ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * for forward iteration with nextPostInc().
151ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @return the first code unit in its iteration range
152ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @stable ICU 2.0
153ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   */
154ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  virtual UChar         firstPostInc(void);
155ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
156ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  /**
157ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * Sets the iterator to refer to the first code point in its
158ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * iteration range, and returns that code unit,
159ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * This can be used to begin an iteration with next32().
160ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * Note that an iteration with next32PostInc(), beginning with,
161ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * e.g., setToStart() or firstPostInc(), is more efficient.
162ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @return the first code point in its iteration range
163ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @stable ICU 2.0
164ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   */
165ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  virtual UChar32       first32(void);
166ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
167ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  /**
168ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * Sets the iterator to refer to the first code point in its
169ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * iteration range, returns that code point, and moves the position
170ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * to the second code point. This is an alternative to setToStart()
171ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * for forward iteration with next32PostInc().
172ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @return the first code point in its iteration range.
173ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @stable ICU 2.0
174ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   */
175ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  virtual UChar32       first32PostInc(void);
176ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
177ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  /**
178ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * Sets the iterator to refer to the last code unit in its
179ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * iteration range, and returns that code unit.
180ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * This can be used to begin an iteration with previous().
181ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @return the last code unit in its iteration range.
182ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @stable ICU 2.0
183ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   */
184ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  virtual UChar         last(void);
185ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
186ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  /**
187ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * Sets the iterator to refer to the last code point in its
188ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * iteration range, and returns that code unit.
189ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * This can be used to begin an iteration with previous32().
190ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @return the last code point in its iteration range.
191ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @stable ICU 2.0
192ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   */
193ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  virtual UChar32       last32(void);
194ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
195ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  /**
196ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * Sets the iterator to refer to the "position"-th code unit
197ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * in the text-storage object the iterator refers to, and
198ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * returns that code unit.
199ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @param position the position within the text-storage object
200ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @return the code unit
201ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @stable ICU 2.0
202ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   */
203ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  virtual UChar         setIndex(int32_t position);
204ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
205ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  /**
206ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * Sets the iterator to refer to the beginning of the code point
207ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * that contains the "position"-th code unit
208ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * in the text-storage object the iterator refers to, and
209ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * returns that code point.
210ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * The current position is adjusted to the beginning of the code point
211ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * (its first code unit).
212ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @param position the position within the text-storage object
213ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @return the code unit
214ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @stable ICU 2.0
215ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   */
216ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  virtual UChar32       setIndex32(int32_t position);
217ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
218ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  /**
219ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * Returns the code unit the iterator currently refers to.
220ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @return the code unit the iterator currently refers to.
221ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @stable ICU 2.0
222ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   */
223ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  virtual UChar         current(void) const;
224ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
225ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  /**
226ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * Returns the code point the iterator currently refers to.
227ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @return the code point the iterator currently refers to.
228ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @stable ICU 2.0
229ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   */
230ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  virtual UChar32       current32(void) const;
231ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
232ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  /**
233ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * Advances to the next code unit in the iteration range (toward
234ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * endIndex()), and returns that code unit.  If there are no more
235ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * code units to return, returns DONE.
236ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @return the next code unit in the iteration range.
237ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @stable ICU 2.0
238ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   */
239ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  virtual UChar         next(void);
240ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
241ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  /**
242ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * Gets the current code unit for returning and advances to the next code unit
243ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * in the iteration range
244ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * (toward endIndex()).  If there are
245ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * no more code units to return, returns DONE.
246ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @return the current code unit.
247ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @stable ICU 2.0
248ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   */
249ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  virtual UChar         nextPostInc(void);
250ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
251ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  /**
252ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * Advances to the next code point in the iteration range (toward
253ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * endIndex()), and returns that code point.  If there are no more
254ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * code points to return, returns DONE.
255ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * Note that iteration with "pre-increment" semantics is less
256ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * efficient than iteration with "post-increment" semantics
257ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * that is provided by next32PostInc().
258ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @return the next code point in the iteration range.
259ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @stable ICU 2.0
260ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   */
261ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  virtual UChar32       next32(void);
262ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
263ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  /**
264ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * Gets the current code point for returning and advances to the next code point
265ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * in the iteration range
266ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * (toward endIndex()).  If there are
267ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * no more code points to return, returns DONE.
268ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @return the current point.
269ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @stable ICU 2.0
270ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   */
271ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  virtual UChar32       next32PostInc(void);
272ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
273ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  /**
274ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * Returns FALSE if there are no more code units or code points
275ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * at or after the current position in the iteration range.
276ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * This is used with nextPostInc() or next32PostInc() in forward
277ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * iteration.
278ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @return FALSE if there are no more code units or code points
279ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * at or after the current position in the iteration range.
280ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @stable ICU 2.0
281ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   */
282ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  virtual UBool        hasNext();
283ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
284ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  /**
285ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * Advances to the previous code unit in the iteration range (toward
286ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * startIndex()), and returns that code unit.  If there are no more
287ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * code units to return, returns DONE.
288ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @return the previous code unit in the iteration range.
289ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @stable ICU 2.0
290ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   */
291ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  virtual UChar         previous(void);
292ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
293ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  /**
294ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * Advances to the previous code point in the iteration range (toward
295ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * startIndex()), and returns that code point.  If there are no more
296ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * code points to return, returns DONE.
297ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @return the previous code point in the iteration range.
298ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @stable ICU 2.0
299ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   */
300ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  virtual UChar32       previous32(void);
301ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
302ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  /**
303ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * Returns FALSE if there are no more code units or code points
304ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * before the current position in the iteration range.
305ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * This is used with previous() or previous32() in backward
306ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * iteration.
307ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @return FALSE if there are no more code units or code points
308ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * before the current position in the iteration range.
309ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @stable ICU 2.0
310ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   */
311ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  virtual UBool        hasPrevious();
312ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
313ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  /**
314ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * Moves the current position relative to the start or end of the
315ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * iteration range, or relative to the current position itself.
316ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * The movement is expressed in numbers of code units forward
317ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * or backward by specifying a positive or negative delta.
318ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @param delta the position relative to origin. A positive delta means forward;
319ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * a negative delta means backward.
320ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @param origin Origin enumeration {kStart, kCurrent, kEnd}
321ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @return the new position
322ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @stable ICU 2.0
323ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   */
324ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  virtual int32_t      move(int32_t delta, EOrigin origin);
325ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
326ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  /**
327ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * Moves the current position relative to the start or end of the
328ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * iteration range, or relative to the current position itself.
329ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * The movement is expressed in numbers of code points forward
330ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * or backward by specifying a positive or negative delta.
331ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @param delta the position relative to origin. A positive delta means forward;
332ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * a negative delta means backward.
333ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @param origin Origin enumeration {kStart, kCurrent, kEnd}
334ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @return the new position
335ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @stable ICU 2.0
336ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   */
337ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  virtual int32_t      move32(int32_t delta, EOrigin origin);
338ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
339ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  /**
340ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * Sets the iterator to iterate over a new range of text
341ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @stable ICU 2.0
342ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   */
343ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  void setText(const UChar* newText, int32_t newTextLength);
344ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
345ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  /**
346ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * Copies the UChar array under iteration into the UnicodeString
347ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * referred to by "result".  Even if this iterator iterates across
348ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * only a part of this string, the whole string is copied.
349ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @param result Receives a copy of the text under iteration.
350ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @stable ICU 2.0
351ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   */
352ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  virtual void            getText(UnicodeString& result);
353ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
354ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  /**
355ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * Return a class ID for this class (not really public)
356ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @return a class ID for this class
357ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @stable ICU 2.0
358ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   */
359ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  static UClassID         U_EXPORT2 getStaticClassID(void);
360ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
361ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  /**
362ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * Return a class ID for this object (not really public)
363ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @return a class ID for this object.
364ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @stable ICU 2.0
365ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   */
366ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  virtual UClassID        getDynamicClassID(void) const;
367ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
368ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruprotected:
369ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  /**
370ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * Protected constructor
371ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @stable ICU 2.0
372ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   */
373ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  UCharCharacterIterator();
374ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  /**
375ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * Protected member text
376ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @stable ICU 2.0
377ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   */
378ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  const UChar*            text;
379ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
380ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru};
381ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
382ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruU_NAMESPACE_END
383ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#endif
384