ICU 4.8.1.1  4.8.1.1
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
colldata.h
Go to the documentation of this file.
1 /*
2  ******************************************************************************
3  * Copyright (C) 1996-2010, 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 
30 #define KEY_BUFFER_SIZE 64
31 
36 #define CELIST_BUFFER_SIZE 4
37 
44 //#define INSTRUMENT_CELIST
45 
50 #define STRING_LIST_BUFFER_SIZE 16
51 
58 //#define INSTRUMENT_STRING_LIST
59 
66 class U_I18N_API CEList : public UObject
67 {
68 public:
82  CEList(UCollator *coll, const UnicodeString &string, UErrorCode &status);
83 
88  ~CEList();
89 
97  int32_t size() const;
98 
108  uint32_t get(int32_t index) const;
109 
121  UBool matchesAt(int32_t offset, const CEList *other) const;
122 
132  uint32_t &operator[](int32_t index) const;
133 
138  virtual UClassID getDynamicClassID() const;
143  static UClassID getStaticClassID();
144 
145 private:
146  void add(uint32_t ce, UErrorCode &status);
147 
148  uint32_t ceBuffer[CELIST_BUFFER_SIZE];
149  uint32_t *ces;
150  int32_t listMax;
151  int32_t listSize;
152 
153 #ifdef INSTRUMENT_CELIST
154  static int32_t _active;
155  static int32_t _histogram[10];
156 #endif
157 };
158 
167 {
168 public:
180  StringList(UErrorCode &status);
181 
187  ~StringList();
188 
197  void add(const UnicodeString *string, UErrorCode &status);
198 
208  void add(const UChar *chars, int32_t count, UErrorCode &status);
209 
220  const UnicodeString *get(int32_t index) const;
221 
229  int32_t size() const;
230 
235  virtual UClassID getDynamicClassID() const;
240  static UClassID getStaticClassID();
241 
242 private:
243  UnicodeString *strings;
244  int32_t listMax;
245  int32_t listSize;
246 
247 #ifdef INSTRUMENT_STRING_LIST
248  static int32_t _lists;
249  static int32_t _strings;
250  static int32_t _histogram[101];
251 #endif
252 };
253 
254 /*
255  * Forward references to internal classes.
256  */
257 class StringToCEsMap;
258 class CEToStringsMap;
259 class CollDataCache;
260 
280 {
281 public:
297  static CollData *open(UCollator *collator, UErrorCode &status);
298 
306  static void close(CollData *collData);
307 
314  UCollator *getCollator() const;
315 
328  const StringList *getStringList(int32_t ce) const;
329 
341  const CEList *getCEList(const UnicodeString *string) const;
342 
350  void freeCEList(const CEList *list);
351 
363  int32_t minLengthInChars(const CEList *ces, int32_t offset) const;
364 
365 
385  int32_t minLengthInChars(const CEList *ces, int32_t offset, int32_t *history) const;
386 
391  virtual UClassID getDynamicClassID() const;
396  static UClassID getStaticClassID();
397 
410  static void freeCollDataCache();
411 
419  static void flushCollDataCache();
420 
421 private:
422  friend class CollDataCache;
423  friend class CollDataCacheEntry;
424 
425  CollData(UCollator *collator, char *cacheKey, int32_t cachekeyLength, UErrorCode &status);
426  ~CollData();
427 
428  CollData();
429 
430  static char *getCollatorKey(UCollator *collator, char *buffer, int32_t bufferLength);
431 
432  static CollDataCache *getCollDataCache();
433 
434  UCollator *coll;
435  StringToCEsMap *charsToCEList;
436  CEToStringsMap *ceToCharsStartingWith;
437 
438  char keyBuffer[KEY_BUFFER_SIZE];
439  char *key;
440 
441  static CollDataCache *collDataCache;
442 
443  uint32_t minHan;
444  uint32_t maxHan;
445 
446  uint32_t jamoLimits[4];
447 };
448 
450 
451 #endif // #if !UCONFIG_NO_COLLATION
452 #endif // #ifndef COLL_DATA_H
StringList.
Definition: colldata.h:166
#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
#define KEY_BUFFER_SIZE
The size of the internal buffer for the Collator's short description string.
Definition: colldata.h:30
C API: Collator.
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:188
C++ API: Common ICU base class UObject.
uint16_t UChar
Define UChar to be wchar_t if that is 16 bits wide; always assumed to be unsigned.
Definition: umachine.h:325
#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
This object holds a list of CEs generated from a particular UnicodeString
Definition: colldata.h:66
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:36
Basic definitions for ICU, for both C and C++ APIs.
CollData.
Definition: colldata.h:279
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