ICU 4.8.1.1  4.8.1.1
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
sortkey.h
Go to the documentation of this file.
1 /*
2  *****************************************************************************
3  * Copyright (C) 1996-2011, International Business Machines Corporation and others.
4  * All Rights Reserved.
5  *****************************************************************************
6  *
7  * File sortkey.h
8  *
9  * Created by: Helena Shih
10  *
11  * Modification History:
12  *
13  * Date Name Description
14  *
15  * 6/20/97 helena Java class name change.
16  * 8/18/97 helena Added internal API documentation.
17  * 6/26/98 erm Changed to use byte arrays and memcmp.
18  *****************************************************************************
19  */
20 
21 #ifndef SORTKEY_H
22 #define SORTKEY_H
23 
24 #include "unicode/utypes.h"
25 
31 #if !UCONFIG_NO_COLLATION
32 
33 #include "unicode/uobject.h"
34 #include "unicode/unistr.h"
35 #include "unicode/coll.h"
36 
38 
39 /* forward declaration */
40 class RuleBasedCollator;
41 
97 public:
105  CollationKey();
106 
107 
114  CollationKey(const uint8_t* values,
115  int32_t count);
116 
122  CollationKey(const CollationKey& other);
123 
128  virtual ~CollationKey();
129 
135  const CollationKey& operator=(const CollationKey& other);
136 
143  UBool operator==(const CollationKey& source) const;
144 
151  UBool operator!=(const CollationKey& source) const;
152 
153 
160  UBool isBogus(void) const;
161 
171  const uint8_t* getByteArray(int32_t& count) const;
172 
173 #ifdef U_USE_COLLATION_KEY_DEPRECATES
174 
181  uint8_t* toByteArray(int32_t& count) const;
182 #endif
183 
193  Collator::EComparisonResult compareTo(const CollationKey& target) const;
194 
205  UCollationResult compareTo(const CollationKey& target, UErrorCode &status) const;
206 
227  int32_t hashCode(void) const;
228 
233  virtual UClassID getDynamicClassID() const;
234 
239  static UClassID U_EXPORT2 getStaticClassID();
240 
241 private:
250  void adopt(uint8_t *values, int32_t capacity, int32_t count);
254  void setLength(int32_t newLength);
255 
256  /*
257  * Creates a collation key with a string.
258  */
259 
266  CollationKey& ensureCapacity(int32_t newSize);
271  CollationKey& setToBogus(void);
276  CollationKey& reset(void);
277 
281  friend class RuleBasedCollator;
285  UBool fBogus;
290  int32_t fCount;
294  int32_t fCapacity;
298  int32_t fHashCode;
302  uint8_t* fBytes;
303 
304 };
305 
306 inline UBool
308 {
309  return !(*this == other);
310 }
311 
312 inline UBool
314 {
315  return fBogus;
316 }
317 
318 inline const uint8_t*
319 CollationKey::getByteArray(int32_t &count) const
320 {
321  count = fCount;
322  return fBytes;
323 }
324 
326 
327 #endif /* #if !UCONFIG_NO_COLLATION */
328 
329 #endif
The RuleBasedCollator class provides the simple implementation of Collator, using data-driven tables...
Definition: tblcoll.h:111
UCollationResult
UCOL_LESS is returned if source string is compared to be less than target string in the u_strcoll() m...
Definition: ucol.h:77
UBool isBogus(void) const
Test to see if the key is in an invalid state.
Definition: sortkey.h:313
UBool operator!=(const CollationKey &source) const
Compare if two collation keys are not the same.
Definition: sortkey.h:307
C++ API: Unicode String.
EComparisonResult
LESS is returned if source string is compared to be less than target string in the compare() method...
Definition: coll.h:226
U_EXPORT UBool operator==(const StringPiece &x, const StringPiece &y)
Global operator == for StringPiece.
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside...
Definition: utypes.h:521
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:131
Collation keys are generated by the Collator class.
Definition: sortkey.h:96
C++ API: Collation Service.
const uint8_t * getByteArray(int32_t &count) const
Returns a pointer to the collation key values.
Definition: sortkey.h:319
#define U_EXPORT2
Definition: platform.h:314
UBool operator!=(const StringPiece &x, const StringPiece &y)
Global operator != for StringPiece.
Definition: stringpiece.h:218
C++ API: Common ICU base class UObject.
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:132
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:215
void * UClassID
UClassID is used to identify classes without using RTTI, since RTTI is not yet supported by all C++ c...
Definition: utypes.h:385
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers...
Definition: utypes.h:639
Basic definitions for ICU, for both C and C++ APIs.
virtual UClassID getDynamicClassID() const =0
ICU4C "poor man's RTTI", returns a UClassID for the actual ICU class.
int8_t UBool
The ICU boolean type.
Definition: umachine.h:228