Logo Search packages:      
Sourcecode: icu version File versions  Download package

utrie.h File Reference


Detailed Description

This is a common implementation of a "folded" trie. It is a kind of compressed, serializable table of 16- or 32-bit values associated with Unicode code points (0..0x10ffff).

This implementation is optimized for getting values while walking forward through a UTF-16 string. Therefore, the simplest and fastest access macros are the _FROM_LEAD() and _FROM_OFFSET_TRAIL() macros.

The _FROM_BMP() macros are a little more complicated; they get values even for lead surrogate code _points_, while the _FROM_LEAD() macros get special "folded" values for lead surrogate code _units_ if there is relevant data associated with them. From such a folded value, an offset needs to be extracted to supply to the _FROM_OFFSET_TRAIL() macros.

Most of the more complex (and more convenient) functions/macros call a callback function to get that offset from the folded value for a lead surrogate unit.

Definition in file utrie.h.

#include "unicode/utypes.h"
#include "udataswp.h"

Go to the source code of this file.

Classes

struct  UNewTrie
struct  UTrie
struct  UTrieHeader

Defines

#define _UTRIE_GET(trie, data, c32, result, resultType)
#define _UTRIE_GET_FROM_BMP(trie, data, c16)   _UTRIE_GET_RAW(trie, data, 0xd800<=(c16) && (c16)<=0xdbff ? UTRIE_LEAD_INDEX_DISP : 0, c16);
#define _UTRIE_GET_FROM_PAIR(trie, data, c, c2, result, resultType)
#define _UTRIE_GET_RAW(trie, data, offset, c16)
#define _UTRIE_NEXT(trie, data, src, limit, c, c2, result, resultType)
#define _UTRIE_PREVIOUS(trie, data, start, src, c, c2, result, resultType)
#define UTRIE_DUMMY_SIZE   ((UTRIE_BMP_INDEX_LENGTH+UTRIE_SURROGATE_BLOCK_COUNT)*2+(UTRIE_SHIFT<=8?256:UTRIE_DATA_BLOCK_LENGTH)*4+UTRIE_DATA_BLOCK_LENGTH*4)
#define UTRIE_GET16(trie, c32, result)   _UTRIE_GET(trie, index, c32, result, uint16_t)
#define UTRIE_GET16_FROM_BMP(trie, c16)   _UTRIE_GET_FROM_BMP(trie, index, c16)
#define UTRIE_GET16_FROM_LEAD(trie, c16)   _UTRIE_GET_RAW(trie, index, 0, c16)
#define UTRIE_GET16_FROM_OFFSET_TRAIL(trie, offset, c2)   _UTRIE_GET_RAW(trie, index, offset, (c2)&0x3ff)
#define UTRIE_GET16_FROM_PAIR(trie, c, c2, result)   _UTRIE_GET_FROM_PAIR(trie, index, c, c2, result, uint16_t)
#define UTRIE_GET16_LATIN1(trie)   ((trie)->index+(trie)->indexLength+UTRIE_DATA_BLOCK_LENGTH)
#define UTRIE_GET32(trie, c32, result)   _UTRIE_GET(trie, data32, c32, result, uint32_t)
#define UTRIE_GET32_FROM_BMP(trie, c16)   _UTRIE_GET_FROM_BMP(trie, data32, c16)
#define UTRIE_GET32_FROM_LEAD(trie, c16)   _UTRIE_GET_RAW(trie, data32, 0, c16)
#define UTRIE_GET32_FROM_OFFSET_TRAIL(trie, offset, c2)   _UTRIE_GET_RAW(trie, data32, offset, (c2)&0x3ff)
#define UTRIE_GET32_FROM_PAIR(trie, c, c2, result)   _UTRIE_GET_FROM_PAIR(trie, data32, c, c2, result, uint32_t)
#define UTRIE_GET32_LATIN1(trie)   ((trie)->data32+UTRIE_DATA_BLOCK_LENGTH)
#define UTRIE_MAX_BUILD_TIME_DATA_LENGTH   (0x110000+UTRIE_DATA_BLOCK_LENGTH+0x400)
#define UTRIE_MAX_DATA_LENGTH   (0x10000<<UTRIE_INDEX_SHIFT)
#define UTRIE_MAX_INDEX_LENGTH   (0x110000>>UTRIE_SHIFT)
#define UTRIE_NEXT16(trie, src, limit, c, c2, result)   _UTRIE_NEXT(trie, index, src, limit, c, c2, result, uint16_t)
#define UTRIE_NEXT32(trie, src, limit, c, c2, result)   _UTRIE_NEXT(trie, data32, src, limit, c, c2, result, uint32_t)
#define UTRIE_PREVIOUS16(trie, start, src, c, c2, result)   _UTRIE_PREVIOUS(trie, index, start, src, c, c2, result, uint16_t)
#define UTRIE_PREVIOUS32(trie, start, src, c, c2, result)   _UTRIE_PREVIOUS(trie, data32, start, src, c, c2, result, uint32_t)

