- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- Search for |

- File List
- Globals

# colldata.h

Go to the documentation of this file.

    00001 /*
    00002  ******************************************************************************
    00003  *   Copyright (C) 1996-2009, International Business Machines                 *
    00004  *   Corporation and others.  All Rights Reserved.                            *
    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
    00029 #define KEY_BUFFER_SIZE 64
    00030
    00034 #define CELIST_BUFFER_SIZE 4
    00035
    00040 //#define INSTRUMENT_CELIST
    00041
    00045 #define STRING_LIST_BUFFER_SIZE 16
    00046
    00051 //#define INSTRUMENT_STRING_LIST
    00052
    00059 class U_I18N_API CEList : public UObject
    00060 {
    00061 public:
    00075     CEList(UCollator *coll, const UnicodeString &string, UErrorCode &status);
    00076
    00080     ~CEList();
    00081
    00089     int32_t size() const;
    00090
    00100     uint32_t get(int32_t index) const;
    00101
    00113     UBool matchesAt(int32_t offset, const CEList *other) const;
    00114
    00124     uint32_t &operator[](int32_t index) const;
    00125
    00129     virtual UClassID getDynamicClassID() const;
    00133     static UClassID getStaticClassID();
    00134
    00135 private:
    00136     void add(uint32_t ce, UErrorCode &status);
    00137
    00138     uint32_t ceBuffer[CELIST_BUFFER_SIZE];
    00139     uint32_t *ces;
    00140     int32_t listMax;
    00141     int32_t listSize;
    00142
    00143 #ifdef INSTRUMENT_CELIST
    00144     static int32_t _active;
    00145     static int32_t _histogram[10];
    00146 #endif
    00147 };
    00148
    00156 class U_I18N_API StringList : public UObject
    00157 {
    00158 public:
    00170     StringList(UErrorCode &status);
    00171
    00177     ~StringList();
    00178
    00187     void add(const UnicodeString *string, UErrorCode &status);
    00188
    00198     void add(const UChar *chars, int32_t count, UErrorCode &status);
    00199
    00210     const UnicodeString *get(int32_t index) const;
    00211
    00219     int32_t size() const;
    00220
    00224     virtual UClassID getDynamicClassID() const;
    00228     static UClassID getStaticClassID();
    00229
    00230 private:
    00231     UnicodeString *strings;
    00232     int32_t listMax;
    00233     int32_t listSize;
    00234
    00235 #ifdef INSTRUMENT_STRING_LIST
    00236     static int32_t _lists;
    00237     static int32_t _strings;
    00238     static int32_t _histogram[101];
    00239 #endif
    00240 };
    00241
    00242 /*
    00243  * Forward references to internal classes.
    00244  */
    00245 class StringToCEsMap;
    00246 class CEToStringsMap;
    00247 class CollDataCache;
    00248
    00267 class U_I18N_API CollData : public UObject
    00268 {
    00269 public:
    00285     static CollData *open(UCollator *collator, UErrorCode &status);
    00286
    00294     static void close(CollData *collData);
    00295
    00301     UCollator *getCollator() const;
    00302
    00315     const StringList *getStringList(int32_t ce) const;
    00316
    00328     const CEList *getCEList(const UnicodeString *string) const;
    00329
    00337     void freeCEList(const CEList *list);
    00338
    00350     int32_t minLengthInChars(const CEList *ces, int32_t offset) const;
    00351
    00352
    00372    int32_t minLengthInChars(const CEList *ces, int32_t offset, int32_t *history) const;
    00373
    00377     virtual UClassID getDynamicClassID() const;
    00381     static UClassID getStaticClassID();
    00382
    00395     static void freeCollDataCache();
    00396
    00404     static void flushCollDataCache();
    00405
    00406 private:
    00407     friend class CollDataCache;
    00408     friend class CollDataCacheEntry;
    00409
    00410     CollData(UCollator *collator, char *cacheKey, int32_t cachekeyLength, UErrorCode &status);
    00411     ~CollData();
    00412
    00413     CollData();
    00414
    00415     static char *getCollatorKey(UCollator *collator, char *buffer, int32_t bufferLength);
    00416
    00417     static CollDataCache *getCollDataCache();
    00418
    00419     UCollator      *coll;
    00420     StringToCEsMap *charsToCEList;
    00421     CEToStringsMap *ceToCharsStartingWith;
    00422
    00423     char keyBuffer[KEY_BUFFER_SIZE];
    00424     char *key;
    00425
    00426     static CollDataCache *collDataCache;
    00427
    00428     uint32_t minHan;
    00429     uint32_t maxHan;
    00430
    00431     uint32_t jamoLimits[4];
    00432 };
    00433
    00434 U_NAMESPACE_END
    00435
    00436 #endif // #if !UCONFIG_NO_COLLATION
    00437 #endif // #ifndef COLL_DATA_H