00001 /*
00002 * Copyright (C) {1996-2003}, 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 #include "unicode/utypes.h"
00026
00027 #if !UCONFIG_NO_COLLATION
00028
00029 #include "unicode/uobject.h"
00030 #include "unicode/unistr.h"
00031 #include "unicode/coll.h"
00032
00033 U_NAMESPACE_BEGIN
00034
00035 /* forward declaration */
00036 class RuleBasedCollator;
00037
00091 class U_I18N_API CollationKey : public UObject {
00092 public:
00100 CollationKey();
00101
00102
00110 CollationKey(const uint8_t* values,
00111 int32_t count);
00112
00118 CollationKey(const CollationKey& other);
00119
00124 ~CollationKey();
00125
00131 const CollationKey& operator=(const CollationKey& other);
00132
00139 UBool operator==(const CollationKey& source) const;
00140
00147 UBool operator!=(const CollationKey& source) const;
00148
00149
00156 UBool isBogus(void) const;
00157
00167 const uint8_t* getByteArray(int32_t& count) const;
00168
00169 #ifdef U_USE_COLLATION_KEY_DEPRECATES
00177 uint8_t* toByteArray(int32_t& count) const;
00178 #endif
00179
00189 Collator::EComparisonResult compareTo(const CollationKey& target) const;
00190
00201 UCollationResult compareTo(const CollationKey& target, UErrorCode &status) const;
00202
00223 int32_t hashCode(void) const;
00224
00229 virtual UClassID getDynamicClassID() const;
00230
00235 static UClassID getStaticClassID();
00236
00237 private:
00245 void adopt(uint8_t *values, int32_t count);
00246
00247 /*
00248 * Creates a collation key with a string.
00249 */
00250
00257 CollationKey& ensureCapacity(int32_t newSize);
00262 CollationKey& setToBogus(void);
00267 CollationKey& reset(void);
00268
00272 friend class RuleBasedCollator;
00276 UBool fBogus;
00281 int32_t fCount;
00285 int32_t fCapacity;
00289 int32_t fHashCode;
00293 uint8_t* fBytes;
00294
00295 };
00296
00297 inline UBool
00298 CollationKey::operator!=(const CollationKey& other) const
00299 {
00300 return !(*this == other);
00301 }
00302
00303 inline UBool
00304 CollationKey::isBogus() const
00305 {
00306 return fBogus;
00307 }
00308
00309 inline const uint8_t*
00310 CollationKey::getByteArray(int32_t &count) const
00311 {
00312 count = fCount;
00313 return fBytes;
00314 }
00315
00316 U_NAMESPACE_END
00317
00318 #endif /* #if !UCONFIG_NO_COLLATION */
00319
00320 #endif
1.2.11.1 written by Dimitri van Heesch,
© 1997-2001