/* ***************************************************************************************** * Copyright (C) 1997-1999, International Business Machines * Corporation and others. All Rights Reserved. ***************************************************************************************** */ //=============================================================================== // // File coleitr.h // // // // Created by: Helena Shih // // Modification History: // // Date Name Description // // 8/18/97 helena Added internal API documentation. // 08/03/98 erm Synched with 1.2 version CollationElementIterator.java // 12/10/99 aliu Ported Thai collation support from Java. //=============================================================================== #ifndef COLEITR_H #define COLEITR_H #include "unicode/unistr.h" #include "unicode/tblcoll.h" #include "unicode/chariter.h" class Normalizer; class VectorOfPToContractElement; class RuleBasedCollator; class U_I18N_API CollationElementIterator { public: static int32_t const NULLORDER; ~CollationElementIterator(); virtual bool_t operator==(const CollationElementIterator& other) const; virtual bool_t operator!=(const CollationElementIterator& other) const; void reset(void); int32_t next(UErrorCode& status); int32_t previous(UErrorCode& status); static int32_t primaryOrder(int32_t order); static int32_t secondaryOrder(int32_t order); static int32_t tertiaryOrder(int32_t order); int32_t getMaxExpansion(int32_t order) const; public: int32_t strengthOrder(int32_t order) const; void setText(const UnicodeString& str, UErrorCode& status); void setText(CharacterIterator& str, UErrorCode& status); static bool_t isIgnorable(int32_t order); UTextOffset getOffset(void) const; void setOffset(UTextOffset newOffset, UErrorCode& status); /* CollationElementIterator should not be subclassed. */ protected: CollationElementIterator( const UnicodeString& sourceText, const RuleBasedCollator* order, UErrorCode& status); CollationElementIterator( const CharacterIterator& sourceText, const RuleBasedCollator* order, UErrorCode& status); const CollationElementIterator& operator=(const CollationElementIterator& other); public: CollationElementIterator(const CollationElementIterator& other); //============================================================ // privates //============================================================ private: CollationElementIterator(); CollationElementIterator(const RuleBasedCollator* order); int32_t nextContractChar( UChar ch, UErrorCode& status); int32_t prevContractChar( UChar ch, UErrorCode& status); inline static bool_t isThaiPreVowel(UChar ch); inline static bool_t isThaiBaseConsonant(UChar ch); VectorOfInt* makeReorderedBuffer(UChar colFirst, int32_t lastValue, VectorOfInt* lastExpansion, bool_t forward, UErrorCode& status); friend class RuleBasedCollator; static const int32_t UNMAPPEDCHARVALUE; Normalizer* text; // owning VectorOfInt* bufferAlias; // not owned VectorOfInt* ownBuffer; VectorOfInt* reorderBuffer; int32_t expIndex; UnicodeString key; const RuleBasedCollator* orderAlias; }; inline int32_t CollationElementIterator::primaryOrder(int32_t order) { order &= RuleBasedCollator::PRIMARYORDERMASK; return (order >> RuleBasedCollator::PRIMARYORDERSHIFT); } inline int32_t CollationElementIterator::secondaryOrder(int32_t order) { order = order & RuleBasedCollator::SECONDARYORDERMASK; return (order >> RuleBasedCollator::SECONDARYORDERSHIFT); } inline int32_t CollationElementIterator::tertiaryOrder(int32_t order) { return (order &= RuleBasedCollator::TERTIARYORDERMASK); } inline int32_t CollationElementIterator::getMaxExpansion(int32_t order) const { return orderAlias->getMaxExpansion(order); } inline bool_t CollationElementIterator::isIgnorable(int32_t order) { return (primaryOrder(order) == 0); } inline bool_t CollationElementIterator::isThaiPreVowel(UChar ch) { return (ch >= (UChar)0x0E40) && (ch <= (UChar)0X0E44); } inline bool_t CollationElementIterator::isThaiBaseConsonant(UChar ch) { return (ch >= (UChar)0x0E01) && (ch <= (UChar)0x0E2E); } #endif