ICU 4.2.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-2006, 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:
249  void adopt(uint8_t *values, int32_t count);
250 
251  /*
252  * Creates a collation key with a string.
253  */
254 
261  CollationKey& ensureCapacity(int32_t newSize);
266  CollationKey& setToBogus(void);
271  CollationKey& reset(void);
272 
276  friend class RuleBasedCollator;
280  UBool fBogus;
285  int32_t fCount;
289  int32_t fCapacity;
293  int32_t fHashCode;
297  uint8_t* fBytes;
298 
299 };
300 
301 inline UBool
303 {
304  return !(*this == other);
305 }
306 
307 inline UBool
309 {
310  return fBogus;
311 }
312 
313 inline const uint8_t*
315 {
316  count = fCount;
317  return fBytes;
318 }
319 
321 
322 #endif /* #if !UCONFIG_NO_COLLATION */
323 
324 #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:75
UBool isBogus(void) const
Test to see if the key is in an invalid state.
Definition: sortkey.h:308
UBool operator!=(const CollationKey &source) const
Compare if two collation keys are not the same.
Definition: sortkey.h:302
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
unsigned char uint8_t
Define 64 bit limits.
Definition: pwin32.h:131
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside...
Definition: utypes.h:475
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:183
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:314
#define U_EXPORT2
Definition: platform.h:338
C++ API: Common ICU base class UObject.
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API If the compiler doesn't support namespaces...
Definition: uversion.h:184
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:212
void * UClassID
UClassID is used to identify classes without using RTTI, since RTTI is not yet supported by all C++ c...
Definition: utypes.h:339
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers...
Definition: utypes.h:593
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.
signed int int32_t
Define 64 bit limits.
Definition: pwin32.h:143
int8_t UBool
The ICU boolean type.
Definition: umachine.h:208