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 #ifndef U_HIDE_INTERNAL_API
00027
00031 #define KEY_BUFFER_SIZE 64
00032
00037 #define CELIST_BUFFER_SIZE 4
00038
00045
00046
00051 #define STRING_LIST_BUFFER_SIZE 16
00052
00059
00060
00067 class U_I18N_API CEList : public UObject
00068 {
00069 public:
00083 CEList(UCollator *coll, const UnicodeString &string, UErrorCode &status);
00084
00089 ~CEList();
00090
00098 int32_t size() const;
00099
00109 uint32_t get(int32_t index) const;
00110
00122 UBool matchesAt(int32_t offset, const CEList *other) const;
00123
00133 uint32_t &operator[](int32_t index) const;
00134
00139 virtual UClassID getDynamicClassID() const;
00144 static UClassID getStaticClassID();
00145
00146 private:
00147 void add(uint32_t ce, UErrorCode &status);
00148
00149 uint32_t ceBuffer[CELIST_BUFFER_SIZE];
00150 uint32_t *ces;
00151 int32_t listMax;
00152 int32_t listSize;
00153
00154 #ifdef INSTRUMENT_CELIST
00155 static int32_t _active;
00156 static int32_t _histogram[10];
00157 #endif
00158 };
00159
00167 class U_I18N_API StringList : public UObject
00168 {
00169 public:
00181 StringList(UErrorCode &status);
00182
00188 ~StringList();
00189
00198 void add(const UnicodeString *string, UErrorCode &status);
00199
00209 void add(const UChar *chars, int32_t count, UErrorCode &status);
00210
00221 const UnicodeString *get(int32_t index) const;
00222
00230 int32_t size() const;
00231
00236 virtual UClassID getDynamicClassID() const;
00241 static UClassID getStaticClassID();
00242
00243 private:
00244 UnicodeString *strings;
00245 int32_t listMax;
00246 int32_t listSize;
00247
00248 #ifdef INSTRUMENT_STRING_LIST
00249 static int32_t _lists;
00250 static int32_t _strings;
00251 static int32_t _histogram[101];
00252 #endif
00253 };
00254 #endif
00255
00256
00257
00258
00259 class StringToCEsMap;
00260 class CEToStringsMap;
00261 class CollDataCache;
00262
00263 #ifndef U_HIDE_INTERNAL_API
00264
00282 class U_I18N_API CollData : public UObject
00283 {
00284 public:
00300 static CollData *open(UCollator *collator, UErrorCode &status);
00301
00309 static void close(CollData *collData);
00310
00317 UCollator *getCollator() const;
00318
00331 const StringList *getStringList(int32_t ce) const;
00332
00344 const CEList *getCEList(const UnicodeString *string) const;
00345
00353 void freeCEList(const CEList *list);
00354
00366 int32_t minLengthInChars(const CEList *ces, int32_t offset) const;
00367
00368
00388 int32_t minLengthInChars(const CEList *ces, int32_t offset, int32_t *history) const;
00389
00394 virtual UClassID getDynamicClassID() const;
00399 static UClassID getStaticClassID();
00400
00413 static void freeCollDataCache();
00414
00422 static void flushCollDataCache();
00423
00424 private:
00425 friend class CollDataCache;
00426 friend class CollDataCacheEntry;
00427
00428 CollData(UCollator *collator, char *cacheKey, int32_t cachekeyLength, UErrorCode &status);
00429 ~CollData();
00430
00431 CollData();
00432
00433 static char *getCollatorKey(UCollator *collator, char *buffer, int32_t bufferLength);
00434
00435 static CollDataCache *getCollDataCache();
00436
00437 UCollator *coll;
00438 StringToCEsMap *charsToCEList;
00439 CEToStringsMap *ceToCharsStartingWith;
00440
00441 char keyBuffer[KEY_BUFFER_SIZE];
00442 char *key;
00443
00444 static CollDataCache *collDataCache;
00445
00446 uint32_t minHan;
00447 uint32_t maxHan;
00448
00449 uint32_t jamoLimits[4];
00450 };
00451 #endif
00452
00453 U_NAMESPACE_END
00454
00455 #endif // #if !UCONFIG_NO_COLLATION
00456 #endif // #ifndef COLL_DATA_H