sortkey.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 1996-2005, International Business Machines Corporation and others.
00003  * All Rights Reserved.
00004  *****************************************************************************************
00005  *
00006  * File sortkey.h
00007  *
00008  * Created by: Helena Shih
00009  *
00010  * Modification History:
00011  *
00012  *  Date         Name          Description
00013  *
00014  *  6/20/97     helena      Java class name change.
00015  *  8/18/97     helena      Added internal API documentation.
00016  *  6/26/98     erm         Changed to use byte arrays and memcmp.
00017  *****************************************************************************************
00018  */
00019 
00020 #ifndef SORTKEY_H
00021 #define SORTKEY_H
00022 
00023 #include "unicode/utypes.h"
00024 
00030 #if !UCONFIG_NO_COLLATION
00031 
00032 #include "unicode/uobject.h"
00033 #include "unicode/unistr.h"
00034 #include "unicode/coll.h"
00035 
00036 U_NAMESPACE_BEGIN
00037 
00038 /* forward declaration */
00039 class RuleBasedCollator;
00040 
00095 class U_I18N_API CollationKey : public UObject {
00096 public:
00104     CollationKey();
00105 
00106 
00114     CollationKey(const  uint8_t*    values,
00115                 int32_t     count);
00116 
00122     CollationKey(const CollationKey& other);
00123 
00128     virtual ~CollationKey();
00129 
00135     const   CollationKey&   operator=(const CollationKey& other);
00136 
00143     UBool                   operator==(const CollationKey& source) const;
00144 
00151     UBool                   operator!=(const CollationKey& source) const;
00152 
00153 
00160     UBool                   isBogus(void) const;
00161 
00171     const    uint8_t*       getByteArray(int32_t& count) const;
00172 
00173 #ifdef U_USE_COLLATION_KEY_DEPRECATES
00174 
00181     uint8_t*                toByteArray(int32_t& count) const;
00182 #endif
00183 
00193     Collator::EComparisonResult compareTo(const CollationKey& target) const;
00194 
00205     UCollationResult compareTo(const CollationKey& target, UErrorCode &status) const;
00206 
00227     int32_t                 hashCode(void) const;
00228 
00233     virtual UClassID getDynamicClassID() const;
00234 
00239     static UClassID U_EXPORT2 getStaticClassID();
00240 
00241 private:
00249     void adopt(uint8_t *values, int32_t count);
00250 
00251     /*
00252     * Creates a collation key with a string.
00253     */
00254 
00261     CollationKey&           ensureCapacity(int32_t newSize);
00266     CollationKey&           setToBogus(void);
00271     CollationKey&           reset(void);
00272     
00276     friend  class           RuleBasedCollator;
00280     UBool                   fBogus;
00285     int32_t                 fCount;
00289     int32_t                 fCapacity;
00293     int32_t                 fHashCode;
00297     uint8_t*                fBytes;
00298 
00299 };
00300 
00301 inline UBool
00302 CollationKey::operator!=(const CollationKey& other) const
00303 {
00304     return !(*this == other);
00305 }
00306 
00307 inline UBool
00308 CollationKey::isBogus() const
00309 {
00310     return fBogus;
00311 }
00312 
00313 inline const uint8_t*
00314 CollationKey::getByteArray(int32_t &count) const
00315 {
00316     count = fCount;
00317     return fBytes;
00318 }
00319 
00320 U_NAMESPACE_END
00321 
00322 #endif /* #if !UCONFIG_NO_COLLATION */
00323 
00324 #endif

Generated on Tue Feb 28 01:37:39 2006 for ICU 3.4 by  doxygen 1.4.4