ICU 50.2 50.2
colldata.h
Go to the documentation of this file.
1/*
2 ******************************************************************************
3 * Copyright (C) 1996-2012, International Business Machines *
4 * Corporation and others. All Rights Reserved. *
5 ******************************************************************************
6 */
7
13
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
26#ifndef U_HIDE_INTERNAL_API
31#define KEY_BUFFER_SIZE 64
32
37#define CELIST_BUFFER_SIZE 4
38
45//#define INSTRUMENT_CELIST
46
51#define STRING_LIST_BUFFER_SIZE 16
52
59//#define INSTRUMENT_STRING_LIST
60
68{
69public:
83 CEList(UCollator *coll, const UnicodeString &string, UErrorCode &status);
84
90
98 int32_t size() const;
99
109 uint32_t get(int32_t index) const;
110
122 UBool matchesAt(int32_t offset, const CEList *other) const;
123
133 uint32_t &operator[](int32_t index) const;
134
145
146private:
147 void add(uint32_t ce, UErrorCode &status);
148
149 uint32_t ceBuffer[CELIST_BUFFER_SIZE];
150 uint32_t *ces;
151 int32_t listMax;
152 int32_t listSize;
153
154#ifdef INSTRUMENT_CELIST
155 static int32_t _active;
156 static int32_t _histogram[10];
157#endif
158};
159
168{
169public:
182
189
198 void add(const UnicodeString *string, UErrorCode &status);
199
209 void add(const UChar *chars, int32_t count, UErrorCode &status);
210
221 const UnicodeString *get(int32_t index) const;
222
230 int32_t size() const;
231
242
243private:
244 UnicodeString *strings;
245 int32_t listMax;
246 int32_t listSize;
247
248#ifdef INSTRUMENT_STRING_LIST
249 static int32_t _lists;
250 static int32_t _strings;
251 static int32_t _histogram[101];
252#endif
253};
254#endif /* U_HIDE_INTERNAL_API */
255
256/*
257 * Forward references to internal classes.
258 */
259class StringToCEsMap;
260class CEToStringsMap;
261class CollDataCache;
262
263#ifndef U_HIDE_INTERNAL_API
282class U_I18N_API CollData : public UObject
283{
284public:
300 static CollData *open(UCollator *collator, UErrorCode &status);
301
309 static void close(CollData *collData);
310
318
331 const StringList *getStringList(int32_t ce) const;
332
344 const CEList *getCEList(const UnicodeString *string) const;
345
353 void freeCEList(const CEList *list);
354
366 int32_t minLengthInChars(const CEList *ces, int32_t offset) const;
367
368
388 int32_t minLengthInChars(const CEList *ces, int32_t offset, int32_t *history) const;
389
400
413 static void freeCollDataCache();
414
422 static void flushCollDataCache();
423
424private:
425 friend class CollDataCache;
426 friend class CollDataCacheEntry;
427
428 CollData(UCollator *collator, char *cacheKey, int32_t cachekeyLength, UErrorCode &status);
429 ~CollData();
430
431 CollData();
432
433 static char *getCollatorKey(UCollator *collator, char *buffer, int32_t bufferLength);
434
435 static CollDataCache *getCollDataCache();
436
437 UCollator *coll;
438 StringToCEsMap *charsToCEList;
439 CEToStringsMap *ceToCharsStartingWith;
440
441 char keyBuffer[KEY_BUFFER_SIZE];
442 char *key;
443
444 static CollDataCache *collDataCache;
445
446 uint32_t minHan;
447 uint32_t maxHan;
448
449 uint32_t jamoLimits[4];
450};
451#endif /* U_HIDE_INTERNAL_API */
452
454
455#endif // #if !UCONFIG_NO_COLLATION
456#endif // #ifndef COLL_DATA_H
This object holds a list of CEs generated from a particular UnicodeString
Definition colldata.h:68
static UClassID getStaticClassID()
UObject glue...
uint32_t & operator[](int32_t index) const
The index operator.
int32_t size() const
Return the number of CEs in the list.
virtual UClassID getDynamicClassID() const
UObject glue...
UBool matchesAt(int32_t offset, const CEList *other) const
Check if the CEs in another CEList match the suffix of this list starting at a give offset.
~CEList()
The destructor.
CEList(UCollator *coll, const UnicodeString &string, UErrorCode &status)
Construct a CEList object.
uint32_t get(int32_t index) const
Get a particular CE from the list.
UCollator * getCollator() const
Get the UCollator object used to create this object.
static CollData * open(UCollator *collator, UErrorCode &status)
Construct a CollData object.
int32_t minLengthInChars(const CEList *ces, int32_t offset, int32_t *history) const
Return the length of the shortest string that will generate the given list of CEs.
virtual UClassID getDynamicClassID() const
UObject glue...
int32_t minLengthInChars(const CEList *ces, int32_t offset) const
Return the length of the shortest string that will generate the given list of CEs.
void freeCEList(const CEList *list)
Release a CEList returned by getCEList.
const CEList * getCEList(const UnicodeString *string) const
Get a list of the CEs generated by a partcular stirng.
static UClassID getStaticClassID()
UObject glue...
const StringList * getStringList(int32_t ce) const
Get a list of all the strings which generate a list of CEs starting with a given CE.
static void flushCollDataCache()
CollData objects are expensive to compute, and so may be cached.
static void close(CollData *collData)
Release a CollData object.
static void freeCollDataCache()
CollData objects are expensive to compute, and so may be cached.
StringList.
Definition colldata.h:168
void add(const UChar *chars, int32_t count, UErrorCode &status)
Add an array of Unicode code points to the list.
virtual UClassID getDynamicClassID() const
the UObject glue...
const UnicodeString * get(int32_t index) const
Get a particular string from the list.
StringList(UErrorCode &status)
Construct an empty StringList
~StringList()
The destructor.
int32_t size() const
Get the number of stings in the list.
void add(const UnicodeString *string, UErrorCode &status)
Add a string to the list.
static UClassID getStaticClassID()
the UObject glue...
UObject is the common ICU "boilerplate" class.
Definition uobject.h:229
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition unistr.h:247
#define KEY_BUFFER_SIZE
The size of the internal buffer for the Collator's short description string.
Definition colldata.h:31
#define CELIST_BUFFER_SIZE
The size of the internal CE buffer in a CEList object.
Definition colldata.h:37
C API: Collator.
struct UCollator UCollator
structure representing a collator object instance
Definition ucol.h:62
int8_t UBool
The ICU boolean type.
Definition umachine.h:200
uint16_t UChar
Define UChar to be UCHAR_TYPE, if that is #defined (for example, to char16_t), or wchar_t if that is ...
Definition umachine.h:278
C++ API: Common ICU base class UObject.
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
Definition uobject.h:96
Basic definitions for ICU, for both C and C++ APIs.
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers,...
Definition utypes.h:476
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside.
Definition utypes.h:358
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition uversion.h:130
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition uversion.h:129