00001 /* 00002 * Copyright (C) {1996-1999}, International Business Machines Corporation and others. All Rights Reserved. 00003 ***************************************************************************************** 00004 */ 00005 //=============================================================================== 00006 // 00007 // File sortkey.h 00008 // 00009 // 00010 // 00011 // Created by: Helena Shih 00012 // 00013 // Modification History: 00014 // 00015 // Date Name Description 00016 // 00017 // 6/20/97 helena Java class name change. 00018 // 8/18/97 helena Added internal API documentation. 00019 // 6/26/98 erm Changed to use byte arrays and memcmp. 00020 //=============================================================================== 00021 00022 #ifndef SORTKEY_H 00023 #define SORTKEY_H 00024 00025 00026 #include "unicode/utypes.h" 00027 #include "unicode/unistr.h" 00028 #include "unicode/coll.h" 00029 00030 U_NAMESPACE_BEGIN 00031 00032 /* forward declaration */ 00033 class RuleBasedCollator; 00034 00087 class U_I18N_API CollationKey { 00088 public: 00096 CollationKey(); 00097 00098 00106 CollationKey(const uint8_t* values, 00107 int32_t count); 00112 CollationKey(const CollationKey& other); 00117 ~CollationKey(); 00118 00123 const CollationKey& operator=(const CollationKey& other); 00124 00131 UBool operator==(const CollationKey& source) const; 00132 00139 UBool operator!=(const CollationKey& source) const; 00140 00141 00148 UBool isBogus(void) const; 00149 00158 const uint8_t* getByteArray(int32_t& count) const; 00159 00167 uint8_t* toByteArray(int32_t& count) const; 00168 00179 Collator::EComparisonResult compareTo(const CollationKey& target) const; 00180 00201 int32_t hashCode(void) const; 00202 00203 private: 00210 void adopt(uint8_t *values, int32_t count); 00211 00212 /* 00213 * Creates a collation key with a string. 00214 */ 00215 CollationKey& ensureCapacity(int32_t newSize); 00216 CollationKey& setToBogus(void); 00217 CollationKey& reset(void); 00218 00219 friend class RuleBasedCollator; 00220 00221 static const int32_t kInvalidHashCode; 00222 static const int32_t kEmptyHashCode; 00223 00224 UBool fBogus; 00225 int32_t fCount; 00226 int32_t fCapacity; 00227 int32_t fHashCode; 00228 uint8_t* fBytes; 00229 }; 00230 00231 inline UBool 00232 CollationKey::operator!=(const CollationKey& other) const 00233 { 00234 return !(*this == other); 00235 } 00236 00237 inline UBool 00238 CollationKey::isBogus() const 00239 { 00240 return fBogus; 00241 } 00242 00243 inline const uint8_t* 00244 CollationKey::getByteArray(int32_t &count) const 00245 { 00246 count = fCount; 00247 return fBytes; 00248 } 00249 00250 U_NAMESPACE_END 00251 00252 #endif