Main Page | Class Hierarchy | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

sortkey.h

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 
00090 class U_I18N_API CollationKey : public UObject {
00091 public:
00099     CollationKey();
00100 
00101 
00109     CollationKey(const  uint8_t*    values,
00110                 int32_t     count);
00111 
00117     CollationKey(const CollationKey& other);
00118 
00123     ~CollationKey();
00124 
00130     const   CollationKey&   operator=(const CollationKey& other);
00131 
00138     UBool                   operator==(const CollationKey& source) const;
00139 
00146     UBool                   operator!=(const CollationKey& source) const;
00147 
00148 
00155     UBool                   isBogus(void) const;
00156 
00166     const    uint8_t*       getByteArray(int32_t& count) const;
00167 
00168 #ifdef U_USE_COLLATION_KEY_DEPRECATES
00169 
00176     uint8_t*                toByteArray(int32_t& count) const;
00177 #endif
00178 
00188     Collator::EComparisonResult compareTo(const CollationKey& target) const;
00189 
00200     UCollationResult compareTo(const CollationKey& target, UErrorCode &status) const;
00201 
00222     int32_t                 hashCode(void) const;
00223 
00229     virtual inline UClassID getDynamicClassID() const;
00230 
00236     static inline UClassID getStaticClassID();
00237 
00238 private:
00246     void adopt(uint8_t *values, int32_t count);
00247 
00248     /*
00249     * Creates a collation key with a string.
00250     */
00251 
00258     CollationKey&           ensureCapacity(int32_t newSize);
00263     CollationKey&           setToBogus(void);
00268     CollationKey&           reset(void);
00269         
00273     friend  class           RuleBasedCollator;
00277     UBool                   fBogus;
00282     int32_t                 fCount;
00286     int32_t                 fCapacity;
00290     int32_t                 fHashCode;
00294     uint8_t*                fBytes;
00295 
00300     static const char fgClassID;
00301 };
00302 
00303 inline UClassID
00304 CollationKey::getStaticClassID()
00305 { return (UClassID)&fgClassID; }
00306 
00307 inline UClassID
00308 CollationKey::getDynamicClassID() const
00309 { return CollationKey::getStaticClassID(); }
00310 
00311 inline UBool
00312 CollationKey::operator!=(const CollationKey& other) const
00313 {
00314     return !(*this == other);
00315 }
00316 
00317 inline UBool
00318 CollationKey::isBogus() const
00319 {
00320     return fBogus;
00321 }
00322 
00323 inline const uint8_t*
00324 CollationKey::getByteArray(int32_t &count) const
00325 {
00326     count = fCount;
00327     return fBytes;
00328 }
00329 
00330 U_NAMESPACE_END
00331 
00332 #endif /* #if !UCONFIG_NO_COLLATION */
00333 
00334 #endif

Generated on Wed Sep 3 17:47:09 2003 for ICU 2.6 by doxygen 1.3.2