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

- File List
- Globals

# colldata.h

Go to the documentation of this file.

    00001 /*
    00002  ******************************************************************************
    00003  *   Copyright (C) 1996-2010, 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
    00030 #define KEY_BUFFER_SIZE 64
    00031
    00036 #define CELIST_BUFFER_SIZE 4
    00037
    00044 //#define INSTRUMENT_CELIST
    00045
    00050 #define STRING_LIST_BUFFER_SIZE 16
    00051
    00058 //#define INSTRUMENT_STRING_LIST
    00059
    00066 class U_I18N_API CEList : public UObject
    00067 {
    00068 public:
    00082     CEList(UCollator *coll, const UnicodeString &string, UErrorCode &status);
    00083
    00088     ~CEList();
    00089
    00097     int32_t size() const;
    00098
    00108     uint32_t get(int32_t index) const;
    00109
    00121     UBool matchesAt(int32_t offset, const CEList *other) const;
    00122
    00132     uint32_t &operator[](int32_t index) const;
    00133
    00138     virtual UClassID getDynamicClassID() const;
    00143     static UClassID getStaticClassID();
    00144
    00145 private:
    00146     void add(uint32_t ce, UErrorCode &status);
    00147
    00148     uint32_t ceBuffer[CELIST_BUFFER_SIZE];
    00149     uint32_t *ces;
    00150     int32_t listMax;
    00151     int32_t listSize;
    00152
    00153 #ifdef INSTRUMENT_CELIST
    00154     static int32_t _active;
    00155     static int32_t _histogram[10];
    00156 #endif
    00157 };
    00158
    00166 class U_I18N_API StringList : public UObject
    00167 {
    00168 public:
    00180     StringList(UErrorCode &status);
    00181
    00187     ~StringList();
    00188
    00197     void add(const UnicodeString *string, UErrorCode &status);
    00198
    00208     void add(const UChar *chars, int32_t count, UErrorCode &status);
    00209
    00220     const UnicodeString *get(int32_t index) const;
    00221
    00229     int32_t size() const;
    00230
    00235     virtual UClassID getDynamicClassID() const;
    00240     static UClassID getStaticClassID();
    00241
    00242 private:
    00243     UnicodeString *strings;
    00244     int32_t listMax;
    00245     int32_t listSize;
    00246
    00247 #ifdef INSTRUMENT_STRING_LIST
    00248     static int32_t _lists;
    00249     static int32_t _strings;
    00250     static int32_t _histogram[101];
    00251 #endif
    00252 };
    00253
    00254 /*
    00255  * Forward references to internal classes.
    00256  */
    00257 class StringToCEsMap;
    00258 class CEToStringsMap;
    00259 class CollDataCache;
    00260
    00279 class U_I18N_API CollData : public UObject
    00280 {
    00281 public:
    00297     static CollData *open(UCollator *collator, UErrorCode &status);
    00298
    00306     static void close(CollData *collData);
    00307
    00314     UCollator *getCollator() const;
    00315
    00328     const StringList *getStringList(int32_t ce) const;
    00329
    00341     const CEList *getCEList(const UnicodeString *string) const;
    00342
    00350     void freeCEList(const CEList *list);
    00351
    00363     int32_t minLengthInChars(const CEList *ces, int32_t offset) const;
    00364
    00365
    00385    int32_t minLengthInChars(const CEList *ces, int32_t offset, int32_t *history) const;
    00386
    00391     virtual UClassID getDynamicClassID() const;
    00396     static UClassID getStaticClassID();
    00397
    00410     static void freeCollDataCache();
    00411
    00419     static void flushCollDataCache();
    00420
    00421 private:
    00422     friend class CollDataCache;
    00423     friend class CollDataCacheEntry;
    00424
    00425     CollData(UCollator *collator, char *cacheKey, int32_t cachekeyLength, UErrorCode &status);
    00426     ~CollData();
    00427
    00428     CollData();
    00429
    00430     static char *getCollatorKey(UCollator *collator, char *buffer, int32_t bufferLength);
    00431
    00432     static CollDataCache *getCollDataCache();
    00433
    00434     UCollator      *coll;
    00435     StringToCEsMap *charsToCEList;
    00436     CEToStringsMap *ceToCharsStartingWith;
    00437
    00438     char keyBuffer[KEY_BUFFER_SIZE];
    00439     char *key;
    00440
    00441     static CollDataCache *collDataCache;
    00442
    00443     uint32_t minHan;
    00444     uint32_t maxHan;
    00445
    00446     uint32_t jamoLimits[4];
    00447 };
    00448
    00449 U_NAMESPACE_END
    00450
    00451 #endif // #if !UCONFIG_NO_COLLATION
    00452 #endif // #ifndef COLL_DATA_H

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines