/* * Copyright © {1996-1999}, International Business Machines Corporation and others. All Rights Reserved. ***************************************************************************************** */ //=============================================================================== // // File sortkey.h // // // // Created by: Helena Shih // // Modification History: // // Date Name Description // // 6/20/97 helena Java class name change. // 8/18/97 helena Added internal API documentation. // 6/26/98 erm Changed to use byte arrays and memcmp. //=============================================================================== #ifndef SORTKEY_H #define SORTKEY_H #include "unicode/utypes.h" #include "unicode/unistr.h" #include "unicode/coll.h" /* forward declaration */ class RuleBasedCollator; class U_I18N_API CollationKey { public: CollationKey(); CollationKey(const uint8_t* values, int32_t count); CollationKey(const CollationKey& other); ~CollationKey(); const CollationKey& operator=(const CollationKey& other); UBool operator==(const CollationKey& source) const; UBool operator!=(const CollationKey& source) const; UBool isBogus(void) const; const uint8_t* getByteArray(int32_t& count) const; uint8_t* toByteArray(int32_t& count) const; Collator::EComparisonResult compareTo(const CollationKey& target) const; int32_t hashCode(void) const; private: uint16_t* copyValues(int32_t &size) const; /* * Creates a collation key with a string. */ CollationKey(const UnicodeString& value); int32_t storeBytes(int32_t cursor, uint32_t byteValue); int32_t storeUnicodeString(int32_t cursor, const UnicodeString &value); void reverseBytes(int32_t from, int32_t to); CollationKey& ensureCapacity(int32_t newSize); CollationKey& copyUnicodeString(const UnicodeString &value); CollationKey& setToBogus(void); CollationKey& reset(void); friend class RuleBasedCollator; static const int32_t kInvalidHashCode; static const int32_t kEmptyHashCode; UBool fBogus; int32_t fCount; int32_t fCapacity; int32_t fHashCode; uint8_t* fBytes; }; inline UBool CollationKey::operator!=(const CollationKey& other) const { return !(*this == other); } inline UBool CollationKey::isBogus() const { return fBogus; } inline const uint8_t* CollationKey::getByteArray(int32_t &count) const { count = fCount; return fBytes; } inline UTextOffset CollationKey::storeBytes(UTextOffset cursor, uint32_t byteValue) { fBytes[cursor++] = (uint8_t) (byteValue >> 8); fBytes[cursor++] = (uint8_t) byteValue; return cursor; } #endif