ICU 65.1 65.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::UnicodeSetIterator::string
const UnicodeString * string
If codepoint == IS_STRING, then string points to the current string.
Definition: usetiter.h:102
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::nextString
int32_t nextString
Next string.
Definition: usetiter.h:278
unistr.h
C++ API: Unicode String.
icu::UnicodeSetIterator
UnicodeSetIterator iterates over the contents of a UnicodeSet.
Definition: usetiter.h:66
UClassID
void * UClassID
UClassID is used to identify classes without using the compiler&#39;s RTTI.
Definition: uobject.h:96
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::getCodepointEnd
UChar32 getCodepointEnd() const
Returns the end of the current code point range, if isString() returned false and nextRange() was cal...
Definition: usetiter.h:316
icu::UnicodeSetIterator::endElement
int32_t endElement
End element.
Definition: usetiter.h:269
icu::UnicodeSetIterator::isString
UBool isString() const
Returns true if the current element is a string.
Definition: usetiter.h:308
icu::UnicodeSetIterator::getCodepoint
UChar32 getCodepoint() const
Returns the current code point, if isString() returned false.
Definition: usetiter.h:312
icu::UnicodeSetIterator::range
int32_t range
Range.
Definition: usetiter.h:265
UChar32
int32_t UChar32
Define UChar32 as a type for single Unicode code points.
Definition: umachine.h:425
icu::UObject::getDynamicClassID
virtual UClassID getDynamicClassID() const
ICU4C "poor man&#39;s RTTI", returns a UClassID for the actual ICU class.
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::UnicodeSet
A mutable set of Unicode characters and multicharacter strings.
Definition: uniset.h:281
uobject.h
C++ API: Common ICU base class UObject.
icu::UnicodeSetIterator::endRange
int32_t endRange
End range.
Definition: usetiter.h:261
icu::UnicodeSetIterator::stringCount
int32_t stringCount
String count.
Definition: usetiter.h:282
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
icu::UnicodeSetIterator::nextElement
int32_t nextElement
Next element.
Definition: usetiter.h:273
icu::UnicodeString
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:294
icu::UObject
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:223
UBool
int8_t UBool
The ICU boolean type.
Definition: umachine.h:261