Main Page   Class Hierarchy   Alphabetical List   Data Structures   File List   Data Fields   Globals  

sortkey.h

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);
00108 
00113     CollationKey(const CollationKey& other);
00114 
00119     ~CollationKey();
00120 
00125     const   CollationKey&   operator=(const CollationKey& other);
00126 
00133     UBool                   operator==(const CollationKey& source) const;
00134 
00141     UBool                   operator!=(const CollationKey& source) const;
00142 
00143 
00150     UBool                   isBogus(void) const;
00151 
00160     const    uint8_t*       getByteArray(int32_t& count) const;
00161 
00169     uint8_t*                toByteArray(int32_t& count) const;
00170 
00181     Collator::EComparisonResult compareTo(const CollationKey& target) const;
00182 
00203     int32_t                 hashCode(void) const;
00204 
00205 private:
00212     void adopt(uint8_t *values, int32_t count);
00213 
00214     /*
00215     * Creates a collation key with a string.
00216     */
00217     CollationKey&           ensureCapacity(int32_t newSize);
00218     CollationKey&           setToBogus(void);
00219     CollationKey&           reset(void);
00220 
00221     friend  class           RuleBasedCollator;
00222 
00223     UBool                   fBogus;
00224     int32_t                 fCount;
00225     int32_t                 fCapacity;
00226     int32_t                 fHashCode;
00227     uint8_t*                fBytes;
00228 };
00229 
00230 inline UBool
00231 CollationKey::operator!=(const CollationKey& other) const
00232 {
00233     return !(*this == other);
00234 }
00235 
00236 inline UBool
00237 CollationKey::isBogus() const
00238 {
00239     return fBogus;
00240 }
00241 
00242 inline const uint8_t*
00243 CollationKey::getByteArray(int32_t &count) const
00244 {
00245     count = fCount;
00246     return fBytes;
00247 }
00248 
00249 U_NAMESPACE_END
00250 
00251 #endif

Generated on Mon Mar 4 23:12:34 2002 for ICU 2.0 by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002