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 00014 #if U_SHOW_CPLUSPLUS_API 00015 00016 #include "unicode/uobject.h" 00017 #include "unicode/unistr.h" 00018 00024 U_NAMESPACE_BEGIN 00025 00026 class UnicodeSet; 00027 class UnicodeString; 00028 00066 class U_COMMON_API UnicodeSetIterator : public UObject { 00067 00068 protected: 00069 00076 enum { IS_STRING = -1 }; 00077 00083 UChar32 codepoint; 00084 00094 UChar32 codepointEnd; 00095 00102 const UnicodeString* string; 00103 00104 public: 00105 00112 UnicodeSetIterator(const UnicodeSet& set); 00113 00120 UnicodeSetIterator(); 00121 00126 virtual ~UnicodeSetIterator(); 00127 00143 inline UBool isString() const; 00144 00150 inline UChar32 getCodepoint() const; 00151 00158 inline UChar32 getCodepointEnd() const; 00159 00171 const UnicodeString& getString(); 00172 00195 UBool next(); 00196 00216 UBool nextRange(); 00217 00225 void reset(const UnicodeSet& set); 00226 00231 void reset(); 00232 00238 static UClassID U_EXPORT2 getStaticClassID(); 00239 00245 virtual UClassID getDynamicClassID() const; 00246 00247 // ======================= PRIVATES =========================== 00248 00249 protected: 00250 00251 // endElement and nextElements are really UChar32's, but we keep 00252 // them as signed int32_t's so we can do comparisons with 00253 // endElement set to -1. Leave them as int32_t's. 00257 const UnicodeSet* set; 00261 int32_t endRange; 00265 int32_t range; 00269 int32_t endElement; 00273 int32_t nextElement; 00274 //UBool abbreviated; 00278 int32_t nextString; 00282 int32_t stringCount; 00283 00289 UnicodeString *cpString; 00290 00294 UnicodeSetIterator(const UnicodeSetIterator&); // disallow 00295 00299 UnicodeSetIterator& operator=(const UnicodeSetIterator&); // disallow 00300 00304 virtual void loadRange(int32_t range); 00305 00306 }; 00307 00308 inline UBool UnicodeSetIterator::isString() const { 00309 return codepoint == (UChar32)IS_STRING; 00310 } 00311 00312 inline UChar32 UnicodeSetIterator::getCodepoint() const { 00313 return codepoint; 00314 } 00315 00316 inline UChar32 UnicodeSetIterator::getCodepointEnd() const { 00317 return codepointEnd; 00318 } 00319 00320 00321 U_NAMESPACE_END 00322 00323 #endif /* U_SHOW_CPLUSPLUS_API */ 00324 00325 #endif
1.6.1