/* ***************************************************************************************** * 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(); UBool operator==(const CollationElementIterator& other) const; UBool 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 UBool 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( UChar32 ch, UErrorCode& status); int32_t prevContractChar( UChar32 ch, UErrorCode& status); inline static UBool isThaiPreVowel(UChar32 ch); inline static UBool isThaiBaseConsonant(UChar32 ch); VectorOfInt* makeReorderedBuffer(UChar colFirst, int32_t lastValue, VectorOfInt* lastExpansion, UBool 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 UBool CollationElementIterator::isIgnorable(int32_t order) { return (primaryOrder(order) == 0); } inline UBool CollationElementIterator::isThaiPreVowel(UChar32 ch) { return ((uint32_t)ch - 0xe40) <= (0xe44 - 0xe40); } inline UBool CollationElementIterator::isThaiBaseConsonant(UChar32 ch) { return ((uint32_t)ch - 0xe01) <= (0xe2e - 0xe01); } #endif