00001
00002
00003
00004
00005
00006
00007
00014 #ifndef COLL_DATA_H
00015 #define COLL_DATA_H
00016
00017 #include "unicode/utypes.h"
00018
00019 #if !UCONFIG_NO_COLLATION
00020
00021 #include "unicode/uobject.h"
00022 #include "unicode/ucol.h"
00023
00024 U_NAMESPACE_BEGIN
00025
00026
00027
00028
00029 #define KEY_BUFFER_SIZE 64
00030
00031
00032
00033
00034 #define CELIST_BUFFER_SIZE 4
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045 #define STRING_LIST_BUFFER_SIZE 16
00046
00047
00048
00049
00050
00051
00052
00061 class U_I18N_API CEList : public UObject
00062 {
00063 public:
00077 CEList(UCollator *coll, const UnicodeString &string, UErrorCode &status);
00078
00082 ~CEList();
00083
00091 int32_t size() const;
00092
00102 uint32_t get(int32_t index) const;
00103
00115 UBool matchesAt(int32_t offset, const CEList *other) const;
00116
00126 uint32_t &operator[](int32_t index) const;
00127
00128
00129
00130
00131 virtual UClassID getDynamicClassID() const;
00132 static UClassID getStaticClassID();
00133
00134 private:
00135 void add(uint32_t ce, UErrorCode &status);
00136
00137 uint32_t ceBuffer[CELIST_BUFFER_SIZE];
00138 uint32_t *ces;
00139 int32_t listMax;
00140 int32_t listSize;
00141
00142 #ifdef INSTRUMENT_CELIST
00143 static int32_t _active;
00144 static int32_t _histogram[10];
00145 #endif
00146 };
00147
00155 class U_I18N_API StringList : public UObject
00156 {
00157 public:
00169 StringList(UErrorCode &status);
00170
00176 ~StringList();
00177
00186 void add(const UnicodeString *string, UErrorCode &status);
00187
00197 void add(const UChar *chars, int32_t count, UErrorCode &status);
00198
00209 const UnicodeString *get(int32_t index) const;
00210
00218 int32_t size() const;
00219
00220
00221
00222
00223 virtual UClassID getDynamicClassID() const;
00224 static UClassID getStaticClassID();
00225
00226 private:
00227 UnicodeString *strings;
00228 int32_t listMax;
00229 int32_t listSize;
00230
00231 #ifdef INSTRUMENT_STRING_LIST
00232 static int32_t _lists;
00233 static int32_t _strings;
00234 static int32_t _histogram[101];
00235 #endif
00236 };
00237
00238
00239
00240
00241 class StringToCEsMap;
00242 class CEToStringsMap;
00243 class CollDataCache;
00244
00263 class U_I18N_API CollData : public UObject
00264 {
00265 public:
00281 static CollData *open(UCollator *collator, UErrorCode &status);
00282
00290 static void close(CollData *collData);
00291
00297 UCollator *getCollator() const;
00298
00311 const StringList *getStringList(int32_t ce) const;
00312
00324 const CEList *getCEList(const UnicodeString *string) const;
00325
00333 void freeCEList(const CEList *list);
00334
00346 int32_t minLengthInChars(const CEList *ces, int32_t offset) const;
00347
00348
00368 int32_t minLengthInChars(const CEList *ces, int32_t offset, int32_t *history) const;
00369
00370
00371
00372
00373 virtual UClassID getDynamicClassID() const;
00374 static UClassID getStaticClassID();
00375
00388 static void freeCollDataCache();
00389
00397 static void flushCollDataCache();
00398
00399 private:
00400 friend class CollDataCache;
00401 friend class CollDataCacheEntry;
00402
00403 CollData(UCollator *collator, char *cacheKey, int32_t cachekeyLength, UErrorCode &status);
00404 ~CollData();
00405
00406 CollData();
00407
00408 static char *getCollatorKey(UCollator *collator, char *buffer, int32_t bufferLength);
00409
00410 static CollDataCache *getCollDataCache();
00411
00412 UCollator *coll;
00413 StringToCEsMap *charsToCEList;
00414 CEToStringsMap *ceToCharsStartingWith;
00415
00416 char keyBuffer[KEY_BUFFER_SIZE];
00417 char *key;
00418
00419 static CollDataCache *collDataCache;
00420
00421 uint32_t minHan;
00422 uint32_t maxHan;
00423
00424 uint32_t jamoLimits[4];
00425 };
00426
00427 U_NAMESPACE_END
00428
00429 #endif // #if !UCONFIG_NO_COLLATION
00430 #endif // #ifndef COLL_DATA_H