Main Page | Class Hierarchy | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

coll.h

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/ucol.h" 00048 #include "unicode/normlzr.h" 00049 #include "unicode/locid.h" 00050 00051 U_NAMESPACE_BEGIN 00052 00053 class CollationKey; 00054 00154 class U_I18N_API Collator 00155 { 00156 public: 00157 00158 // Collator public enums ----------------------------------------------- 00159 00185 enum ECollationStrength 00186 { 00187 PRIMARY = 0, 00188 SECONDARY = 1, 00189 TERTIARY = 2, 00190 QUATERNARY = 3, 00191 IDENTICAL = 15 00192 }; 00193 00204 enum EComparisonResult 00205 { 00206 LESS = -1, 00207 EQUAL = 0, 00208 GREATER = 1 00209 }; 00210 00211 // Collator public destructor ----------------------------------------- 00212 00217 virtual ~Collator(); 00218 00219 // Collator public methods -------------------------------------------- 00220 00227 virtual UBool operator==(const Collator& other) const; 00228 00235 virtual UBool operator!=(const Collator& other) const; 00236 00242 virtual Collator* clone(void) const = 0; 00243 00261 static Collator* createInstance(UErrorCode& err); 00262 00286 static Collator* createInstance(const Locale& loc, UErrorCode& err); 00287 00308 static Collator *createInstance(const Locale &loc, UVersionInfo version, UErrorCode &err); 00309 00321 virtual EComparisonResult compare(const UnicodeString& source, 00322 const UnicodeString& target) const = 0; 00323 00336 virtual EComparisonResult compare(const UnicodeString& source, 00337 const UnicodeString& target, 00338 int32_t length) const = 0; 00339 00355 virtual EComparisonResult compare(const UChar* source, int32_t sourceLength, 00356 const UChar* target, int32_t targetLength) 00357 const = 0; 00358 00373 virtual CollationKey& getCollationKey(const UnicodeString& source, 00374 CollationKey& key, 00375 UErrorCode& status) const = 0; 00376 00392 virtual CollationKey& getCollationKey(const UChar*source, 00393 int32_t sourceLength, 00394 CollationKey& key, 00395 UErrorCode& status) const = 0; 00400 virtual int32_t hashCode(void) const = 0; 00401 00406 virtual const Locale getLocale(ULocDataLocaleType type, UErrorCode& status) const = 0; 00407 00417 UBool greater(const UnicodeString& source, const UnicodeString& target) 00418 const; 00419 00429 UBool greaterOrEqual(const UnicodeString& source, 00430 const UnicodeString& target) const; 00440 UBool equals(const UnicodeString& source, const UnicodeString& target) const; 00441 00452 virtual ECollationStrength getStrength(void) const = 0; 00453 00474 virtual void setStrength(ECollationStrength newStrength) = 0; 00475 00485 static UnicodeString& getDisplayName(const Locale& objectLocale, 00486 const Locale& displayLocale, 00487 UnicodeString& name); 00496 static UnicodeString& getDisplayName(const Locale& objectLocale, 00497 UnicodeString& name); 00498 00505 static const Locale* getAvailableLocales(int32_t& count); 00506 00512 virtual void getVersion(UVersionInfo info) const = 0; 00513 00531 virtual UClassID getDynamicClassID(void) const = 0; 00532 00541 virtual void setAttribute(UColAttribute attr, UColAttributeValue value, 00542 UErrorCode &status) = 0; 00543 00552 virtual UColAttributeValue getAttribute(UColAttribute attr, 00553 UErrorCode &status) = 0; 00554 00565 virtual uint32_t setVariableTop(const UChar *varTop, int32_t len, UErrorCode &status) = 0; 00566 00576 virtual uint32_t setVariableTop(const UnicodeString varTop, UErrorCode &status) = 0; 00577 00585 virtual void setVariableTop(const uint32_t varTop, UErrorCode &status) = 0; 00586 00593 virtual uint32_t getVariableTop(UErrorCode &status) const = 0; 00594 00595 00601 virtual Collator* safeClone(void) = 0; 00602 00615 virtual int32_t getSortKey(const UnicodeString& source, 00616 uint8_t* result, 00617 int32_t resultLength) const = 0; 00618 00634 virtual int32_t getSortKey(const UChar*source, int32_t sourceLength, 00635 uint8_t*result, int32_t resultLength) const = 0; 00636 00637 // start deprecated APIs 00644 virtual Normalizer::EMode getDecomposition(void) const = 0; 00645 00653 virtual void setDecomposition(Normalizer::EMode mode) = 0; 00654 00655 00693 static int32_t getBound(const uint8_t *source, 00694 int32_t sourceLength, 00695 UColBoundMode boundType, 00696 uint32_t noOfLevels, 00697 uint8_t *result, 00698 int32_t resultLength, 00699 UErrorCode &status); 00700 00701 00702 protected: 00703 00704 // Collator protected constructors ------------------------------------- 00705 00712 Collator(); 00713 00723 Collator(UCollationStrength collationStrength, 00724 UNormalizationMode decompositionMode); 00725 00730 Collator(const Collator& other); 00731 00732 // Collator protected methods ----------------------------------------- 00733 00734 private: 00735 00736 // Collator private data members --------------------------------------- 00737 00738 /* 00739 synwee : removed as attributes to be handled by child class 00740 UCollationStrength strength; 00741 Normalizer::EMode decmp; 00742 */ 00743 /* This is useless information */ 00744 /* static const UVersionInfo fVersion;*/ 00745 }; 00746 00747 // Collator inline methods ----------------------------------------------- 00748 00749 inline UBool Collator::operator==(const Collator& other) const 00750 { 00751 return (UBool)(this == &other); 00752 } 00753 00754 inline UBool Collator::operator!=(const Collator& other) const 00755 { 00756 return (UBool)!(*this == other); 00757 } 00758 00759 /* 00760 synwee : removed since there's no attribute to be retrieved here 00761 inline UCollationStrength Collator::getStrength() const 00762 { 00763 return strength; 00764 } 00765 00766 inline Normalizer::EMode Collator::getDecomposition() const 00767 { 00768 return decmp; 00769 } 00770 */ 00771 U_NAMESPACE_END 00772 00773 #endif

Generated on Wed Aug 18 05:18:14 2004 for ICU 2.1 by doxygen 1.3.7