Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

coleitr.h

Go to the documentation of this file.
00001 /*
00002 *****************************************************************************************
00003 *   Copyright (C) 1997-1999, International Business Machines
00004 *   Corporation and others.  All Rights Reserved.
00005 *****************************************************************************************
00006 */
00007 //===============================================================================
00008 //
00009 // File coleitr.h
00010 //
00011 // 
00012 //
00013 // Created by: Helena Shih
00014 //
00015 // Modification History:
00016 //
00017 //  Date         Name          Description
00018 //
00019 //  8/18/97     helena      Added internal API documentation.
00020 // 08/03/98        erm            Synched with 1.2 version CollationElementIterator.java
00021 // 12/10/99      aliu          Ported Thai collation support from Java.
00022 //===============================================================================
00023 
00024 #ifndef COLEITR_H
00025 #define COLEITR_H
00026 
00027 
00028 #include "unicode/unistr.h"
00029 #include "unicode/tblcoll.h"
00030 #include "unicode/chariter.h"
00031 
00032 class Normalizer;
00033 class VectorOfPToContractElement;
00034 class RuleBasedCollator;
00035 
00036 
00093 class U_I18N_API CollationElementIterator
00094 {
00095 public: 
00099     static  int32_t const   NULLORDER;
00100 
00104                                 ~CollationElementIterator();
00109     UBool          operator==(const CollationElementIterator& other) const;
00110 
00115     UBool          operator!=(const CollationElementIterator& other) const;
00116 
00121             void                reset(void);
00129             int32_t             next(UErrorCode& status);
00137             int32_t                 previous(UErrorCode& status);
00138 
00145     static  int32_t             primaryOrder(int32_t order);
00152     static  int32_t             secondaryOrder(int32_t order);
00159     static  int32_t             tertiaryOrder(int32_t order);
00168         int32_t                    getMaxExpansion(int32_t order) const;
00169 
00170 public:
00177            int32_t              strengthOrder(int32_t order) const;
00184             void                setText(const   UnicodeString&  str,
00185                                                 UErrorCode&      status);
00192             void                setText(CharacterIterator&  str,
00193                                         UErrorCode&            status);
00200     static    UBool              isIgnorable(int32_t order);
00206             UTextOffset          getOffset(void) const;
00214             void                setOffset(UTextOffset newOffset,
00215                                           UErrorCode& status);
00216     /* CollationElementIterator should not be subclassed. */
00217 protected:
00231                                 CollationElementIterator(   const   UnicodeString&  sourceText,
00232                                                             const   RuleBasedCollator*  order,
00233                                                             UErrorCode& status);
00234 
00248                                 CollationElementIterator(   const    CharacterIterator&  sourceText,
00249                                                             const   RuleBasedCollator*  order,
00250                                                             UErrorCode& status);
00255     const   CollationElementIterator&
00256                                 operator=(const CollationElementIterator& other);
00257 public:
00262                                 CollationElementIterator(const  CollationElementIterator& other);
00263     //============================================================
00264     // privates
00265     //============================================================
00266 private:
00270                                 CollationElementIterator();
00274                                 CollationElementIterator(const RuleBasedCollator* order);
00275 
00284             int32_t             nextContractChar(   UChar32     ch,
00285                                                     UErrorCode&  status);
00286 
00295             int32_t             prevContractChar(   UChar32     ch,
00296                                                     UErrorCode&  status);
00297     
00298     inline static UBool isThaiPreVowel(UChar32 ch);
00299                  
00300     inline static UBool isThaiBaseConsonant(UChar32 ch);
00301                  
00302     VectorOfInt* makeReorderedBuffer(UChar colFirst,
00303                                      int32_t lastValue,
00304                                      VectorOfInt* lastExpansion,
00305                                      UBool forward, UErrorCode& status);
00306 
00307     friend  class   RuleBasedCollator;
00308 
00309 // This is just temporary, for prototyping.
00310   friend int32_t ucol_getNextCE(const UCollator *coll, collIterate *source, UErrorCode *status);
00311 
00312     static  const   int32_t         UNMAPPEDCHARVALUE;
00313 
00314             Normalizer*            text;       // owning 
00315 
00316             VectorOfInt*        bufferAlias; // not owned
00317 
00326             VectorOfInt*        ownBuffer;
00327 
00335             VectorOfInt*        reorderBuffer;
00336 
00337             int32_t             expIndex;
00338             UnicodeString       key;
00339     const   RuleBasedCollator*  orderAlias;
00340 };
00341 
00342 
00348 inline int32_t
00349 CollationElementIterator::primaryOrder(int32_t order)
00350 {
00351     order &= RuleBasedCollator::PRIMARYORDERMASK;
00352     return (order >> RuleBasedCollator::PRIMARYORDERSHIFT);
00353 }
00359 inline int32_t
00360 CollationElementIterator::secondaryOrder(int32_t order)
00361 {
00362     order = order & RuleBasedCollator::SECONDARYORDERMASK;
00363     return (order >> RuleBasedCollator::SECONDARYORDERSHIFT);
00364 }
00370 inline int32_t
00371 CollationElementIterator::tertiaryOrder(int32_t order)
00372 {
00373     return (order &= RuleBasedCollator::TERTIARYORDERMASK);
00374 }
00375 
00376 inline int32_t
00377 CollationElementIterator::getMaxExpansion(int32_t order) const
00378 {
00379     return orderAlias->getMaxExpansion(order);
00380 }
00381 
00382 inline UBool
00383 CollationElementIterator::isIgnorable(int32_t order)
00384 {
00385     return (primaryOrder(order) == RuleBasedCollator::PRIMIGNORABLE);
00386 }
00387 
00392 inline UBool CollationElementIterator::isThaiPreVowel(UChar32 ch) {
00393     return ((uint32_t)ch - 0xe40) <= (0xe44 - 0xe40);
00394 }
00395 
00399 inline UBool CollationElementIterator::isThaiBaseConsonant(UChar32 ch) {
00400     return ((uint32_t)ch - 0xe01) <= (0xe2e - 0xe01);
00401 }
00402 
00403 #endif

Generated at Fri Dec 15 12:12:31 2000 for ICU 1.7 by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000