ICU 4.2.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-2009, 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 
29 #define KEY_BUFFER_SIZE 64
30 
34 #define CELIST_BUFFER_SIZE 4
35 
40 //#define INSTRUMENT_CELIST
41 
45 #define STRING_LIST_BUFFER_SIZE 16
46 
51 //#define INSTRUMENT_STRING_LIST
52 
59 class U_I18N_API CEList : public UObject
60 {
61 public:
75  CEList(UCollator *coll, const UnicodeString &string, UErrorCode &status);
76 
80  ~CEList();
81 
89  int32_t size() const;
90 
100  uint32_t get(int32_t index) const;
101 
113  UBool matchesAt(int32_t offset, const CEList *other) const;
114 
124  uint32_t &operator[](int32_t index) const;
125 
129  virtual UClassID getDynamicClassID() const;
133  static UClassID getStaticClassID();
134 
135 private:
136  void add(uint32_t ce, UErrorCode &status);
137 
138  uint32_t ceBuffer[CELIST_BUFFER_SIZE];
139  uint32_t *ces;
140  int32_t listMax;
141  int32_t listSize;
142 
143 #ifdef INSTRUMENT_CELIST
144  static int32_t _active;
145  static int32_t _histogram[10];
146 #endif
147 };
148 
157 {
158 public:
170  StringList(UErrorCode &status);
171 
177  ~StringList();
178 
187  void add(const UnicodeString *string, UErrorCode &status);
188 
198  void add(const UChar *chars, int32_t count, UErrorCode &status);
199 
210  const UnicodeString *get(int32_t index) const;
211 
219  int32_t size() const;
220 
224  virtual UClassID getDynamicClassID() const;
228  static UClassID getStaticClassID();
229 
230 private:
231  UnicodeString *strings;
232  int32_t listMax;
233  int32_t listSize;
234 
235 #ifdef INSTRUMENT_STRING_LIST
236  static int32_t _lists;
237  static int32_t _strings;
238  static int32_t _histogram[101];
239 #endif
240 };
241 
242 /*
243  * Forward references to internal classes.
244  */
245 class StringToCEsMap;
246 class CEToStringsMap;
247 class CollDataCache;
248 
268 {
269 public:
285  static CollData *open(UCollator *collator, UErrorCode &status);
286 
294  static void close(CollData *collData);
295 
301  UCollator *getCollator() const;
302 
315  const StringList *getStringList(int32_t ce) const;
316 
328  const CEList *getCEList(const UnicodeString *string) const;
329 
337  void freeCEList(const CEList *list);
338 
350  int32_t minLengthInChars(const CEList *ces, int32_t offset) const;
351 
352 
372  int32_t minLengthInChars(const CEList *ces, int32_t offset, int32_t *history) const;
373 
377  virtual UClassID getDynamicClassID() const;
381  static UClassID getStaticClassID();
382 
395  static void freeCollDataCache();
396 
404  static void flushCollDataCache();
405 
406 private:
407  friend class CollDataCache;
408  friend class CollDataCacheEntry;
409 
410  CollData(UCollator *collator, char *cacheKey, int32_t cachekeyLength, UErrorCode &status);
411  ~CollData();
412 
413  CollData();
414 
415  static char *getCollatorKey(UCollator *collator, char *buffer, int32_t bufferLength);
416 
417  static CollDataCache *getCollDataCache();
418 
419  UCollator *coll;
420  StringToCEsMap *charsToCEList;
421  CEToStringsMap *ceToCharsStartingWith;
422 
423  char keyBuffer[KEY_BUFFER_SIZE];
424  char *key;
425 
426  static CollDataCache *collDataCache;
427 
428  uint32_t minHan;
429  uint32_t maxHan;
430 
431  uint32_t jamoLimits[4];
432 };
433 
435 
436 #endif // #if !UCONFIG_NO_COLLATION
437 #endif // #ifndef COLL_DATA_H
StringList.
Definition: colldata.h:156
unsigned int uint32_t
Define 64 bit limits.
Definition: pwin32.h:147
#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
#define KEY_BUFFER_SIZE
The size of the internal buffer for the Collator's short description string.
Definition: colldata.h:29
C API: Collator.
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:187
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:299
#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
Define this to enable the StringList objects to collect statistics.
Definition: colldata.h:59
struct UCollator UCollator
structure representing a collator object instance
Definition: ucol.h:60
#define CELIST_BUFFER_SIZE
The size of the internal CE buffer in a CEList object.
Definition: colldata.h:34
Basic definitions for ICU, for both C and C++ APIs.
CollData.
Definition: colldata.h:267
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