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/uobject.h" 00028 #include "unicode/unistr.h" 00029 #include "unicode/coll.h" 00030 00031 U_NAMESPACE_BEGIN 00032 00033 /* forward declaration */ 00034 class RuleBasedCollator; 00035 00088 class U_I18N_API CollationKey : public UObject { 00089 public: 00097 CollationKey(); 00098 00099 00107 CollationKey(const uint8_t* values, 00108 int32_t count); 00109 00115 CollationKey(const CollationKey& other); 00116 00121 ~CollationKey(); 00122 00128 const CollationKey& operator=(const CollationKey& other); 00129 00136 UBool operator==(const CollationKey& source) const; 00137 00144 UBool operator!=(const CollationKey& source) const; 00145 00146 00153 UBool isBogus(void) const; 00154 00164 const uint8_t* getByteArray(int32_t& count) const; 00165 00173 uint8_t* toByteArray(int32_t& count) const; 00174 00184 Collator::EComparisonResult compareTo(const CollationKey& target) const; 00185 00206 int32_t hashCode(void) const; 00207 00213 virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } 00214 00220 static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } 00221 00222 private: 00230 void adopt(uint8_t *values, int32_t count); 00231 00232 /* 00233 * Creates a collation key with a string. 00234 */ 00235 00242 CollationKey& ensureCapacity(int32_t newSize); 00247 CollationKey& setToBogus(void); 00252 CollationKey& reset(void); 00253 00257 friend class RuleBasedCollator; 00261 UBool fBogus; 00266 int32_t fCount; 00270 int32_t fCapacity; 00274 int32_t fHashCode; 00278 uint8_t* fBytes; 00279 00284 static const char fgClassID; 00285 }; 00286 00287 inline UBool 00288 CollationKey::operator!=(const CollationKey& other) const 00289 { 00290 return !(*this == other); 00291 } 00292 00293 inline UBool 00294 CollationKey::isBogus() const 00295 { 00296 return fBogus; 00297 } 00298 00299 inline const uint8_t* 00300 CollationKey::getByteArray(int32_t &count) const 00301 { 00302 count = fCount; 00303 return fBytes; 00304 } 00305 00306 U_NAMESPACE_END 00307 00308 #endif