sortkey.h

00001 /*
00002  * Copyright (C) 1996-2004, 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 
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 /* forward declaration */
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     * Creates a collation key with a string.
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 /* #if !UCONFIG_NO_COLLATION */
00317 
00318 #endif

Generated on Tue Nov 16 10:03:06 2004 for ICU 3.2 by  doxygen 1.3.9.1