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 #include "unicode/uobject.h"
00049 #include "unicode/ucol.h"
00050 #include "unicode/normlzr.h"
00051 #include "unicode/locid.h"
00052 
00053 U_NAMESPACE_BEGIN
00054 
00058 class CollationKey;
00059 
00159 class U_I18N_API Collator : public UObject {
00160 public:
00161 
00162   // Collator public enums -----------------------------------------------
00163 
00189   enum ECollationStrength 
00190   {
00191     PRIMARY    = 0,
00192     SECONDARY  = 1, 
00193     TERTIARY   = 2,
00194     QUATERNARY = 3,
00195     IDENTICAL  = 15
00196   };
00197   
00208   enum EComparisonResult 
00209   {
00210     LESS = -1,
00211     EQUAL = 0,
00212     GREATER = 1
00213   };
00214   
00215   // Collator public destructor -----------------------------------------
00216   
00221   virtual ~Collator();
00222 
00223   // Collator public methods --------------------------------------------
00224 
00231   virtual UBool operator==(const Collator& other) const;
00232 
00239   virtual UBool operator!=(const Collator& other) const;
00240 
00246   virtual Collator* clone(void) const = 0;
00247 
00267   static Collator* createInstance(UErrorCode&  err);
00268 
00292   static Collator* createInstance(const Locale& loc, UErrorCode& err);
00293 
00314   static Collator *createInstance(const Locale &loc, UVersionInfo version, UErrorCode &err);
00315 
00327   virtual EComparisonResult compare(const UnicodeString& source, 
00328                                     const UnicodeString& target) const = 0;
00329 
00342   virtual EComparisonResult compare(const UnicodeString& source,
00343                                     const UnicodeString& target,
00344                                     int32_t length) const = 0;
00345     
00361   virtual EComparisonResult compare(const UChar* source, int32_t sourceLength,
00362                                     const UChar* target, int32_t targetLength) 
00363                                     const = 0;
00364 
00380   virtual CollationKey& getCollationKey(const UnicodeString&  source,
00381                                         CollationKey& key,
00382                                         UErrorCode& status) const = 0;
00383 
00400   virtual CollationKey& getCollationKey(const UChar*source, 
00401                                         int32_t sourceLength,
00402                                         CollationKey& key,
00403                                         UErrorCode& status) const = 0;
00408   virtual int32_t hashCode(void) const = 0;
00409 
00420   virtual const Locale getLocale(ULocDataLocaleType type, UErrorCode& status) const = 0;
00421 
00431   UBool greater(const UnicodeString& source, const UnicodeString& target) 
00432                 const;
00433 
00443   UBool greaterOrEqual(const UnicodeString& source, 
00444                        const UnicodeString& target) const;
00454   UBool equals(const UnicodeString& source, const UnicodeString& target) const;
00455         
00466   virtual ECollationStrength getStrength(void) const = 0;
00467   
00488   virtual void setStrength(ECollationStrength newStrength) = 0;
00489 
00499   static UnicodeString& getDisplayName(const Locale& objectLocale,
00500                                        const Locale& displayLocale,
00501                                        UnicodeString& name);
00510   static UnicodeString& getDisplayName(const Locale& objectLocale,
00511                                        UnicodeString& name);
00512 
00519   static const Locale* getAvailableLocales(int32_t& count);
00520 
00526   virtual void getVersion(UVersionInfo info) const = 0;
00527 
00545   virtual UClassID getDynamicClassID(void) const = 0;
00546 
00555   virtual void setAttribute(UColAttribute attr, UColAttributeValue value, 
00556                             UErrorCode &status) = 0;
00557 
00566   virtual UColAttributeValue getAttribute(UColAttribute attr, 
00567                                           UErrorCode &status) = 0;
00568 
00579   virtual uint32_t setVariableTop(const UChar *varTop, int32_t len, UErrorCode &status) = 0;
00580 
00590   virtual uint32_t setVariableTop(const UnicodeString varTop, UErrorCode &status) = 0;
00591 
00599   virtual void setVariableTop(const uint32_t varTop, UErrorCode &status) = 0;
00600 
00607   virtual uint32_t getVariableTop(UErrorCode &status) const = 0;
00608 
00609 
00615   virtual Collator* safeClone(void) = 0;
00616 
00629   virtual int32_t getSortKey(const UnicodeString& source,
00630                             uint8_t* result,
00631                             int32_t resultLength) const = 0;
00632 
00648   virtual int32_t getSortKey(const UChar*source, int32_t sourceLength,
00649                              uint8_t*result, int32_t resultLength) const = 0;
00650 
00651   // start deprecated APIs
00658   virtual Normalizer::EMode getDecomposition(void) const = 0;
00659 
00667   virtual void setDecomposition(Normalizer::EMode  mode) = 0;
00668 
00669 
00707 static int32_t getBound(const uint8_t       *source,
00708         int32_t             sourceLength,
00709         UColBoundMode       boundType,
00710         uint32_t            noOfLevels,
00711         uint8_t             *result,
00712         int32_t             resultLength,
00713         UErrorCode          &status);
00714 
00715 
00716 protected:
00717 
00718   // Collator protected constructors -------------------------------------
00719 
00727   Collator();
00728 
00739   Collator(UCollationStrength collationStrength, 
00740               UNormalizationMode decompositionMode);
00741   
00747   Collator(const Collator& other);
00748   
00749   // Collator protected methods -----------------------------------------
00750 
00751 private:
00752  
00753   // Collator private data members ---------------------------------------
00754 
00755   /*
00756   synwee : removed as attributes to be handled by child class
00757   UCollationStrength  strength;
00758   Normalizer::EMode  decmp;
00759   */
00760     /* This is useless information */
00761 /*  static const UVersionInfo fVersion;*/
00762 };
00763 
00764 // Collator inline methods -----------------------------------------------
00765 
00766 inline UBool Collator::operator==(const Collator& other) const
00767 {
00768   return (UBool)(this == &other);
00769 }
00770 
00771 inline UBool Collator::operator!=(const Collator& other) const
00772 {
00773   return (UBool)!(*this == other);
00774 }
00775 
00776 /*
00777 synwee : removed since there's no attribute to be retrieved here
00778 inline UCollationStrength Collator::getStrength() const
00779 {
00780   return strength;
00781 }
00782 
00783 inline Normalizer::EMode Collator::getDecomposition() const
00784 {
00785   return decmp;
00786 }
00787 */
00788 U_NAMESPACE_END
00789 
00790 #endif

Generated on Thu Aug 15 14:13:23 2002 for ICU 2.2 by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001