ICU 71.1 71.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
67 class U_COMMON_API UnicodeSetIterator U_FINAL : public UObject {
73 enum { IS_STRING = -1 };
74
79 UChar32 codepoint;
80
89 UChar32 codepointEnd;
90
96 const UnicodeString* string;
97
98 public:
99
106 UnicodeSetIterator(const UnicodeSet& set);
107
114 UnicodeSetIterator();
115
120 virtual ~UnicodeSetIterator();
121
137 inline UBool isString() const;
138
144 inline UChar32 getCodepoint() const;
145
152 inline UChar32 getCodepointEnd() const;
153
165 const UnicodeString& getString();
166
167 #ifndef U_HIDE_DRAFT_API
168
177 inline UnicodeSetIterator &skipToStrings() {
178 // Finish code point/range iteration.
179 range = endRange;
180 endElement = -1;
181 nextElement = 0;
182 return *this;
183 }
184 #endif // U_HIDE_DRAFT_API
185
208 UBool next();
209
229 UBool nextRange();
230
238 void reset(const UnicodeSet& set);
239
244 void reset();
245
251 static UClassID U_EXPORT2 getStaticClassID();
252
258 virtual UClassID getDynamicClassID() const override;
259
260 // ======================= PRIVATES ===========================
261
262 private:
263
264 // endElement and nextElements are really UChar32's, but we keep
265 // them as signed int32_t's so we can do comparisons with
266 // endElement set to -1. Leave them as int32_t's.
269 const UnicodeSet* set;
272 int32_t endRange;
275 int32_t range;
278 int32_t endElement;
281 int32_t nextElement;
284 int32_t nextString;
287 int32_t stringCount;
288
293 UnicodeString *cpString;
294
297 UnicodeSetIterator(const UnicodeSetIterator&) = delete;
298
301 UnicodeSetIterator& operator=(const UnicodeSetIterator&) = delete;
302
305 void loadRange(int32_t range);
306 };
307
308 inline UBool UnicodeSetIterator::isString() const {
309 return codepoint < 0;
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
U_FINAL
#define U_FINAL
Definition: umachine.h:141
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
icu::UnicodeSet
A mutable set of Unicode characters and multicharacter strings.
Definition: uniset.h:285
UBool
int8_t UBool
The ICU boolean type, a signed-byte integer.
Definition: umachine.h:269
U_COMMON_API
#define U_COMMON_API
Definition: utypes.h:300
icu::UnicodeSetIterator::skipToStrings
UnicodeSetIterator & skipToStrings()
Skips over the remaining code points/ranges, if any.
Definition: usetiter.h:177
icu::UnicodeSetIterator
UnicodeSetIterator iterates over the contents of a UnicodeSet.
Definition: usetiter.h:67
icu::UnicodeString
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:295
UChar32
int32_t UChar32
Define UChar32 as a type for single Unicode code points.
Definition: umachine.h:467
icu::UObject
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:223
UClassID
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
Definition: uobject.h:96
icu::UObject::getDynamicClassID
virtual UClassID getDynamicClassID() const
ICU4C "poor man's RTTI", returns a UClassID for the actual ICU class.
uobject.h
C++ API: Common ICU base class UObject.
unistr.h
C++ API: Unicode String.