00001 /* 00002 ********************************************************************** 00003 * Copyright (c) 2002, International Business Machines 00004 * Corporation and others. All Rights Reserved. 00005 ********************************************************************** 00006 * $Source: /usr/cvs/icu/icu/source/common/unicode/usetiter.h,v $ 00007 * $Revision: 1.5 $ 00008 ********************************************************************** 00009 */ 00010 #ifndef USETITER_H 00011 #define USETITER_H 00012 00013 #include "unicode/utypes.h" 00014 #include "unicode/uobject.h" 00015 #include "unicode/unistr.h" 00016 00017 U_NAMESPACE_BEGIN 00018 00019 class UnicodeSet; 00020 class UnicodeString; 00021 00054 class U_COMMON_API UnicodeSetIterator : public UObject { 00055 00056 protected: 00057 00063 enum { IS_STRING = -1 }; 00064 00069 UChar32 codepoint; 00070 00079 UChar32 codepointEnd; 00080 00086 const UnicodeString* string; 00087 00088 public: 00089 00095 UnicodeSetIterator(const UnicodeSet& set); 00096 00102 UnicodeSetIterator(); 00103 00107 virtual ~UnicodeSetIterator(); 00108 00118 inline UBool isString() const; 00119 00124 inline UChar32 getCodepoint() const; 00125 00131 inline UChar32 getCodepointEnd() const; 00132 00137 inline const UnicodeString& getString() const; 00138 00157 UBool next(); 00158 00178 UBool nextRange(); 00179 00186 void reset(const UnicodeSet& set); 00187 00191 void reset(); 00192 00198 virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } 00199 00205 static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } 00206 00207 // ======================= PRIVATES =========================== 00208 00209 protected: 00210 00211 // endElement and nextElements are really UChar32's, but we keep 00212 // them as signed int32_t's so we can do comparisons with 00213 // endElement set to -1. Leave them as int32_t's. 00214 const UnicodeSet* set; 00215 int32_t endRange; 00216 int32_t range; 00217 int32_t endElement; 00218 int32_t nextElement; 00219 //UBool abbreviated; 00220 int32_t nextString; 00221 int32_t stringCount; 00222 00223 UnicodeSetIterator(const UnicodeSetIterator&); // disallow 00224 00225 UnicodeSetIterator& operator=(const UnicodeSetIterator&); // disallow 00226 00227 virtual void loadRange(int32_t range); 00228 00229 private: 00230 00235 static const char fgClassID; 00236 }; 00237 00238 inline UBool UnicodeSetIterator::isString() const { 00239 return codepoint == IS_STRING; 00240 } 00241 00242 inline UChar32 UnicodeSetIterator::getCodepoint() const { 00243 return codepoint; 00244 } 00245 00246 inline UChar32 UnicodeSetIterator::getCodepointEnd() const { 00247 return codepointEnd; 00248 } 00249 00250 inline const UnicodeString& UnicodeSetIterator::getString() const { 00251 return *string; 00252 } 00253 00254 U_NAMESPACE_END 00255 00256 #endif