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/utypes.h"
00048 
00049 #if !UCONFIG_NO_COLLATION
00050 
00051 #include "unicode/uobject.h"
00052 #include "unicode/ucol.h"
00053 #include "unicode/normlzr.h"
00054 #include "unicode/locid.h"
00055 #include "unicode/uniset.h"
00056 
00057 U_NAMESPACE_BEGIN
00058 
00062 class CollationKey;
00063 
00163 class U_I18N_API Collator : public UObject {
00164 public:
00165 
00166   // Collator public enums -----------------------------------------------
00167 
00193   enum ECollationStrength 
00194   {
00195     PRIMARY    = 0,
00196     SECONDARY  = 1, 
00197     TERTIARY   = 2,
00198     QUATERNARY = 3,
00199     IDENTICAL  = 15
00200   };
00201   
00212   enum EComparisonResult 
00213   {
00214     LESS = -1,
00215     EQUAL = 0,
00216     GREATER = 1
00217   };
00218   
00219   // Collator public destructor -----------------------------------------
00220   
00225   virtual ~Collator();
00226 
00227   // Collator public methods --------------------------------------------
00228 
00235   virtual UBool operator==(const Collator& other) const;
00236 
00243   virtual UBool operator!=(const Collator& other) const;
00244 
00250   virtual Collator* clone(void) const = 0;
00251 
00271   static Collator* createInstance(UErrorCode&  err);
00272 
00296   static Collator* createInstance(const Locale& loc, UErrorCode& err);
00297 
00318   static Collator *createInstance(const Locale &loc, UVersionInfo version, UErrorCode &err);
00319 
00331   virtual EComparisonResult compare(const UnicodeString& source, 
00332                                     const UnicodeString& target) const = 0;
00333 
00346   virtual EComparisonResult compare(const UnicodeString& source,
00347                                     const UnicodeString& target,
00348                                     int32_t length) const = 0;
00349     
00365   virtual EComparisonResult compare(const UChar* source, int32_t sourceLength,
00366                                     const UChar* target, int32_t targetLength) 
00367                                     const = 0;
00368 
00384   virtual CollationKey& getCollationKey(const UnicodeString&  source,
00385                                         CollationKey& key,
00386                                         UErrorCode& status) const = 0;
00387 
00404   virtual CollationKey& getCollationKey(const UChar*source, 
00405                                         int32_t sourceLength,
00406                                         CollationKey& key,
00407                                         UErrorCode& status) const = 0;
00412   virtual int32_t hashCode(void) const = 0;
00413 
00424   virtual const Locale getLocale(ULocDataLocaleType type, UErrorCode& status) const = 0;
00425 
00435   UBool greater(const UnicodeString& source, const UnicodeString& target) 
00436                 const;
00437 
00447   UBool greaterOrEqual(const UnicodeString& source, 
00448                        const UnicodeString& target) const;
00458   UBool equals(const UnicodeString& source, const UnicodeString& target) const;
00459         
00470   virtual ECollationStrength getStrength(void) const = 0;
00471   
00492   virtual void setStrength(ECollationStrength newStrength) = 0;
00493 
00503   static UnicodeString& getDisplayName(const Locale& objectLocale,
00504                                        const Locale& displayLocale,
00505                                        UnicodeString& name);
00514   static UnicodeString& getDisplayName(const Locale& objectLocale,
00515                                        UnicodeString& name);
00516 
00523   static const Locale* getAvailableLocales(int32_t& count);
00524 
00530   virtual void getVersion(UVersionInfo info) const = 0;
00531 
00549   virtual UClassID getDynamicClassID(void) const = 0;
00550 
00559   virtual void setAttribute(UColAttribute attr, UColAttributeValue value, 
00560                             UErrorCode &status) = 0;
00561 
00570   virtual UColAttributeValue getAttribute(UColAttribute attr, 
00571                                           UErrorCode &status) = 0;
00572 
00583   virtual uint32_t setVariableTop(const UChar *varTop, int32_t len, UErrorCode &status) = 0;
00584 
00594   virtual uint32_t setVariableTop(const UnicodeString varTop, UErrorCode &status) = 0;
00595 
00603   virtual void setVariableTop(const uint32_t varTop, UErrorCode &status) = 0;
00604 
00611   virtual uint32_t getVariableTop(UErrorCode &status) const = 0;
00612 
00622   virtual UnicodeSet *getTailoredSet(UErrorCode &status) const;
00623 
00624 
00630   virtual Collator* safeClone(void) = 0;
00631 
00644   virtual int32_t getSortKey(const UnicodeString& source,
00645                             uint8_t* result,
00646                             int32_t resultLength) const = 0;
00647 
00663   virtual int32_t getSortKey(const UChar*source, int32_t sourceLength,
00664                              uint8_t*result, int32_t resultLength) const = 0;
00665 
00666 #ifdef ICU_NORMALIZER_USE_DEPRECATES
00667   // start obsolete APIs
00674   virtual Normalizer::EMode getDecomposition(void) const = 0;
00675 
00683   virtual void setDecomposition(Normalizer::EMode  mode) = 0;
00684 #endif /* ICU_NORMALIZER_USE_DEPRECATES */
00685 
00686 
00724     static int32_t getBound(const uint8_t       *source,
00725             int32_t             sourceLength,
00726             UColBoundMode       boundType,
00727             uint32_t            noOfLevels,
00728             uint8_t             *result,
00729             int32_t             resultLength,
00730             UErrorCode          &status);
00731 
00732 
00733 protected:
00734 
00735   // Collator protected constructors -------------------------------------
00736 
00744   Collator();
00745 
00757   Collator(UCollationStrength collationStrength, 
00758            UNormalizationMode decompositionMode);
00759   
00765   Collator(const Collator& other);
00766   
00767   // Collator protected methods -----------------------------------------
00768 
00769 private:
00774   Collator& operator=(const Collator& other);
00775 
00776 
00777  
00778   // Collator private data members ---------------------------------------
00779 
00780   /*
00781   synwee : removed as attributes to be handled by child class
00782   UCollationStrength  strength;
00783   Normalizer::EMode  decmp;
00784   */
00785     /* This is useless information */
00786 /*  static const UVersionInfo fVersion;*/
00787 };
00788 
00789 // Collator inline methods -----------------------------------------------
00790 
00791 inline UBool Collator::operator==(const Collator& other) const
00792 {
00793   return (UBool)(this == &other);
00794 }
00795 
00796 inline UBool Collator::operator!=(const Collator& other) const
00797 {
00798   return (UBool)!(*this == other);
00799 }
00800 
00801 inline UnicodeSet *Collator::getTailoredSet(UErrorCode &status) const
00802 {
00803   if(U_FAILURE(status)) {
00804     return NULL;
00805   }
00806   // everything can be changed
00807   return new UnicodeSet(0, 0x10FFFF);
00808 }
00809 
00810 /*
00811 synwee : removed since there's no attribute to be retrieved here
00812 inline UCollationStrength Collator::getStrength() const
00813 {
00814   return strength;
00815 }
00816 
00817 inline Normalizer::EMode Collator::getDecomposition() const
00818 {
00819   return decmp;
00820 }
00821 */
00822 U_NAMESPACE_END
00823 
00824 #endif /* #if !UCONFIG_NO_COLLATION */
00825 
00826 #endif

Generated on Wed Dec 18 16:49:30 2002 for ICU 2.4 by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001