Main Page   Class Hierarchy   Alphabetical List   Data Structures   File List   Data Fields   Globals  

coll.h

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 
00406   virtual const Locale getLocale(UErrorCode& status) const = 0;
00407 
00417   UBool greater(const UnicodeString& source, const UnicodeString& target) 
00418                 const;
00419 
00429   UBool greaterOrEqual(const UnicodeString& source, 
00430                        const UnicodeString& target) const;
00440   UBool equals(const UnicodeString& source, const UnicodeString& target) const;
00441         
00452   virtual ECollationStrength getStrength(void) const = 0;
00453   
00474   virtual void setStrength(ECollationStrength newStrength) = 0;
00475 
00485   static UnicodeString& getDisplayName(const Locale& objectLocale,
00486                                        const Locale& displayLocale,
00487                                        UnicodeString& name);
00496   static UnicodeString& getDisplayName(const Locale& objectLocale,
00497                                        UnicodeString& name);
00498 
00505   static const Locale* getAvailableLocales(int32_t& count);
00506 
00512   virtual void getVersion(UVersionInfo info) const = 0;
00513 
00531   virtual UClassID getDynamicClassID(void) const = 0;
00532 
00541   virtual void setAttribute(UColAttribute attr, UColAttributeValue value, 
00542                             UErrorCode &status) = 0;
00543 
00552   virtual UColAttributeValue getAttribute(UColAttribute attr, 
00553                                           UErrorCode &status) = 0;
00554 
00565   virtual uint32_t setVariableTop(const UChar *varTop, int32_t len, UErrorCode &status) = 0;
00566 
00576   virtual uint32_t setVariableTop(const UnicodeString varTop, UErrorCode &status) = 0;
00577 
00585   virtual void setVariableTop(const uint32_t varTop, UErrorCode &status) = 0;
00586 
00593   virtual uint32_t getVariableTop(UErrorCode &status) const = 0;
00594 
00595 
00601   virtual Collator* safeClone(void) = 0;
00602 
00615   virtual int32_t getSortKey(const UnicodeString& source,
00616                             uint8_t* result,
00617                             int32_t resultLength) const = 0;
00618 
00634   virtual int32_t getSortKey(const UChar*source, int32_t sourceLength,
00635                              uint8_t*result, int32_t resultLength) const = 0;
00636 
00637   // start deprecated APIs
00644   virtual Normalizer::EMode getDecomposition(void) const = 0;
00645 
00653   virtual void setDecomposition(Normalizer::EMode  mode) = 0;
00654 
00655 protected:
00656 
00657   // Collator protected constructors -------------------------------------
00658 
00665   Collator();
00666 
00676   Collator(UCollationStrength collationStrength, 
00677               UNormalizationMode decompositionMode);
00678   
00683   Collator(const Collator& other);
00684   
00685   // Collator protected methods -----------------------------------------
00686 
00687 private:
00688  
00689   // Collator private data members ---------------------------------------
00690 
00691   /*
00692   synwee : removed as attributes to be handled by child class
00693   UCollationStrength  strength;
00694   Normalizer::EMode  decmp;
00695   */
00696     /* This is useless information */
00697 /*  static const UVersionInfo fVersion;*/
00698 };
00699 
00700 // Collator inline methods -----------------------------------------------
00701 
00702 inline UBool Collator::operator==(const Collator& other) const
00703 {
00704   return (UBool)(this == &other);
00705 }
00706 
00707 inline UBool Collator::operator!=(const Collator& other) const
00708 {
00709   return (UBool)!(*this == other);
00710 }
00711 
00712 /*
00713 synwee : removed since there's no attribute to be retrieved here
00714 inline UCollationStrength Collator::getStrength() const
00715 {
00716   return strength;
00717 }
00718 
00719 inline Normalizer::EMode Collator::getDecomposition() const
00720 {
00721   return decmp;
00722 }
00723 */
00724 U_NAMESPACE_END
00725 
00726 #endif

Generated on Tue Mar 5 13:05:44 2002 for ICU 2.0 by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002