00001
00002
00003
00004
00005
00006
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
00067 class U_COMMON_API UnicodeSetIterator final : public UObject {
00073 enum { IS_STRING = -1 };
00074
00079 UChar32 codepoint;
00080
00089 UChar32 codepointEnd;
00090
00096 const UnicodeString* string;
00097
00098 public:
00099
00106 UnicodeSetIterator(const UnicodeSet& set);
00107
00114 UnicodeSetIterator();
00115
00120 virtual ~UnicodeSetIterator();
00121
00137 inline UBool isString() const;
00138
00144 inline UChar32 getCodepoint() const;
00145
00152 inline UChar32 getCodepointEnd() const;
00153
00165 const UnicodeString& getString();
00166
00176 inline UnicodeSetIterator &skipToStrings() {
00177
00178 range = endRange;
00179 endElement = -1;
00180 nextElement = 0;
00181 return *this;
00182 }
00183
00206 UBool next();
00207
00227 UBool nextRange();
00228
00236 void reset(const UnicodeSet& set);
00237
00242 void reset();
00243
00249 static UClassID U_EXPORT2 getStaticClassID();
00250
00256 virtual UClassID getDynamicClassID() const override;
00257
00258
00259
00260 private:
00261
00262
00263
00264
00267 const UnicodeSet* set;
00270 int32_t endRange;
00273 int32_t range;
00276 int32_t endElement;
00279 int32_t nextElement;
00282 int32_t nextString;
00285 int32_t stringCount;
00286
00291 UnicodeString *cpString;
00292
00295 UnicodeSetIterator(const UnicodeSetIterator&) = delete;
00296
00299 UnicodeSetIterator& operator=(const UnicodeSetIterator&) = delete;
00300
00303 void loadRange(int32_t range);
00304 };
00305
00306 inline UBool UnicodeSetIterator::isString() const {
00307 return codepoint < 0;
00308 }
00309
00310 inline UChar32 UnicodeSetIterator::getCodepoint() const {
00311 return codepoint;
00312 }
00313
00314 inline UChar32 UnicodeSetIterator::getCodepointEnd() const {
00315 return codepointEnd;
00316 }
00317
00318
00319 U_NAMESPACE_END
00320
00321 #endif
00322
00323 #endif