2
******************************************************************************
4
* Copyright (C) 1998-2001, International Business Machines
5
* Corporation and others. All Rights Reserved.
7
******************************************************************************
11
* Modification History:
13
* Date Name Description
14
* 05/05/99 stephen Cleaned up.
15
******************************************************************************
21
#include "unicode/utypes.h"
22
#include "unicode/chariter.h"
23
#include "unicode/uchriter.h"
27
* A concrete subclass of CharacterIterator that iterates over the
28
* characters (code units or code points) in a UnicodeString.
29
* It's possible not only to create an
30
* iterator that iterates over an entire UnicodeString, but also to
31
* create one that iterates over only a subrange of a UnicodeString
32
* (iterators over different subranges of the same UnicodeString don't
34
* @see CharacterIterator
35
* @see ForwardCharacterIterator
38
class U_COMMON_API StringCharacterIterator : public UCharCharacterIterator {
41
* Create an iterator over the UnicodeString referred to by "textStr".
42
* The UnicodeString object is copied.
43
* The iteration range is the whole string, and the starting position is 0.
46
StringCharacterIterator(const UnicodeString& textStr);
49
* Create an iterator over the UnicodeString referred to by "textStr".
50
* The iteration range is the whole string, and the starting
51
* position is specified by "textPos". If "textPos" is outside the valid
52
* iteration range, the behavior of this object is undefined.
55
StringCharacterIterator(const UnicodeString& textStr,
59
* Create an iterator over the UnicodeString referred to by "textStr".
60
* The UnicodeString object is copied.
61
* The iteration range begins with the code unit specified by
62
* "textBegin" and ends with the code unit BEFORE the code unit specfied
63
* by "textEnd". The starting position is specified by "textPos". If
64
* "textBegin" and "textEnd" don't form a valid range on "text" (i.e.,
65
* textBegin >= textEnd or either is negative or greater than text.size()),
66
* or "textPos" is outside the range defined by "textBegin" and "textEnd",
67
* the behavior of this iterator is undefined.
70
StringCharacterIterator(const UnicodeString& textStr,
76
* Copy constructor. The new iterator iterates over the same range
77
* of the same string as "that", and its initial position is the
78
* same as "that"'s current position.
79
* The UnicodeString object in "that" is copied.
82
StringCharacterIterator(const StringCharacterIterator& that);
88
virtual ~StringCharacterIterator();
91
* Assignment operator. *this is altered to iterate over the same
92
* range of the same string as "that", and refers to the same
93
* character within that string as "that" does.
96
StringCharacterIterator&
97
operator=(const StringCharacterIterator& that);
100
* Returns true if the iterators iterate over the same range of the
101
* same string and are pointing at the same character.
104
virtual UBool operator==(const ForwardCharacterIterator& that) const;
107
* Returns a new StringCharacterIterator referring to the same
108
* character in the same range of the same string as this one. The
109
* caller must delete the new iterator.
112
virtual CharacterIterator* clone(void) const;
115
* Sets the iterator to iterate over the provided string.
118
void setText(const UnicodeString& newText);
121
* Copies the UnicodeString under iteration into the UnicodeString
122
* referred to by "result". Even if this iterator iterates across
123
* only a part of this string, the whole string is copied.
124
* @param result Receives a copy of the text under iteration.
127
virtual void getText(UnicodeString& result);
130
* Return a class ID for this object (not really public)
133
virtual UClassID getDynamicClassID(void) const
134
{ return getStaticClassID(); }
137
* Return a class ID for this class (not really public)
140
static UClassID getStaticClassID(void)
141
{ return (UClassID)(&fgClassID); }
144
StringCharacterIterator();
145
void setText(const UChar* newText, int32_t newTextLength);
149
static const char fgClassID;