ICU 77.1  77.1
Data Structures | Namespaces | Macros | Enumerations | Functions
ucptrie.h File Reference

C API: This file defines an immutable Unicode code point trie. More...

#include "unicode/utypes.h"
#include "unicode/ucpmap.h"
#include "unicode/utf8.h"
#include "unicode/localpointer.h"

Go to the source code of this file.

Data Structures

struct  UCPTrie
 Immutable Unicode code point trie structure. More...
 

Namespaces

 icu
 File coll.h.
 

Macros

#define UCPTRIE_16(trie, i)   ((trie)->data.ptr16[i])
 Macro parameter value for a trie with 16-bit data values. More...
 
#define UCPTRIE_32(trie, i)   ((trie)->data.ptr32[i])
 Macro parameter value for a trie with 32-bit data values. More...
 
#define UCPTRIE_8(trie, i)   ((trie)->data.ptr8[i])
 Macro parameter value for a trie with 8-bit data values. More...
 
#define UCPTRIE_FAST_GET(trie, dataAccess, c)   dataAccess(trie, _UCPTRIE_CP_INDEX(trie, 0xffff, c))
 Returns a trie value for a code point, with range checking. More...
 
#define UCPTRIE_SMALL_GET(trie, dataAccess, c)    dataAccess(trie, _UCPTRIE_CP_INDEX(trie, UCPTRIE_SMALL_MAX, c))
 Returns a 16-bit trie value for a code point, with range checking. More...
 
#define UCPTRIE_FAST_U16_NEXT(trie, dataAccess, src, limit, c, result)
 UTF-16: Reads the next code point (UChar32 c, out), post-increments src, and gets a value from the trie. More...
 
#define UCPTRIE_FAST_U16_PREV(trie, dataAccess, start, src, c, result)
 UTF-16: Reads the previous code point (UChar32 c, out), pre-decrements src, and gets a value from the trie. More...
 
#define UCPTRIE_FAST_U8_NEXT(trie, dataAccess, src, limit, result)
 UTF-8: Post-increments src and gets a value from the trie. More...
 
#define UCPTRIE_FAST_U8_PREV(trie, dataAccess, start, src, result)
 UTF-8: Pre-decrements src and gets a value from the trie. More...
 
#define UCPTRIE_ASCII_GET(trie, dataAccess, c)   dataAccess(trie, c)
 Returns a trie value for an ASCII code point, without range checking. More...
 
#define UCPTRIE_FAST_BMP_GET(trie, dataAccess, c)   dataAccess(trie, _UCPTRIE_FAST_INDEX(trie, c))
 Returns a trie value for a BMP code point (U+0000..U+FFFF), without range checking. More...
 
#define UCPTRIE_FAST_SUPP_GET(trie, dataAccess, c)   dataAccess(trie, _UCPTRIE_SMALL_INDEX(trie, c))
 Returns a trie value for a supplementary code point (U+10000..U+10FFFF), without range checking. More...
 

Enumerations

enum  UCPTrieType { UCPTRIE_TYPE_ANY = -1 , UCPTRIE_TYPE_FAST , UCPTRIE_TYPE_SMALL }
 Selectors for the type of a UCPTrie. More...
 
enum  UCPTrieValueWidth { UCPTRIE_VALUE_BITS_ANY = -1 , UCPTRIE_VALUE_BITS_16 , UCPTRIE_VALUE_BITS_32 , UCPTRIE_VALUE_BITS_8 }
 Selectors for the number of bits in a UCPTrie data value. More...
 

Functions

U_CAPI UCPTrieucptrie_openFromBinary (UCPTrieType type, UCPTrieValueWidth valueWidth, const void *data, int32_t length, int32_t *pActualLength, UErrorCode *pErrorCode)
 Opens a trie from its binary form, stored in 32-bit-aligned memory. More...
 
U_CAPI void ucptrie_close (UCPTrie *trie)
 Closes a trie and releases associated memory. More...
 
U_CAPI UCPTrieType ucptrie_getType (const UCPTrie *trie)
 Returns the trie type. More...
 
U_CAPI UCPTrieValueWidth ucptrie_getValueWidth (const UCPTrie *trie)
 Returns the number of bits in a trie data value. More...
 
U_CAPI uint32_t ucptrie_get (const UCPTrie *trie, UChar32 c)
 Returns the value for a code point as stored in the trie, with range checking. More...
 
U_CAPI UChar32 ucptrie_getRange (const UCPTrie *trie, UChar32 start, UCPMapRangeOption option, uint32_t surrogateValue, UCPMapValueFilter *filter, const void *context, uint32_t *pValue)
 Returns the last code point such that all those from start to there have the same value. More...
 
