ICU 49.1.1  49.1.1
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 #ifndef U_HIDE_DEPRECATED_API
33 
34 #include "unicode/uobject.h"
35 #include "unicode/unistr.h"
36 #include "unicode/coll.h"
37 
39 
40 /* forward declaration */
41 class RuleBasedCollator;
42 
98 public:
106  CollationKey();
107 
108 
115  CollationKey(const uint8_t* values,
116  int32_t count);
117 
123  CollationKey(const CollationKey& other);
124 
129  virtual ~CollationKey();
130 
136  const CollationKey& operator=(const CollationKey& other);
137 
144  UBool operator==(const CollationKey& source) const;
145 
152  UBool operator!=(const CollationKey& source) const;
153 
154 
161  UBool isBogus(void) const;
162 
172  const uint8_t* getByteArray(int32_t& count) const;
173 
174 #ifdef U_USE_COLLATION_KEY_DEPRECATES
175 
182  uint8_t* toByteArray(int32_t& count) const;
183 #endif
184 
194  Collator::EComparisonResult compareTo(const CollationKey& target) const;
195 
206  UCollationResult compareTo(const CollationKey& target, UErrorCode &status) const;
207 
228  int32_t hashCode(void) const;
229 
234  virtual UClassID getDynamicClassID() const;
235 
240  static UClassID U_EXPORT2 getStaticClassID();
241 
242 private:
251  void adopt(uint8_t *values, int32_t capacity, int32_t count);
255  void setLength(int32_t newLength);
256 
257  /*
258  * Creates a collation key with a string.
259  */
260 
267  CollationKey& ensureCapacity(int32_t newSize);
272  CollationKey& setToBogus(void);
277  CollationKey& reset(void);
278 
282  friend class RuleBasedCollator;
286  UBool fBogus;
291  int32_t fCount;
295  int32_t fCapacity;
299  int32_t fHashCode;
303  uint8_t* fBytes;
304 
305 };
306 
307 inline UBool
309 {
310  return !(*this == other);
311 }
312 
313 inline UBool
315 {
316  return fBogus;
317 }
318 
319 inline const uint8_t*
320 CollationKey::getByteArray(int32_t &count) const
321 {
322  count = fCount;
323  return fBytes;
324 }
325 
327 
328 #endif /* U_HIDE_DEPRECATED_API */
329 #endif /* #if !UCONFIG_NO_COLLATION */
330 
331 #endif