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
24U_NAMESPACE_BEGIN
25
26class UnicodeSet;
27class UnicodeString;
28
67
68 protected:
69
76 enum { IS_STRING = -1 };
77
84
95
103
104 public:
105
113
121
127
143 inline UBool isString() const;
144
150 inline UChar32 getCodepoint() const;
151
158 inline UChar32 getCodepointEnd() const;
159
172
196
217
225 void reset(const UnicodeSet& set);
226
231 void reset();
232
239
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.
274 //UBool abbreviated;
283
290
295
300
304 virtual void loadRange(int32_t range);
305
306};
307
308inline UBool UnicodeSetIterator::isString() const {
309 return codepoint == (UChar32)IS_STRING;
310}
311
312inline UChar32 UnicodeSetIterator::getCodepoint() const {
313 return codepoint;
314}
315
316inline UChar32 UnicodeSetIterator::getCodepointEnd() const {
317 return codepointEnd;
318}
319
320
322
323#endif /* U_SHOW_CPLUSPLUS_API */
324
325#endif
"Smart pointer" base class; do not use directly: use LocalPointer etc.
UObject is the common ICU "boilerplate" class.
Definition uobject.h:223
UnicodeSetIterator iterates over the contents of a UnicodeSet.
Definition usetiter.h:66
UBool next()
Advances the iteration position to the next element in the set, which can be either a single code poi...
UnicodeSetIterator(const UnicodeSet &set)
Create an iterator over the given set.
UnicodeSetIterator & operator=(const UnicodeSetIterator &)
Assignment operator.
int32_t nextElement
Next element.
Definition usetiter.h:273
void reset()
Resets this iterator to the start of the set.
virtual void loadRange(int32_t range)
Load range.
UChar32 codepointEnd
When iterating over ranges using nextRange(), codepointEnd contains the inclusive end of the iteratio...
Definition usetiter.h:94
virtual UClassID getDynamicClassID() const
ICU "poor man's RTTI", returns a UClassID for the actual class.
const UnicodeSet * set
The set.
Definition usetiter.h:257
UBool nextRange()
Returns the next element in the set, either a code point range or a string.
int32_t endRange
End range.
Definition usetiter.h:261
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
UnicodeSetIterator(const UnicodeSetIterator &)
Copy constructor.
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.
int32_t range
Range.
Definition usetiter.h:265
int32_t nextString
Next string.
Definition usetiter.h:278
UChar32 codepoint
Current code point, or the special value IS_STRING, if the iterator points to a string.
Definition usetiter.h:83
static UClassID getStaticClassID()
ICU "poor man's RTTI", returns a UClassID for this class.
const UnicodeString * string
If codepoint == IS_STRING, then string points to the current string.
Definition usetiter.h:102
virtual ~UnicodeSetIterator()
Destructor.
int32_t stringCount
String count.
Definition usetiter.h:282
UnicodeSetIterator()
Create an iterator over nothing.
const UnicodeString & getString()
Returns the current string, if isString() returned true.
int32_t endElement
End element.
Definition usetiter.h:269
A mutable set of Unicode characters and multicharacter strings.
Definition uniset.h:279
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition unistr.h:296
int32_t UChar32
Define UChar32 as a type for single Unicode code points.
Definition umachine.h:467
int8_t UBool
The ICU boolean type, a signed-byte integer.
Definition umachine.h:269
C++ API: Unicode String.
C++ API: Common ICU base class UObject.
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
Definition uobject.h:96
Basic definitions for ICU, for both C and C++ APIs.
#define U_COMMON_API
Set to export library symbols from inside the common library, and to import them from outside.
Definition utypes.h:300