U_CAPI int32_t ucptrie_toBinary (const UCPTrie *trie, void *data, int32_t capacity, UErrorCode *pErrorCode)
 Writes a memory-mappable form of the trie into 32-bit aligned memory. More...
 

Detailed Description

C API: This file defines an immutable Unicode code point trie.

See also
UCPTrie
UMutableCPTrie

Definition in file ucptrie.h.

Macro Definition Documentation

◆ UCPTRIE_16

#define UCPTRIE_16 (   trie,
 
)    ((trie)->data.ptr16[i])

Macro parameter value for a trie with 16-bit data values.

Use the name of this macro as a "dataAccess" parameter in other macros. Do not use this macro in any other way.

See also
UCPTRIE_VALUE_BITS_16
Stable:
ICU 63

Definition at line 326 of file ucptrie.h.

◆ UCPTRIE_32

#define UCPTRIE_32 (   trie,
 
)    ((trie)->data.ptr32[i])

Macro parameter value for a trie with 32-bit data values.

Use the name of this macro as a "dataAccess" parameter in other macros. Do not use this macro in any other way.

See also
UCPTRIE_VALUE_BITS_32
Stable:
ICU 63

Definition at line 336 of file ucptrie.h.

◆ UCPTRIE_8

#define UCPTRIE_8 (   trie,
 
)    ((trie)->data.ptr8[i])

Macro parameter value for a trie with 8-bit data values.

Use the name of this macro as a "dataAccess" parameter in other macros. Do not use this macro in any other way.

See also
UCPTRIE_VALUE_BITS_8
Stable:
ICU 63

Definition at line 346 of file ucptrie.h.

◆ UCPTRIE_ASCII_GET

#define UCPTRIE_ASCII_GET (   trie,
  dataAccess,
 
)    dataAccess(trie, c)

Returns a trie value for an ASCII code point, without range checking.

Parameters
trie(const UCPTrie *, in) the trie (of either fast or small type)
dataAccessUCPTRIE_16, UCPTRIE_32, or UCPTRIE_8 according to the trie’s value width
c(UChar32, in) the input code point; must be U+0000..U+007F
Returns
The ASCII code point's trie value.
Stable:
ICU 63

Definition at line 517 of file ucptrie.h.

◆ UCPTRIE_FAST_BMP_GET

#define UCPTRIE_FAST_BMP_GET (   trie,
  dataAccess,
 
)    dataAccess(trie, _UCPTRIE_FAST_INDEX(trie, c))

Returns a trie value for a BMP code point (U+0000..U+FFFF), without range checking.

Can be used to look up a value for a UTF-16 code unit if other parts of the string processing check for surrogates.

Parameters
trie(const UCPTrie *, in) the trie; must have type UCPTRIE_TYPE_FAST
dataAccessUCPTRIE_16, UCPTRIE_32, or UCPTRIE_8 according to the trie’s value width
c(UChar32, in) the input code point, must be U+0000..U+FFFF
Returns
The BMP code point's trie value.
Stable:
ICU 63

Definition at line 530 of file ucptrie.h.

◆ UCPTRIE_FAST_GET

#define UCPTRIE_FAST_GET (   trie,
  dataAccess,
 
)    dataAccess(trie, _UCPTRIE_CP_INDEX(trie, 0xffff, c))

Returns a trie value for a code point, with range checking.

Returns the trie error value if c is not in the range 0..U+10FFFF.

Parameters
trie(const UCPTrie *, in) the trie; must have type UCPTRIE_TYPE_FAST
dataAccessUCPTRIE_16, UCPTRIE_32, or UCPTRIE_8 according to the trie’s value width
c(UChar32, in) the input code point
Returns
The code point's trie value.
Stable:
ICU 63

Definition at line 358 of file ucptrie.h.

◆ UCPTRIE_FAST_SUPP_GET

#define UCPTRIE_FAST_SUPP_GET (   trie,
  dataAccess,
 
)    dataAccess(trie, _UCPTRIE_SMALL_INDEX(trie, c))

Returns a trie value for a supplementary code point (U+10000..U+10FFFF), without range checking.

Parameters
trie(const UCPTrie *, in) the trie; must have type UCPTRIE_TYPE_FAST
dataAccessUCPTRIE_16, UCPTRIE_32, or UCPTRIE_8 according to the trie’s value width
c(UChar32, in) the input code point, must be U+10000..U+10FFFF
Returns
The supplementary code point's trie value.