00001 // © 2016 and later: Unicode, Inc. and others. 00002 // License & terms of use: http://www.unicode.org/copyright.html 00003 /* 00004 ********************************************************************** 00005 * Copyright (c) 2002-2014, International Business Machines 00006 * Corporation and others. All Rights Reserved. 00007 ********************************************************************** 00008 */ 00009 #ifndef USETITER_H 00010 #define USETITER_H 00011 00012 #include "unicode/utypes.h" 00013 #include "unicode/uobject.h" 00014 #include "unicode/unistr.h" 00015 00021 U_NAMESPACE_BEGIN 00022 00023 class UnicodeSet; 00024 class UnicodeString; 00025 00063 class U_COMMON_API UnicodeSetIterator : public UObject { 00064 00065 protected: 00066 00073 enum { IS_STRING = -1 }; 00074 00080 UChar32 codepoint; 00081 00091 UChar32 codepointEnd; 00092 00099 const UnicodeString* string; 00100 00101 public: 00102 00109 UnicodeSetIterator(const UnicodeSet& set); 00110 00117 UnicodeSetIterator(); 00118 00123 virtual ~UnicodeSetIterator(); 00124 00140 inline UBool isString() const; 00141 00147 inline UChar32 getCodepoint() const; 00148 00155 inline UChar32 getCodepointEnd() const; 00156 00168 const UnicodeString& getString(); 00169 00192 UBool next(); 00193 00213 UBool nextRange(); 00214 00222 void reset(const UnicodeSet& set); 00223 00228 void reset(); 00229 00235 static UClassID U_EXPORT2 getStaticClassID(); 00236 00242 virtual UClassID getDynamicClassID() const; 00243 00244 // ======================= PRIVATES =========================== 00245 00246 protected: 00247 00248 // endElement and nextElements are really UChar32's, but we keep 00249 // them as signed int32_t's so we can do comparisons with 00250 // endElement set to -1. Leave them as int32_t's. 00254 const UnicodeSet* set; 00258 int32_t endRange; 00262 int32_t range; 00266 int32_t endElement; 00270 int32_t nextElement; 00271 //UBool abbreviated; 00275 int32_t nextString; 00279 int32_t stringCount; 00280 00286 UnicodeString *cpString; 00287 00291 UnicodeSetIterator(const UnicodeSetIterator&); // disallow 00292 00296 UnicodeSetIterator& operator=(const UnicodeSetIterator&); // disallow 00297 00301 virtual void loadRange(int32_t range); 00302 00303 }; 00304 00305 inline UBool UnicodeSetIterator::isString() const { 00306 return codepoint == (UChar32)IS_STRING; 00307 } 00308 00309 inline UChar32 UnicodeSetIterator::getCodepoint() const { 00310 return codepoint; 00311 } 00312 00313 inline UChar32 UnicodeSetIterator::getCodepointEnd() const { 00314 return codepointEnd; 00315 } 00316 00317 00318 U_NAMESPACE_END 00319 00320 #endif
1.6.1