ICU 50.1.2  50.1.2
colldata.h
Go to the documentation of this file.
1 /*
2  ******************************************************************************
3  * Copyright (C) 1996-2012, International Business Machines *
4  * Corporation and others. All Rights Reserved. *
5  ******************************************************************************
6  */
7 
14 #ifndef COLL_DATA_H
15 #define COLL_DATA_H
16 
17 #include "unicode/utypes.h"
18 
19 #if !UCONFIG_NO_COLLATION
20 
21 #include "unicode/uobject.h"
22 #include "unicode/ucol.h"
23 
25 
26 #ifndef U_HIDE_INTERNAL_API
27 
31 #define KEY_BUFFER_SIZE 64
32 
37 #define CELIST_BUFFER_SIZE 4
38 
45 //#define INSTRUMENT_CELIST
46 
51 #define STRING_LIST_BUFFER_SIZE 16
52 
59 //#define INSTRUMENT_STRING_LIST
60 
67 class U_I18N_API CEList : public UObject
68 {
69 public:
83  CEList(UCollator *coll, const UnicodeString &string, UErrorCode &status);
84 
89  ~CEList();
90 
98  int32_t size() const;
99 
109  uint32_t get(int32_t index) const;
110 
122  UBool matchesAt(int32_t offset, const CEList *other) const;
123 
133  uint32_t &operator[](int32_t index) const;
134 
139  virtual UClassID getDynamicClassID() const;
144  static UClassID getStaticClassID();
145 
146 private:
147  void add(uint32_t ce, UErrorCode &status);
148 
149  uint32_t ceBuffer[CELIST_BUFFER_SIZE];
150  uint32_t *ces;
151  int32_t listMax;
152  int32_t listSize;
153 
154 #ifdef INSTRUMENT_CELIST
155  static int32_t _active;
156  static int32_t _histogram[10];
157 #endif
158 };
159 
168 {
169 public:
181  StringList(UErrorCode &status);
182 
188  ~StringList();
189 
198  void add(const UnicodeString *string, UErrorCode &status);
199 
209  void add(const UChar *chars, int32_t count, UErrorCode &status);
210 
221  const UnicodeString *get(int32_t index) const;
222 
230  int32_t size() const;
231 
236  virtual UClassID getDynamicClassID() const;
241  static UClassID getStaticClassID();
242 
243 private:
244  UnicodeString *strings;
245  int32_t listMax;
246  int32_t listSize;
247 
248 #ifdef INSTRUMENT_STRING_LIST
249  static int32_t _lists;
250  static int32_t _strings;
251  static int32_t _histogram[101];
252 #endif
253 };
254 #endif /* U_HIDE_INTERNAL_API */
255 
256 /*
257  * Forward references to internal classes.
258  */
259 class StringToCEsMap;
260 class CEToStringsMap;
261 class CollDataCache;
262 
263 #ifndef U_HIDE_INTERNAL_API
264 
283 {
284 public:
300  static CollData *open(UCollator *collator, UErrorCode &status);
301 
309  static void close(CollData *collData);
310 
317  UCollator *getCollator() const;
318 
331  const StringList *getStringList(int32_t ce) const;
332 
344  const CEList *getCEList(const UnicodeString *string) const;
345 
353  void freeCEList(const CEList *list);
354 
366  int32_t minLengthInChars(const CEList *ces, int32_t offset) const;
367 
368 
388  int32_t minLengthInChars(const CEList *ces, int32_t offset, int32_t *history) const;
389 
394  virtual UClassID getDynamicClassID() const;
399  static UClassID getStaticClassID();
400 
413  static void freeCollDataCache();
414 
422  static void flushCollDataCache();
423 
424 private:
425  friend class CollDataCache;
426  friend class CollDataCacheEntry;
427 
428  CollData(UCollator *collator, char *cacheKey, int32_t cachekeyLength, UErrorCode &status);
429  ~CollData();
430 
431  CollData();
432 
433  static char *getCollatorKey(UCollator *collator, char *buffer, int32_t bufferLength);
434 
435  static CollDataCache *getCollDataCache();
436 
437  UCollator *coll;
438  StringToCEsMap *charsToCEList;
439  CEToStringsMap *ceToCharsStartingWith;
440 
441  char keyBuffer[KEY_BUFFER_SIZE];
442  char *key;
443 
444  static CollDataCache *collDataCache;
445 
446  uint32_t minHan;
447  uint32_t maxHan;
448 
449  uint32_t jamoLimits[4];
450 };
451 #endif /* U_HIDE_INTERNAL_API */
452 
454 
455 #endif // #if !UCONFIG_NO_COLLATION
456 #endif // #ifndef COLL_DATA_H
CollData.
Definition: colldata.h:282
virtual UClassID getDynamicClassID() const =0
ICU4C "poor man's RTTI", returns a UClassID for the actual ICU class.
This object holds a list of CEs generated from a particular UnicodeString
Definition: colldata.h:67
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
Definition: uobject.h:96
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside...
Definition: utypes.h:358
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:129
#define KEY_BUFFER_SIZE
The size of the internal buffer for the Collator's short description string.
Definition: colldata.h:31
C API: Collator.
C++ API: Common ICU base class UObject.
uint16_t UChar
Define UChar to be UCHAR_TYPE, if that is #defined (for example, to char16_t), or wchar_t if that is ...
Definition: umachine.h:278
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:130
StringList.
Definition: colldata.h:167
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers...
Definition: utypes.h:476
struct UCollator UCollator
structure representing a collator object instance
Definition: ucol.h:62
#define CELIST_BUFFER_SIZE
The size of the internal CE buffer in a CEList object.
Definition: colldata.h:37
Basic definitions for ICU, for both C and C++ APIs.
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:246
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:229
int8_t UBool
The ICU boolean type.
Definition: umachine.h:200