00001 /* 00002 ********************************************************************** 00003 * Copyright (c) 2002-2008, International Business Machines 00004 * Corporation and others. All Rights Reserved. 00005 ********************************************************************** 00006 */ 00007 #ifndef USETITER_H 00008 #define USETITER_H 00009 00010 #include "unicode/utypes.h" 00011 #include "unicode/uobject.h" 00012 #include "unicode/unistr.h" 00013 00019 U_NAMESPACE_BEGIN 00020 00021 class UnicodeSet; 00022 class UnicodeString; 00023 00061 class U_COMMON_API UnicodeSetIterator : public UObject { 00062 00063 protected: 00064 00071 enum { IS_STRING = -1 }; 00072 00078 UChar32 codepoint; 00079 00089 UChar32 codepointEnd; 00090 00097 const UnicodeString* string; 00098 00099 public: 00100 00107 UnicodeSetIterator(const UnicodeSet& set); 00108 00115 UnicodeSetIterator(); 00116 00121 virtual ~UnicodeSetIterator(); 00122 00138 inline UBool isString() const; 00139 00145 inline UChar32 getCodepoint() const; 00146 00153 inline UChar32 getCodepointEnd() const; 00154 00166 const UnicodeString& getString(); 00167 00190 UBool next(); 00191 00211 UBool nextRange(); 00212 00220 void reset(const UnicodeSet& set); 00221 00226 void reset(); 00227 00233 static UClassID U_EXPORT2 getStaticClassID(); 00234 00240 virtual UClassID getDynamicClassID() const; 00241 00242 // ======================= PRIVATES =========================== 00243 00244 protected: 00245 00246 // endElement and nextElements are really UChar32's, but we keep 00247 // them as signed int32_t's so we can do comparisons with 00248 // endElement set to -1. Leave them as int32_t's. 00252 const UnicodeSet* set; 00256 int32_t endRange; 00260 int32_t range; 00264 int32_t endElement; 00268 int32_t nextElement; 00269 //UBool abbreviated; 00273 int32_t nextString; 00277 int32_t stringCount; 00278 00284 UnicodeString *cpString; 00285 00289 UnicodeSetIterator(const UnicodeSetIterator&); // disallow 00290 00294 UnicodeSetIterator& operator=(const UnicodeSetIterator&); // disallow 00295 00299 virtual void loadRange(int32_t range); 00300 00301 }; 00302 00303 inline UBool UnicodeSetIterator::isString() const { 00304 return codepoint == (UChar32)IS_STRING; 00305 } 00306 00307 inline UChar32 UnicodeSetIterator::getCodepoint() const { 00308 return codepoint; 00309 } 00310 00311 inline UChar32 UnicodeSetIterator::getCodepointEnd() const { 00312 return codepointEnd; 00313 } 00314 00315 00316 U_NAMESPACE_END 00317 00318 #endif