- Main Page
- Modules
- Data Structures
- Files
- Related Pages

- Search for |

- File List
- Globals

# coll.h

Go to the documentation of this file.

    00001 /*
    00002 ******************************************************************************
    00003 *   Copyright (C) 1996-2007, 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
    00054 #if !UCONFIG_NO_COLLATION
    00055
    00056 #include "unicode/uobject.h"
    00057 #include "unicode/ucol.h"
    00058 #include "unicode/normlzr.h"
    00059 #include "unicode/locid.h"
    00060 #include "unicode/uniset.h"
    00061 #include "unicode/umisc.h"
    00062
    00063 U_NAMESPACE_BEGIN
    00064
    00065 class StringEnumeration;
    00066
    00067 #if !UCONFIG_NO_SERVICE
    00068
    00071 class CollatorFactory;
    00072 #endif
    00073
    00077 class CollationKey;
    00078
    00175 class U_I18N_API Collator : public UObject {
    00176 public:
    00177
    00178     // Collator public enums -----------------------------------------------
    00179
    00205     enum ECollationStrength
    00206     {
    00207         PRIMARY    = 0,
    00208         SECONDARY  = 1,
    00209         TERTIARY   = 2,
    00210         QUATERNARY = 3,
    00211         IDENTICAL  = 15
    00212     };
    00213
    00224     enum EComparisonResult
    00225     {
    00226         LESS = -1,
    00227         EQUAL = 0,
    00228         GREATER = 1
    00229     };
    00230
    00231     // Collator public destructor -----------------------------------------
    00232
    00237     virtual ~Collator();
    00238
    00239     // Collator public methods --------------------------------------------
    00240
    00247     virtual UBool operator==(const Collator& other) const;
    00248
    00255     virtual UBool operator!=(const Collator& other) const;
    00256
    00262     virtual Collator* clone(void) const = 0;
    00263
    00283     static Collator* U_EXPORT2 createInstance(UErrorCode&  err);
    00284
    00308     static Collator* U_EXPORT2 createInstance(const Locale& loc, UErrorCode& err);
    00309
    00310 #ifdef U_USE_COLLATION_OBSOLETE_2_6
    00311
    00334     static Collator *createInstance(const Locale &loc, UVersionInfo version, UErrorCode &err);
    00335 #endif
    00336
    00348     virtual EComparisonResult compare(const UnicodeString& source,
    00349                                       const UnicodeString& target) const;
    00350
    00363     virtual UCollationResult compare(const UnicodeString& source,
    00364                                       const UnicodeString& target,
    00365                                       UErrorCode &status) const = 0;
    00366
    00379     virtual EComparisonResult compare(const UnicodeString& source,
    00380                                       const UnicodeString& target,
    00381                                       int32_t length) const;
    00382
    00396     virtual UCollationResult compare(const UnicodeString& source,
    00397                                       const UnicodeString& target,
    00398                                       int32_t length,
    00399                                       UErrorCode &status) const = 0;
    00400
    00416     virtual EComparisonResult compare(const UChar* source, int32_t sourceLength,
    00417                                       const UChar* target, int32_t targetLength)
    00418                                       const;
    00419
    00436     virtual UCollationResult compare(const UChar* source, int32_t sourceLength,
    00437                                       const UChar* target, int32_t targetLength,
    00438                                       UErrorCode &status) const = 0;
    00439
    00455     virtual CollationKey& getCollationKey(const UnicodeString&  source,
    00456                                           CollationKey& key,
    00457                                           UErrorCode& status) const = 0;
    00458
    00475     virtual CollationKey& getCollationKey(const UChar*source,
    00476                                           int32_t sourceLength,
    00477                                           CollationKey& key,
    00478                                           UErrorCode& status) const = 0;
    00483     virtual int32_t hashCode(void) const = 0;
    00484
    00497     virtual const Locale getLocale(ULocDataLocaleType type, UErrorCode& status) const = 0;
    00498
    00508     UBool greater(const UnicodeString& source, const UnicodeString& target)
    00509                   const;
    00510
    00520     UBool greaterOrEqual(const UnicodeString& source,
    00521                          const UnicodeString& target) const;
    00522
    00532     UBool equals(const UnicodeString& source, const UnicodeString& target) const;
    00533
    00544     virtual ECollationStrength getStrength(void) const = 0;
    00545
    00564     virtual void setStrength(ECollationStrength newStrength) = 0;
    00565
    00575     static UnicodeString& U_EXPORT2 getDisplayName(const Locale& objectLocale,
    00576                                          const Locale& displayLocale,
    00577                                          UnicodeString& name);
    00578
    00587     static UnicodeString& U_EXPORT2 getDisplayName(const Locale& objectLocale,
    00588                                          UnicodeString& name);
    00589
    00601     static const Locale* U_EXPORT2 getAvailableLocales(int32_t& count);
    00602
    00611     static StringEnumeration* U_EXPORT2 getAvailableLocales(void);
    00612
    00622     static StringEnumeration* U_EXPORT2 getKeywords(UErrorCode& status);
    00623
    00635     static StringEnumeration* U_EXPORT2 getKeywordValues(const char *keyword, UErrorCode& status);
    00636
    00664     static Locale U_EXPORT2 getFunctionalEquivalent(const char* keyword, const Locale& locale,
    00665                                           UBool& isAvailable, UErrorCode& status);
    00666
    00667 #if !UCONFIG_NO_SERVICE
    00668
    00676     static URegistryKey U_EXPORT2 registerInstance(Collator* toAdopt, const Locale& locale, UErrorCode& status);
    00677
    00685     static URegistryKey U_EXPORT2 registerFactory(CollatorFactory* toAdopt, UErrorCode& status);
    00686
    00697     static UBool U_EXPORT2 unregister(URegistryKey key, UErrorCode& status);
    00698 #endif /* UCONFIG_NO_SERVICE */
    00699
    00705     virtual void getVersion(UVersionInfo info) const = 0;
    00706
    00717     virtual UClassID getDynamicClassID(void) const = 0;
    00718
    00727     virtual void setAttribute(UColAttribute attr, UColAttributeValue value,
    00728                               UErrorCode &status) = 0;
    00729
    00738     virtual UColAttributeValue getAttribute(UColAttribute attr,
    00739                                             UErrorCode &status) = 0;
    00740
    00751     virtual uint32_t setVariableTop(const UChar *varTop, int32_t len, UErrorCode &status) = 0;
    00752
    00762     virtual uint32_t setVariableTop(const UnicodeString varTop, UErrorCode &status) = 0;
    00763
    00771     virtual void setVariableTop(const uint32_t varTop, UErrorCode &status) = 0;
    00772
    00779     virtual uint32_t getVariableTop(UErrorCode &status) const = 0;
    00780
    00790     virtual UnicodeSet *getTailoredSet(UErrorCode &status) const;
    00791
    00792
    00798     virtual Collator* safeClone(void) = 0;
    00799
    00812     virtual int32_t getSortKey(const UnicodeString& source,
    00813                               uint8_t* result,
    00814                               int32_t resultLength) const = 0;
    00815
    00831     virtual int32_t getSortKey(const UChar*source, int32_t sourceLength,
    00832                                uint8_t*result, int32_t resultLength) const = 0;
    00833
    00871     static int32_t U_EXPORT2 getBound(const uint8_t       *source,
    00872             int32_t             sourceLength,
    00873             UColBoundMode       boundType,
    00874             uint32_t            noOfLevels,
    00875             uint8_t             *result,
    00876             int32_t             resultLength,
    00877             UErrorCode          &status);
    00878
    00879
    00880 protected:
    00881
    00882     // Collator protected constructors -------------------------------------
    00883
    00891     Collator();
    00892
    00904     Collator(UCollationStrength collationStrength,
    00905              UNormalizationMode decompositionMode);
    00906
    00912     Collator(const Collator& other);
    00913
    00914     // Collator protected methods -----------------------------------------
    00915
    00916
    00923     virtual void setLocales(const Locale& requestedLocale, const Locale& validLocale);
    00924
    00925 public:
    00926 #if !UCONFIG_NO_SERVICE
    00927
    00931     static UCollator* createUCollator(const char* loc, UErrorCode* status);
    00932 #endif
    00933 private:
    00938     Collator& operator=(const Collator& other);
    00939
    00940     friend class CFactory;
    00941     friend class SimpleCFactory;
    00942     friend class ICUCollatorFactory;
    00943     friend class ICUCollatorService;
    00944     static Collator* makeInstance(const Locale& desiredLocale,
    00945                                   UErrorCode& status);
    00946
    00947     // Collator private data members ---------------------------------------
    00948
    00949     /*
    00950     synwee : removed as attributes to be handled by child class
    00951     UCollationStrength  strength;
    00952     Normalizer::EMode  decmp;
    00953     */
    00954     /* This is useless information */
    00955 /*  static const UVersionInfo fVersion;*/
    00956 };
    00957
    00958 #if !UCONFIG_NO_SERVICE
    00959
    00975 class U_I18N_API CollatorFactory : public UObject {
    00976 public:
    00977
    00982     virtual ~CollatorFactory();
    00983
    00991     virtual UBool visible(void) const;
    00992
    01000     virtual Collator* createCollator(const Locale& loc) = 0;
    01001
    01012     virtual  UnicodeString& getDisplayName(const Locale& objectLocale,
    01013                                            const Locale& displayLocale,
    01014                                            UnicodeString& result);
    01015
    01025     virtual const UnicodeString * getSupportedIDs(int32_t &count, UErrorCode& status) = 0;
    01026 };
    01027 #endif /* UCONFIG_NO_SERVICE */
    01028
    01029 // Collator inline methods -----------------------------------------------
    01030
    01031 U_NAMESPACE_END
    01032
    01033 #endif /* #if !UCONFIG_NO_COLLATION */
    01034
    01035 #endif