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/unistr.h" 00031 #include "unicode/tblcoll.h" 00032 #include "unicode/ucoleitr.h" 00033 00034 // #include "tables.h" 00035 // #include "unicode/chariter.h" 00036 00037 // have to do this because the include path in the main project does not have 00038 // tables.h. 00039 // class VectorOfInt; 00040 // class Normalizer; 00041 // class VectorOfPToContractElement; 00042 // class RuleBasedCollator; 00043 00044 // typedef void * UCollationElements; 00045 // struct UCollationElements; 00046 typedef struct UCollationElements UCollationElements; 00047 00122 class U_I18N_API CollationElementIterator 00123 { 00124 public: 00125 00126 // CollationElementIterator public data member ------------------------------ 00127 00131 static int32_t const NULLORDER; 00132 00133 // CollationElementIterator public constructor/destructor ------------------- 00134 00138 CollationElementIterator(const CollationElementIterator& other); 00139 00143 ~CollationElementIterator(); 00144 00145 // CollationElementIterator public methods ---------------------------------- 00146 00150 UBool operator==(const CollationElementIterator& other) const; 00151 00155 UBool operator!=(const CollationElementIterator& other) const; 00156 00160 void reset(void); 00161 00168 int32_t next(UErrorCode& status); 00169 00176 int32_t previous(UErrorCode& status); 00177 00183 static int32_t primaryOrder(int32_t order); 00184 00190 static int32_t secondaryOrder(int32_t order); 00191 00197 static int32_t tertiaryOrder(int32_t order); 00198 00207 int32_t getMaxExpansion(int32_t order) const; 00208 00214 int32_t strengthOrder(int32_t order) const; 00215 00221 void setText(const UnicodeString& str, UErrorCode& status); 00222 00228 void setText(CharacterIterator& str, UErrorCode& status); 00229 00235 static UBool isIgnorable(int32_t order); 00236 00241 UTextOffset getOffset(void) const; 00242 00249 void setOffset(UTextOffset newOffset, UErrorCode& status); 00250 00251 protected: 00252 00253 // CollationElementIterator protected constructors -------------------------- 00254 00255 friend class RuleBasedCollator; 00256 00269 CollationElementIterator(const UnicodeString& sourceText, 00270 const RuleBasedCollator* order, UErrorCode& status); 00271 00284 CollationElementIterator(const CharacterIterator& sourceText, 00285 const RuleBasedCollator* order, UErrorCode& status); 00286 00287 // CollationElementIterator protected methods ------------------------------- 00288 00292 const CollationElementIterator& 00293 operator=(const CollationElementIterator& other); 00294 00295 private: 00296 00297 // friend class RuleBasedCollator; 00298 00299 // CollationElementIterator private data members ---------------------------- 00300 00301 // static const int32_t UNMAPPEDCHARVALUE; 00302 00303 /* 00304 Normalizer* text; // owning 00305 00306 VectorOfInt* bufferAlias; // not owned 00307 */ 00308 00316 // VectorOfInt* ownBuffer; 00317 00324 /* 00325 VectorOfInt* reorderBuffer; 00326 00327 int32_t expIndex; 00328 UnicodeString key; 00329 const RuleBasedCollator* orderAlias; 00330 */ 00331 00335 UCollationElements *m_data_; 00336 00340 UBool isDataOwned_; 00341 00342 // CollationElementIterator private constructor/destructor ------------------ 00343 00347 /* CollationElementIterator(); */ 00348 00353 CollationElementIterator(const RuleBasedCollator* order); 00354 00355 // CollationElementIterator private methods --------------------------------- 00356 00364 // int32_t nextContractChar(UChar32 ch, UErrorCode& status); 00365 00374 // int32_t prevContractChar(UChar32 ch, UErrorCode& status); 00375 00376 // inline static UBool isThaiPreVowel(UChar32 ch); 00377 00378 // inline static UBool isThaiBaseConsonant(UChar32 ch); 00379 00380 /* 00381 VectorOfInt* makeReorderedBuffer(UChar colFirst, int32_t lastValue, 00382 VectorOfInt* lastExpansion, UBool forward, 00383 UErrorCode& status); 00384 */ 00385 }; 00386 00387 // CollationElementIterator inline method defination -------------------------- 00388 00394 inline int32_t CollationElementIterator::primaryOrder(int32_t order) 00395 { 00396 order &= RuleBasedCollator::PRIMARYORDERMASK; 00397 return (order >> RuleBasedCollator::PRIMARYORDERSHIFT); 00398 } 00399 00405 inline int32_t CollationElementIterator::secondaryOrder(int32_t order) 00406 { 00407 order = order & RuleBasedCollator::SECONDARYORDERMASK; 00408 return (order >> RuleBasedCollator::SECONDARYORDERSHIFT); 00409 } 00410 00416 inline int32_t CollationElementIterator::tertiaryOrder(int32_t order) 00417 { 00418 return (order &= RuleBasedCollator::TERTIARYORDERMASK); 00419 } 00420 00421 inline int32_t CollationElementIterator::getMaxExpansion(int32_t order) const 00422 { 00423 return ucol_getMaxExpansion(m_data_, (uint32_t)order); 00424 } 00425 00426 inline UBool CollationElementIterator::isIgnorable(int32_t order) 00427 { 00428 return (primaryOrder(order) == RuleBasedCollator::PRIMIGNORABLE); 00429 } 00430 00435 /* 00436 inline UBool CollationElementIterator::isThaiPreVowel(UChar32 ch) 00437 { 00438 return ((uint32_t)ch - 0xe40) <= (0xe44 - 0xe40); 00439 } 00440 */ 00441 00445 /* 00446 inline UBool CollationElementIterator::isThaiBaseConsonant(UChar32 ch) 00447 { 00448 return ((uint32_t)ch - 0xe01) <= (0xe2e - 0xe01); 00449 } 00450 */ 00451 00452 #endif