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

coll.h

Go to the documentation of this file.
00001 /*
00002 ******************************************************************************
00003 *   Copyright (C) 1996-2001, International Business Machines                 *
00004 *   Corporation and others.  All Rights Reserved.                            *
00005 ******************************************************************************
00006 */
00007 
00044 #ifndef COLL_H
00045 #define COLL_H
00046 
00047 #include "unicode/ucol.h"
00048 #include "unicode/normlzr.h"
00049 #include "unicode/locid.h"
00050 
00051 U_NAMESPACE_BEGIN
00052 
00053 class CollationKey;
00054 
00154 class U_I18N_API Collator
00155 {
00156 public:
00157 
00158   // Collator public enums -----------------------------------------------
00159 
00185   enum ECollationStrength 
00186   {
00187     PRIMARY    = 0,
00188     SECONDARY  = 1, 
00189     TERTIARY   = 2,
00190     QUATERNARY = 3,
00191     IDENTICAL  = 15
00192   };
00193   
00204   enum EComparisonResult 
00205   {
00206     LESS = -1,
00207     EQUAL = 0,
00208     GREATER = 1
00209   };
00210   
00211   // Collator public destructor -----------------------------------------
00212   
00217   virtual ~Collator();
00218 
00219   // Collator public methods --------------------------------------------
00220 
00227   virtual UBool operator==(const Collator& other) const;
00228 
00235   virtual UBool operator!=(const Collator& other) const;
00236 
00242   virtual Collator* clone(void) const = 0;
00243 
00261   static Collator* createInstance(UErrorCode&  err);
00262 
00286   static Collator* createInstance(const Locale& loc, UErrorCode& err);
00287 
00308   static Collator *createInstance(const Locale &loc, UVersionInfo version, UErrorCode &err);
00309 
00321   virtual EComparisonResult compare(const UnicodeString& source, 
00322                                     const UnicodeString& target) const = 0;
00323 
00336   virtual EComparisonResult compare(const UnicodeString& source,
00337                                     const UnicodeString& target,
00338                                     int32_t length) const = 0;
00339     
00355   virtual EComparisonResult compare(const UChar* source, int32_t sourceLength,
00356                                     const UChar* target, int32_t targetLength) 
00357                                     const = 0;
00358 
00373   virtual CollationKey& getCollationKey(const UnicodeString&  source,
00374                                         CollationKey& key,
00375                                         UErrorCode& status) const = 0;
00376 
00392   virtual CollationKey& getCollationKey(const UChar*source, 
00393                                         int32_t sourceLength,
00394                                                                       CollationKey& key,
00395                                                                       UErrorCode& status) const = 0;
00400   virtual int32_t hashCode(void) const = 0;
00401 
00411   UBool greater(const UnicodeString& source, const UnicodeString& target) 
00412                 const;
00413 
00423   UBool greaterOrEqual(const UnicodeString& source, 
00424                        const UnicodeString& target) const;
00434   UBool equals(const UnicodeString& source, const UnicodeString& target) const;
00435         
00446   virtual ECollationStrength getStrength(void) const = 0;
00447   
00468   virtual void setStrength(ECollationStrength newStrength) = 0;
00469 
00479   static UnicodeString& getDisplayName(const Locale& objectLocale,
00480                                        const Locale& displayLocale,
00481                                        UnicodeString& name);
00490   static UnicodeString& getDisplayName(const Locale& objectLocale,
00491                                        UnicodeString& name);
00492 
00499   static const Locale* getAvailableLocales(int32_t& count);
00500 
00506   void getVersion(UVersionInfo info) const;
00507 
00525   virtual UClassID getDynamicClassID(void) const = 0;
00526 
00535   virtual void setAttribute(UColAttribute attr, UColAttributeValue value, 
00536                             UErrorCode &status) = 0;
00537 
00546   virtual UColAttributeValue getAttribute(UColAttribute attr, 
00547                                           UErrorCode &status) = 0;
00548 
00559   virtual uint32_t setVariableTop(const UChar *varTop, int32_t len, UErrorCode &status) = 0;
00560 
00570   virtual uint32_t setVariableTop(const UnicodeString varTop, UErrorCode &status) = 0;
00571 
00579   virtual void setVariableTop(const uint32_t varTop, UErrorCode &status) = 0;
00580 
00587   virtual uint32_t getVariableTop(UErrorCode &status) const = 0;
00588 
00589 
00595   virtual Collator* safeClone(void) = 0;
00596 
00609   virtual int32_t getSortKey(const UnicodeString& source, uint8_t* result,
00610                                                                  int32_t resultLength) const = 0;
00611 
00627   virtual int32_t getSortKey(const UChar*source, int32_t sourceLength,
00628                                                                  uint8_t*result, int32_t resultLength) const = 0;
00629   // start deprecated APIs
00636   virtual Normalizer::EMode getDecomposition(void) const = 0;
00637 
00645   virtual void setDecomposition(Normalizer::EMode  mode) = 0;
00646 
00647 protected:
00648 
00649   // Collator protected constructors -------------------------------------
00650 
00657   Collator();
00658 
00668   Collator(UCollationStrength collationStrength, 
00669               UNormalizationMode decompositionMode);
00670   
00675   Collator(const Collator& other);
00676   
00677   // Collator protected methods -----------------------------------------
00678 
00679 private:
00680  
00681   // Collator private data members ---------------------------------------
00682 
00683   /*
00684   synwee : removed as attributes to be handled by child class
00685   UCollationStrength  strength;
00686   Normalizer::EMode  decmp;
00687   */
00688   static const UVersionInfo fVersion;
00689 };
00690 
00691 // Collator inline methods -----------------------------------------------
00692 
00693 inline UBool Collator::operator==(const Collator& other) const
00694 {
00695   return (UBool)(this == &other);
00696 }
00697 
00698 inline UBool Collator::operator!=(const Collator& other) const
00699 {
00700   return (UBool)!(*this == other);
00701 }
00702 
00703 /*
00704 synwee : removed since there's no attribute to be retrieved here
00705 inline UCollationStrength Collator::getStrength() const
00706 {
00707   return strength;
00708 }
00709 
00710 inline Normalizer::EMode Collator::getDecomposition() const
00711 {
00712   return decmp;
00713 }
00714 */
00715 U_NAMESPACE_END
00716 
00717 #endif

Generated on Mon Dec 3 19:00:20 2001 for ICU 2.0 by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001