00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef SORTKEY_H
00021 #define SORTKEY_H
00022
00023 #include "unicode/utypes.h"
00024
00025 #if !UCONFIG_NO_COLLATION
00026
00027 #include "unicode/uobject.h"
00028 #include "unicode/unistr.h"
00029 #include "unicode/coll.h"
00030
00031 U_NAMESPACE_BEGIN
00032
00033
00034 class RuleBasedCollator;
00035
00089 class U_I18N_API CollationKey : public UObject {
00090 public:
00098 CollationKey();
00099
00100
00108 CollationKey(const uint8_t* values,
00109 int32_t count);
00110
00116 CollationKey(const CollationKey& other);
00117
00122 virtual ~CollationKey();
00123
00129 const CollationKey& operator=(const CollationKey& other);
00130
00137 UBool operator==(const CollationKey& source) const;
00138
00145 UBool operator!=(const CollationKey& source) const;
00146
00147
00154 UBool isBogus(void) const;
00155
00165 const uint8_t* getByteArray(int32_t& count) const;
00166
00167 #ifdef U_USE_COLLATION_KEY_DEPRECATES
00168
00175 uint8_t* toByteArray(int32_t& count) const;
00176 #endif
00177
00187 Collator::EComparisonResult compareTo(const CollationKey& target) const;
00188
00199 UCollationResult compareTo(const CollationKey& target, UErrorCode &status) const;
00200
00221 int32_t hashCode(void) const;
00222
00227 virtual UClassID getDynamicClassID() const;
00228
00233 static UClassID U_EXPORT2 getStaticClassID();
00234
00235 private:
00243 void adopt(uint8_t *values, int32_t count);
00244
00245
00246
00247
00248
00255 CollationKey& ensureCapacity(int32_t newSize);
00260 CollationKey& setToBogus(void);
00265 CollationKey& reset(void);
00266
00270 friend class RuleBasedCollator;
00274 UBool fBogus;
00279 int32_t fCount;
00283 int32_t fCapacity;
00287 int32_t fHashCode;
00291 uint8_t* fBytes;
00292
00293 };
00294
00295 inline UBool
00296 CollationKey::operator!=(const CollationKey& other) const
00297 {
00298 return !(*this == other);
00299 }
00300
00301 inline UBool
00302 CollationKey::isBogus() const
00303 {
00304 return fBogus;
00305 }
00306
00307 inline const uint8_t*
00308 CollationKey::getByteArray(int32_t &count) const
00309 {
00310 count = fCount;
00311 return fBytes;
00312 }
00313
00314 U_NAMESPACE_END
00315
00316 #endif
00317
00318 #endif