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