ICU 69.1: usetiter.h Source File

ICU 69.1 69.1

usetiter.h
Go to the documentation of this file.
1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /*
4 **********************************************************************
5 * Copyright (c) 2002-2014, International Business Machines
6 * Corporation and others. All Rights Reserved.
7 **********************************************************************
8 */
9 #ifndef USETITER_H
10 #define USETITER_H
11
12 #include "unicode/utypes.h"
13
14 #if U_SHOW_CPLUSPLUS_API
15
16 #include "unicode/uobject.h"
17 #include "unicode/unistr.h"
18
24 U_NAMESPACE_BEGIN
25
26 class UnicodeSet;
27 class UnicodeString;
28
66 class U_COMMON_API UnicodeSetIterator : public UObject {
67
68 protected:
69
76 enum { IS_STRING = -1 };
77
83 UChar32 codepoint;
84
94 UChar32 codepointEnd;
95
102 const UnicodeString* string;
103
104 public:
105
112 UnicodeSetIterator(const UnicodeSet& set);
113
120 UnicodeSetIterator();
121
126 virtual ~UnicodeSetIterator();
127
143 inline UBool isString() const;
144
150 inline UChar32 getCodepoint() const;
151
158 inline UChar32 getCodepointEnd() const;
159
171 const UnicodeString& getString();
172
195 UBool next();
196
216 UBool nextRange();
217
225 void reset(const UnicodeSet& set);
226
231 void reset();
232
238 static UClassID U_EXPORT2 getStaticClassID();
239
245 virtual UClassID getDynamicClassID() const;
246
247 // ======================= PRIVATES ===========================
248
249 protected:
250
251 // endElement and nextElements are really UChar32's, but we keep
252 // them as signed int32_t's so we can do comparisons with
253 // endElement set to -1. Leave them as int32_t's.
257 const UnicodeSet* set;
261 int32_t endRange;
265 int32_t range;
269 int32_t endElement;
273 int32_t nextElement;
274 //UBool abbreviated;
278 int32_t nextString;
282 int32_t stringCount;
283
289 UnicodeString *cpString;
290
294 UnicodeSetIterator(const UnicodeSetIterator&); // disallow
295
299 UnicodeSetIterator& operator=(const UnicodeSetIterator&); // disallow
300
304 virtual void loadRange(int32_t range);
305
306 };
307
308 inline UBool UnicodeSetIterator::isString() const {
309 return codepoint == (UChar32)IS_STRING;
310 }
311
312 inline UChar32 UnicodeSetIterator::getCodepoint() const {
313 return codepoint;
314 }
315
316 inline UChar32 UnicodeSetIterator::getCodepointEnd() const {
317 return codepointEnd;
318 }
319
320
321 U_NAMESPACE_END
322
323 #endif /* U_SHOW_CPLUSPLUS_API */
324
325 #endif
icu::UObject
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:223
icu::UnicodeSetIterator
UnicodeSetIterator iterates over the contents of a UnicodeSet.
Definition: usetiter.h:66
icu::UnicodeSetIterator::next
UBool next()
Advances the iteration position to the next element in the set, which can be either a single code poi...
icu::UnicodeSetIterator::UnicodeSetIterator
UnicodeSetIterator(const UnicodeSet &set)
Create an iterator over the given set.
icu::UnicodeSetIterator::nextElement
int32_t nextElement
Next element.
Definition: usetiter.h:273
icu::UnicodeSetIterator::reset
void reset()
Resets this iterator to the start of the set.
icu::UnicodeSetIterator::loadRange
virtual void loadRange(int32_t range)
Load range.
icu::UnicodeSetIterator::codepointEnd
UChar32 codepointEnd
When iterating over ranges using nextRange(), codepointEnd contains the inclusive end of the iteratio...
Definition: usetiter.h:94
icu::UnicodeSetIterator::getDynamicClassID
virtual UClassID getDynamicClassID() const
ICU "poor man's RTTI", returns a UClassID for the actual class.
icu::UnicodeSetIterator::set
const UnicodeSet * set
The set.
Definition: usetiter.h:257
icu::UnicodeSetIterator::nextRange
UBool nextRange()
Returns the next element in the set, either a code point range or a string.
icu::UnicodeSetIterator::endRange
int32_t endRange
End range.
Definition: usetiter.h:261
icu::UnicodeSetIterator::cpString
UnicodeString * cpString
Points to the string to use when the caller asks for a string and the current iteration item is a cod...
Definition: usetiter.h:289
icu::UnicodeSetIterator::getString
const UnicodeString & getString()
Returns the current string, if isString() returned true.
icu::UnicodeSetIterator::UnicodeSetIterator
UnicodeSetIterator(const UnicodeSetIterator &)
Copy constructor.
icu::UnicodeSetIterator::reset
void reset(const UnicodeSet &set)
Sets this iterator to visit the elements of the given set and resets it to the start of that set.
icu::UnicodeSetIterator::range
int32_t range
Range.
Definition: usetiter.h:265
icu::UnicodeSetIterator::nextString
int32_t nextString
Next string.
Definition: usetiter.h:278
icu::UnicodeSetIterator::codepoint
UChar32 codepoint
Current code point, or the special value IS_STRING, if the iterator points to a string.
Definition: usetiter.h:83
icu::UnicodeSetIterator::getStaticClassID
static UClassID getStaticClassID()
ICU "poor man's RTTI", returns a UClassID for this class.
icu::UnicodeSetIterator::string
const UnicodeString * string
If codepoint == IS_STRING, then string points to the current string.
Definition: usetiter.h:102
icu::UnicodeSetIterator::~UnicodeSetIterator
virtual ~UnicodeSetIterator()
Destructor.
icu::UnicodeSetIterator::stringCount
int32_t stringCount
String count.
Definition: usetiter.h:282
icu::UnicodeSetIterator::UnicodeSetIterator
UnicodeSetIterator()
Create an iterator over nothing.
icu::UnicodeSetIterator::endElement
int32_t endElement
End element.
Definition: usetiter.h:269
icu::UnicodeSetIterator::operator=
UnicodeSetIterator & operator=(const UnicodeSetIterator &)
Assignment operator.
icu::UnicodeSet
A mutable set of Unicode characters and multicharacter strings.
Definition: uniset.h:279
icu::UnicodeString
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:296
UChar32
int32_t UChar32
Define UChar32 as a type for single Unicode code points.
Definition: umachine.h:467
UBool
int8_t UBool
The ICU boolean type, a signed-byte integer.
Definition: umachine.h:269
unistr.h
C++ API: Unicode String.
uobject.h
C++ API: Common ICU base class UObject.
UClassID
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
Definition: uobject.h:96
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
U_COMMON_API
#define U_COMMON_API
Set to export library symbols from inside the common library, and to import them from outside.
Definition: utypes.h:300