00001 /* 00002 ****************************************************************************** 00003 * Copyright (C) 1997-2001, International Business Machines 00004 * Corporation and others. All Rights Reserved. 00005 ****************************************************************************** 00006 */ 00007 00027 #ifndef COLEITR_H 00028 #define COLEITR_H 00029 00030 #include "unicode/utypes.h" 00031 #include "unicode/uobject.h" 00032 #include "unicode/tblcoll.h" 00033 #include "unicode/ucoleitr.h" 00034 00035 typedef struct UCollationElements UCollationElements; 00036 00037 U_NAMESPACE_BEGIN 00038 00113 class U_I18N_API CollationElementIterator : public UObject { 00114 public: 00115 00116 // CollationElementIterator public data member ------------------------------ 00117 00122 static int32_t const NULLORDER; 00123 00124 // CollationElementIterator public constructor/destructor ------------------- 00125 00132 CollationElementIterator(const CollationElementIterator& other); 00133 00138 ~CollationElementIterator(); 00139 00140 // CollationElementIterator public methods ---------------------------------- 00141 00149 UBool operator==(const CollationElementIterator& other) const; 00150 00158 UBool operator!=(const CollationElementIterator& other) const; 00159 00164 void reset(void); 00165 00173 int32_t next(UErrorCode& status); 00174 00182 int32_t previous(UErrorCode& status); 00183 00190 static int32_t primaryOrder(int32_t order); 00191 00198 static int32_t secondaryOrder(int32_t order); 00199 00206 static int32_t tertiaryOrder(int32_t order); 00207 00217 int32_t getMaxExpansion(int32_t order) const; 00218 00225 int32_t strengthOrder(int32_t order) const; 00226 00233 void setText(const UnicodeString& str, UErrorCode& status); 00234 00241 void setText(CharacterIterator& str, UErrorCode& status); 00242 00249 static UBool isIgnorable(int32_t order); 00250 00256 int32_t getOffset(void) const; 00257 00265 void setOffset(int32_t newOffset, UErrorCode& status); 00266 00272 virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } 00273 00279 static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } 00280 00281 protected: 00282 00283 // CollationElementIterator protected constructors -------------------------- 00287 friend class RuleBasedCollator; 00288 00299 CollationElementIterator(const UnicodeString& sourceText, 00300 const RuleBasedCollator* order, UErrorCode& status); 00301 00312 CollationElementIterator(const CharacterIterator& sourceText, 00313 const RuleBasedCollator* order, UErrorCode& status); 00314 00315 // CollationElementIterator protected methods ------------------------------- 00316 00323 const CollationElementIterator& 00324 operator=(const CollationElementIterator& other); 00325 00326 private: 00327 00328 // CollationElementIterator private data members ---------------------------- 00329 00333 UCollationElements *m_data_; 00334 00338 UBool isDataOwned_; 00339 00344 static const char fgClassID; 00345 }; 00346 00347 // CollationElementIterator inline method defination -------------------------- 00348 00354 inline int32_t CollationElementIterator::primaryOrder(int32_t order) 00355 { 00356 order &= RuleBasedCollator::PRIMARYORDERMASK; 00357 return (order >> RuleBasedCollator::PRIMARYORDERSHIFT); 00358 } 00359 00365 inline int32_t CollationElementIterator::secondaryOrder(int32_t order) 00366 { 00367 order = order & RuleBasedCollator::SECONDARYORDERMASK; 00368 return (order >> RuleBasedCollator::SECONDARYORDERSHIFT); 00369 } 00370 00376 inline int32_t CollationElementIterator::tertiaryOrder(int32_t order) 00377 { 00378 return (order &= RuleBasedCollator::TERTIARYORDERMASK); 00379 } 00380 00381 inline int32_t CollationElementIterator::getMaxExpansion(int32_t order) const 00382 { 00383 return ucol_getMaxExpansion(m_data_, (uint32_t)order); 00384 } 00385 00386 inline UBool CollationElementIterator::isIgnorable(int32_t order) 00387 { 00388 return (primaryOrder(order) == RuleBasedCollator::PRIMIGNORABLE); 00389 } 00390 00391 U_NAMESPACE_END 00392 00393 #endif