00001 /* 00002 ********************************************************************** 00003 * Copyright (c) 2002-2004, 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 00014 U_NAMESPACE_BEGIN 00015 00016 class UnicodeSet; 00017 class UnicodeString; 00018 00051 class U_COMMON_API UnicodeSetIterator : public UObject { 00052 00053 protected: 00054 00061 enum { IS_STRING = -1 }; 00062 00068 UChar32 codepoint; 00069 00079 UChar32 codepointEnd; 00080 00087 const UnicodeString* string; 00088 00089 public: 00090 00097 UnicodeSetIterator(const UnicodeSet& set); 00098 00105 UnicodeSetIterator(); 00106 00111 virtual ~UnicodeSetIterator(); 00112 00123 inline UBool isString() const; 00124 00130 inline UChar32 getCodepoint() const; 00131 00138 inline UChar32 getCodepointEnd() const; 00139 00145 inline const UnicodeString& getString() const; 00146 00166 UBool next(); 00167 00188 UBool nextRange(); 00189 00197 void reset(const UnicodeSet& set); 00198 00203 void reset(); 00204 00210 static UClassID U_EXPORT2 getStaticClassID(); 00211 00217 virtual UClassID getDynamicClassID() const; 00218 00219 // ======================= PRIVATES =========================== 00220 00221 protected: 00222 00223 // endElement and nextElements are really UChar32's, but we keep 00224 // them as signed int32_t's so we can do comparisons with 00225 // endElement set to -1. Leave them as int32_t's. 00229 const UnicodeSet* set; 00233 int32_t endRange; 00237 int32_t range; 00241 int32_t endElement; 00245 int32_t nextElement; 00246 //UBool abbreviated; 00250 int32_t nextString; 00254 int32_t stringCount; 00255 00259 UnicodeSetIterator(const UnicodeSetIterator&); // disallow 00260 00264 UnicodeSetIterator& operator=(const UnicodeSetIterator&); // disallow 00265 00269 virtual void loadRange(int32_t range); 00270 00271 }; 00272 00273 inline UBool UnicodeSetIterator::isString() const { 00274 return codepoint == (UChar32)IS_STRING; 00275 } 00276 00277 inline UChar32 UnicodeSetIterator::getCodepoint() const { 00278 return codepoint; 00279 } 00280 00281 inline UChar32 UnicodeSetIterator::getCodepointEnd() const { 00282 return codepointEnd; 00283 } 00284 00285 inline const UnicodeString& UnicodeSetIterator::getString() const { 00286 return *string; 00287 } 00288 00289 U_NAMESPACE_END 00290 00291 #endif