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

coll.h

Go to the documentation of this file.
00001 /*
00002 *******************************************************************************
00003 *   Copyright (C) 1996-1999, International Business Machines
00004 *   Corporation and others.  All Rights Reserved.
00005 *******************************************************************************
00006 */
00007 //=============================================================================
00008 //
00009 // File coll.h
00010 //
00011 // 
00012 //
00013 // Created by: Helena Shih
00014 //
00015 // Modification History:
00016 //
00017 //  Date        Name        Description
00018 // 02/5/97      aliu        Modified createDefault to load collation data from
00019 //                          binary files when possible.  Added related methods
00020 //                          createCollationFromFile, chopLocale, createPathName.
00021 // 02/11/97     aliu        Added members addToCache, findInCache, and fgCache.
00022 // 02/12/97     aliu        Modified to create objects from RuleBasedCollator cache.
00023 //                          Moved cache out of Collation class.
00024 // 02/13/97     aliu        Moved several methods out of this class and into
00025 //                          RuleBasedCollator, with modifications.  Modified
00026 //                          createDefault() to call new RuleBasedCollator(Locale&)
00027 //                          constructor.  General clean up and documentation.
00028 // 02/20/97     helena      Added clone, operator==, operator!=, operator=, copy
00029 //                          constructor and getDynamicClassID.
00030 // 03/25/97     helena      Updated with platform independent data types.
00031 // 05/06/97     helena      Added memory allocation error detection.
00032 //  6/20/97     helena      Java class name change.
00033 // 09/03/97     helena      Added createCollationKeyValues().
00034 // 02/10/98     damiba      Added compare() with length as parameter.
00035 // 04/23/99     stephen     Removed EDecompositionMode, merged with
00036 //                          Normalizer::EMode.
00037 // 11/02/99     helena      Collator performance enhancements.  Eliminates the 
00038 //                          UnicodeString construction and special case for NO_OP.
00039 // 11/23/99     srl         More performance enhancements. Inlining of
00040 //                          critical accessors.
00041 // 05/15/00     helena      Added version information API. 
00042 //=============================================================================
00043 
00044 #ifndef COLL_H
00045 #define COLL_H
00046 
00047 
00048 #include "unicode/ucol.h"
00049 #include "unicode/locid.h"
00050 #include "unicode/utypes.h"
00051 #include "unicode/unistr.h"
00052 #include "unicode/normlzr.h"
00053 #include "unicode/chariter.h"
00054 
00055 class CollationKey;
00056 
00158 class U_I18N_API Collator {
00159 public:
00184   enum ECollationStrength {
00185     PRIMARY = 0,
00186     SECONDARY = 1, 
00187     TERTIARY = 2,
00188     IDENTICAL = 3
00189   };
00190 
00200   enum EComparisonResult {
00201     LESS = -1,
00202     EQUAL = 0,
00203     GREATER = 1
00204   };
00205   
00210   virtual                         ~Collator();
00211 
00216   virtual     UBool              operator==(const Collator& other) const;
00217 
00222   virtual     UBool              operator!=(const Collator& other) const;
00223 
00228   virtual     Collator*           clone(void) const = 0;
00246   static  Collator*           createInstance( UErrorCode&  err);
00247 
00271   static  Collator*           createInstance( const Locale&   loc,
00272                           UErrorCode&      err);
00273 
00274   // comparison
00300   virtual EComparisonResult   compare(    const   UnicodeString&  source, 
00301                       const   UnicodeString&  target) const = 0;
00302 
00328   virtual EComparisonResult   compare(    const   UnicodeString&  source,
00329                       const   UnicodeString&  target,
00330                       int32_t length) const = 0;
00331     
00332     
00362   virtual EComparisonResult   compare(    const   UChar* source, 
00363                       int32_t sourceLength,
00364                       const   UChar*  target,
00365                       int32_t targetLength) const = 0;
00366 
00404   virtual CollationKey&       getCollationKey(const   UnicodeString&  source,
00405                           CollationKey&       key,
00406                           UErrorCode&      status) const = 0;
00407 
00422   virtual CollationKey&       getCollationKey(const UChar *source,
00423                                               int32_t sourceLength,
00424                                               CollationKey&       key,
00425                                               UErrorCode&      status) const = 0;
00430   virtual int32_t             hashCode(void) const = 0;
00431 
00442   UBool              greater(    const   UnicodeString& source, 
00443                   const   UnicodeString& target) const;
00454   UBool              greaterOrEqual( const   UnicodeString& source, 
00455                       const   UnicodeString& target) const;
00466   UBool              equals( const   UnicodeString& source, 
00467                   const   UnicodeString& target) const;
00468         
00469   // getter/setter
00476   Normalizer::EMode  getDecomposition(void) const;
00484   void                setDecomposition(Normalizer::EMode  mode);
00495   ECollationStrength  getStrength(void) const;
00512   void                setStrength(    ECollationStrength  newStrength);
00522   static  UnicodeString&      getDisplayName( const   Locale&     objectLocale,
00523                           const   Locale&     displayLocale,
00524                           UnicodeString& name) ;
00534   static  UnicodeString&      getDisplayName( const   Locale&         objectLocale,
00535                           UnicodeString&  name) ;
00536 
00543   static  const   Locale*     getAvailableLocales(int32_t& count);
00544 
00550   void getVersion(UVersionInfo info) const;
00551 
00569   virtual UClassID getDynamicClassID(void) const = 0;
00570 
00571   /* New APIs for 1.7. Not yet implemented */
00572 
00580 virtual void setAttribute(UColAttribute attr, UColAttributeValue value, UErrorCode &status) = 0;
00581 
00589 virtual UColAttributeValue getAttribute(UColAttribute attr, UErrorCode &status) = 0;
00590 
00596 virtual Collator* safeClone(void) = 0;
00597 
00598 
00610 virtual EComparisonResult compare(ForwardCharacterIterator &source,
00611                                                                  ForwardCharacterIterator &target) = 0;
00612 
00622   virtual int32_t       getSortKey(const   UnicodeString&  source,
00623                                                   uint8_t *result,
00624                                                   int32_t resultLength) const = 0;
00625 
00637   virtual int32_t       getSortKey(const   UChar *source,
00638                                                   int32_t sourceLength,
00639                                                   uint8_t *result,
00640                                                   int32_t resultLength) const = 0;
00641 
00642 protected:
00646   Collator();
00647   Collator(ECollationStrength collationStrength,
00648        Normalizer::EMode decompositionMode);
00649   Collator(const  Collator&   other);
00650 
00654   const       Collator&       operator=(const Collator&   other);
00655 
00656   //--------------------------------------------------------------------------
00657 private:
00658             
00659   ECollationStrength  strength;
00660   Normalizer::EMode  decmp;
00661   static const UVersionInfo fVersion;
00662 };
00663 
00664 inline UBool
00665 Collator::operator==(const Collator& other) const
00666 {
00667   UBool result;
00668   if (this == &other) result = TRUE;
00669   else result = ((strength == other.strength) && (decmp == other.decmp));
00670   return result;
00671 }
00672 
00673 inline UBool
00674 Collator::operator!=(const Collator& other) const
00675 {
00676   UBool result;
00677   result = !(*this == other);
00678   return result;
00679 }
00680 
00681 inline Collator::ECollationStrength 
00682 Collator::getStrength() const
00683 {
00684   return strength;
00685 }
00686 
00687 inline Normalizer::EMode
00688 Collator::getDecomposition() const
00689 {
00690   return decmp;
00691 }
00692 
00693 
00694 #endif

Generated at Fri Dec 15 12:12:31 2000 for ICU 1.7 by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000