Main Page   Class Hierarchy   Compound List   File List   Header Files   Sources   Compound Members   File Members  

coll.h

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/locid.h"
00049 #include "unicode/utypes.h"
00050 #include "unicode/unistr.h"
00051 #include "unicode/normlzr.h"
00052 
00053 class CollationKey;
00054 
00140 class U_I18N_API Collator {
00141 public:
00166   enum ECollationStrength {
00167     PRIMARY = 0,
00168     SECONDARY = 1, 
00169     TERTIARY = 2,
00170     IDENTICAL = 3
00171   };
00172 
00182   enum EComparisonResult {
00183     LESS = -1,
00184     EQUAL = 0,
00185     GREATER = 1
00186   };
00187   
00192   virtual                         ~Collator();
00193 
00198   virtual     UBool              operator==(const Collator& other) const;
00199 
00204   virtual     UBool              operator!=(const Collator& other) const;
00205 
00210   virtual     Collator*           clone(void) const = 0;
00228   static  Collator*           createInstance( UErrorCode&  err);
00229 
00253   static  Collator*           createInstance( const Locale&   loc,
00254                           UErrorCode&      err);
00255 
00256   // comparison
00282   virtual EComparisonResult   compare(    const   UnicodeString&  source, 
00283                       const   UnicodeString&  target) const = 0;
00284 
00310   virtual EComparisonResult   compare(    const   UnicodeString&  source,
00311                       const   UnicodeString&  target,
00312                       int32_t length) const = 0;
00313     
00314     
00344   virtual EComparisonResult   compare(    const   UChar* source, 
00345                       int32_t sourceLength,
00346                       const   UChar*  target,
00347                       int32_t targetLength) const = 0;
00348 
00386   virtual CollationKey&       getCollationKey(const   UnicodeString&  source,
00387                           CollationKey&       key,
00388                           UErrorCode&      status) const = 0;
00389 
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   UBool              greater(    const   UnicodeString& source, 
00425                   const   UnicodeString& target) const;
00436   UBool              greaterOrEqual( const   UnicodeString& source, 
00437                       const   UnicodeString& target) const;
00448   UBool              equals( const   UnicodeString& source, 
00449                   const   UnicodeString& target) const;
00450         
00451   // getter/setter
00458   Normalizer::EMode  getDecomposition(void) const;
00466   void                setDecomposition(Normalizer::EMode  mode);
00477   ECollationStrength  getStrength(void) const;
00494   void                setStrength(    ECollationStrength  newStrength);
00504   static  UnicodeString&      getDisplayName( const   Locale&     objectLocale,
00505                           const   Locale&     displayLocale,
00506                           UnicodeString& name) ;
00516   static  UnicodeString&      getDisplayName( const   Locale&         objectLocale,
00517                           UnicodeString&  name) ;
00518 
00525   static  const   Locale*     getAvailableLocales(int32_t& count);
00526 
00532   void getVersion(UVersionInfo info) const;
00533 
00551   virtual UClassID getDynamicClassID(void) const = 0;
00552 
00553 protected:
00557   Collator();
00558   Collator(ECollationStrength collationStrength,
00559        Normalizer::EMode decompositionMode);
00560   Collator(const  Collator&   other);
00561 
00565   const       Collator&       operator=(const Collator&   other);
00566 
00567   //--------------------------------------------------------------------------
00568 private:
00569             
00570   ECollationStrength  strength;
00571   Normalizer::EMode  decmp;
00572   static const UVersionInfo fVersion;
00573 };
00574 
00575 inline UBool
00576 Collator::operator==(const Collator& other) const
00577 {
00578   UBool result;
00579   if (this == &other) result = TRUE;
00580   else result = ((strength == other.strength) && (decmp == other.decmp));
00581   return result;
00582 }
00583 
00584 inline UBool
00585 Collator::operator!=(const Collator& other) const
00586 {
00587   UBool result;
00588   result = !(*this == other);
00589   return result;
00590 }
00591 
00592 inline Collator::ECollationStrength 
00593 Collator::getStrength() const
00594 {
00595   return strength;
00596 }
00597 
00598 inline Normalizer::EMode
00599 Collator::getDecomposition() const
00600 {
00601   return decmp;
00602 }
00603 
00604 
00605 #endif

Generated at Mon Jun 5 12:53:02 2000 for ICU1.5 by doxygen 1.0.0 written by Dimitri van Heesch, © 1997-1999