00001
00002
00003
00004
00005
00006
00007
00008
00009
00033 #ifndef COLEITR_H
00034 #define COLEITR_H
00035
00036 #include "unicode/utypes.h"
00037
00038 #if !UCONFIG_NO_COLLATION
00039
00040 #include "unicode/unistr.h"
00041 #include "unicode/uobject.h"
00042
00043 struct UCollationElements;
00044 struct UHashtable;
00045
00046 U_NAMESPACE_BEGIN
00047
00048 struct CollationData;
00049
00050 class CharacterIterator;
00051 class CollationIterator;
00052 class RuleBasedCollator;
00053 class UCollationPCE;
00054 class UVector32;
00055
00119 class U_I18N_API CollationElementIterator U_FINAL : public UObject {
00120 public:
00121
00122
00123
00124 enum {
00129 NULLORDER = (int32_t)0xffffffff
00130 };
00131
00132
00133
00140 CollationElementIterator(const CollationElementIterator& other);
00141
00146 virtual ~CollationElementIterator();
00147
00148
00149
00157 UBool operator==(const CollationElementIterator& other) const;
00158
00166 UBool operator!=(const CollationElementIterator& other) const;
00167
00172 void reset(void);
00173
00181 int32_t next(UErrorCode& status);
00182
00190 int32_t previous(UErrorCode& status);
00191
00198 static inline int32_t primaryOrder(int32_t order);
00199
00206 static inline int32_t secondaryOrder(int32_t order);
00207
00214 static inline int32_t tertiaryOrder(int32_t order);
00215
00225 int32_t getMaxExpansion(int32_t order) const;
00226
00233 int32_t strengthOrder(int32_t order) const;
00234
00241 void setText(const UnicodeString& str, UErrorCode& status);
00242
00249 void setText(CharacterIterator& str, UErrorCode& status);
00250
00257 static inline UBool isIgnorable(int32_t order);
00258
00264 int32_t getOffset(void) const;
00265
00273 void setOffset(int32_t newOffset, UErrorCode& status);
00274
00280 virtual UClassID getDynamicClassID() const;
00281
00287 static UClassID U_EXPORT2 getStaticClassID();
00288
00289 #ifndef U_HIDE_INTERNAL_API
00290
00291 static inline CollationElementIterator *fromUCollationElements(UCollationElements *uc) {
00292 return reinterpret_cast<CollationElementIterator *>(uc);
00293 }
00295 static inline const CollationElementIterator *fromUCollationElements(const UCollationElements *uc) {
00296 return reinterpret_cast<const CollationElementIterator *>(uc);
00297 }
00299 inline UCollationElements *toUCollationElements() {
00300 return reinterpret_cast<UCollationElements *>(this);
00301 }
00303 inline const UCollationElements *toUCollationElements() const {
00304 return reinterpret_cast<const UCollationElements *>(this);
00305 }
00306 #endif // U_HIDE_INTERNAL_API
00307
00308 private:
00309 friend class RuleBasedCollator;
00310 friend class UCollationPCE;
00311
00321 CollationElementIterator(const UnicodeString& sourceText,
00322 const RuleBasedCollator* order, UErrorCode& status);
00323
00324
00325
00326
00327
00328
00329
00330
00331
00341 CollationElementIterator(const CharacterIterator& sourceText,
00342 const RuleBasedCollator* order, UErrorCode& status);
00343
00349 const CollationElementIterator&
00350 operator=(const CollationElementIterator& other);
00351
00352 CollationElementIterator();
00353
00355 inline int8_t normalizeDir() const { return dir_ == 1 ? 0 : dir_; }
00356
00357 static UHashtable *computeMaxExpansions(const CollationData *data, UErrorCode &errorCode);
00358
00359 static int32_t getMaxExpansion(const UHashtable *maxExpansions, int32_t order);
00360
00361
00362
00363 CollationIterator *iter_;
00364 const RuleBasedCollator *rbc_;
00365 uint32_t otherHalf_;
00370 int8_t dir_;
00376 UVector32 *offsets_;
00377
00378 UnicodeString string_;
00379 };
00380
00381
00382
00383 inline int32_t CollationElementIterator::primaryOrder(int32_t order)
00384 {
00385 return (order >> 16) & 0xffff;
00386 }
00387
00388 inline int32_t CollationElementIterator::secondaryOrder(int32_t order)
00389 {
00390 return (order >> 8) & 0xff;
00391 }
00392
00393 inline int32_t CollationElementIterator::tertiaryOrder(int32_t order)
00394 {
00395 return order & 0xff;
00396 }
00397
00398 inline UBool CollationElementIterator::isIgnorable(int32_t order)
00399 {
00400 return (order & 0xffff0000) == 0;
00401 }
00402
00403 U_NAMESPACE_END
00404
00405 #endif
00406
00407 #endif