ICU 66.0.1  66.0.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 
68  protected:
69 
76  enum { IS_STRING = -1 };
77 
84 
95 
103 
104  public:
105 
112  UnicodeSetIterator(const UnicodeSet& set);
113 
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 
290 
294  UnicodeSetIterator(const UnicodeSetIterator&); // disallow
295 
299  UnicodeSetIterator& operator=(const UnicodeSetIterator&); // disallow
300 
304  virtual void loadRange(int32_t range);
305 
306 };
307 
309  return codepoint == (UChar32)IS_STRING;
310 }
311 
313  return codepoint;
314 }
315 
317  return codepointEnd;
318 }
319 
320 
321 U_NAMESPACE_END
322 
323 #endif /* U_SHOW_CPLUSPLUS_API */
324 
325 #endif
const UnicodeString * string
If codepoint == IS_STRING, then string points to the current string.
Definition: usetiter.h:102
UChar32 codepoint
Current code point, or the special value IS_STRING, if the iterator points to a string.
Definition: usetiter.h:83
int32_t nextString
Next string.
Definition: usetiter.h:278
C++ API: Unicode String.
UnicodeSetIterator iterates over the contents of a UnicodeSet.
Definition: usetiter.h:66
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
Definition: uobject.h:96
UChar32 codepointEnd
When iterating over ranges using nextRange(), codepointEnd contains the inclusive end of the iteratio...
Definition: usetiter.h:94
UChar32 getCodepointEnd() const
Returns the end of the current code point range, if isString() returned false and nextRange() was cal...
Definition: usetiter.h:316
int32_t endElement
End element.
Definition: usetiter.h:269
UBool isString() const
Returns true if the current element is a string.
Definition: usetiter.h:308
UChar32 getCodepoint() const
Returns the current code point, if isString() returned false.
Definition: usetiter.h:312
int32_t range
Range.
Definition: usetiter.h:265
int32_t UChar32
Define UChar32 as a type for single Unicode code points.
Definition: umachine.h:425
virtual UClassID getDynamicClassID() const
ICU4C "poor man's RTTI", returns a UClassID for the actual ICU class.
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
A mutable set of Unicode characters and multicharacter strings.
Definition: uniset.h:281
C++ API: Common ICU base class UObject.
int32_t endRange
End range.
Definition: usetiter.h:261
int32_t stringCount
String count.
Definition: usetiter.h:282
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
int32_t nextElement
Next element.
Definition: usetiter.h:273
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:294
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:223
int8_t UBool
The ICU boolean type.
Definition: umachine.h:261