Typedefs

typedef struct UNewTrie UNewTrie
typedef uint32_t U_CALLCONV UNewTrieGetFoldedValue (UNewTrie *trie, UChar32 start, int32_t offset)
typedef struct UTrie UTrie
typedef UBool U_CALLCONV UTrieEnumRange (const void *context, UChar32 start, UChar32 limit, uint32_t value)
typedef uint32_t U_CALLCONV UTrieEnumValue (const void *context, uint32_t value)
typedef int32_t U_CALLCONV UTrieGetFoldingOffset (uint32_t data)

Enumerations

enum  {
  UTRIE_SHIFT = 5, UTRIE_DATA_BLOCK_LENGTH = 1<<UTRIE_SHIFT, UTRIE_MASK = UTRIE_DATA_BLOCK_LENGTH-1, UTRIE_LEAD_INDEX_DISP = 0x2800>>UTRIE_SHIFT,
  UTRIE_INDEX_SHIFT = 2, UTRIE_DATA_GRANULARITY = 1<<UTRIE_INDEX_SHIFT, UTRIE_SURROGATE_BLOCK_BITS = 10-UTRIE_SHIFT, UTRIE_SURROGATE_BLOCK_COUNT = (1<<UTRIE_SURROGATE_BLOCK_BITS),
  UTRIE_BMP_INDEX_LENGTH = 0x10000>>UTRIE_SHIFT
}
enum  { UTRIE_OPTIONS_SHIFT_MASK = 0xf, UTRIE_OPTIONS_INDEX_SHIFT = 4, UTRIE_OPTIONS_DATA_IS_32_BIT = 0x100, UTRIE_OPTIONS_LATIN1_IS_LINEAR = 0x200 }

Functions

U_CAPI UNewTrie *U_EXPORT2 utrie_clone (UNewTrie *fillIn, const UNewTrie *other, uint32_t *aliasData, int32_t aliasDataLength)
U_CAPI void U_EXPORT2 utrie_close (UNewTrie *trie)
U_CAPI int32_t U_EXPORT2 utrie_defaultGetFoldingOffset (uint32_t data)
U_CAPI void U_EXPORT2 utrie_enum (const UTrie *trie, UTrieEnumValue *enumValue, UTrieEnumRange *enumRange, const void *context)
U_CAPI uint32_t U_EXPORT2 utrie_get32 (UNewTrie *trie, UChar32 c, UBool *pInBlockZero)
U_CAPI uint32_t *U_EXPORT2 utrie_getData (UNewTrie *trie, int32_t *pLength)
U_CAPI UNewTrie *U_EXPORT2 utrie_open (UNewTrie *fillIn, uint32_t *aliasData, int32_t maxDataLength, uint32_t initialValue, uint32_t leadUnitValue, UBool latin1Linear)
U_CAPI int32_t U_EXPORT2 utrie_serialize (UNewTrie *trie, void *data, int32_t capacity, UNewTrieGetFoldedValue *getFoldedValue, UBool reduceTo16Bits, UErrorCode *pErrorCode)
U_CAPI UBool U_EXPORT2 utrie_set32 (UNewTrie *trie, UChar32 c, uint32_t value)
U_CAPI UBool U_EXPORT2 utrie_setRange32 (UNewTrie *trie, UChar32 start, UChar32 limit, uint32_t value, UBool overwrite)
U_CAPI int32_t U_EXPORT2 utrie_swap (const UDataSwapper *ds, const void *inData, int32_t length, void *outData, UErrorCode *pErrorCode)
U_CAPI int32_t U_EXPORT2 utrie_unserialize (UTrie *trie, const void *data, int32_t length, UErrorCode *pErrorCode)
U_CAPI int32_t U_EXPORT2 utrie_unserializeDummy (UTrie *trie, void *data, int32_t length, uint32_t initialValue, uint32_t leadUnitValue, UBool make16BitTrie, UErrorCode *pErrorCode)


Generated by  Doxygen 1.6.0   Back to index