]>
Commit | Line | Data |
---|---|---|
b75a7d8f A |
1 | /* |
2 | ******************************************************************************* | |
3 | * | |
73c04bcf | 4 | * Copyright (C) 2002-2005, International Business Machines |
b75a7d8f A |
5 | * Corporation and others. All Rights Reserved. |
6 | * | |
7 | ******************************************************************************* | |
8 | * file name: propsvec.h | |
9 | * encoding: US-ASCII | |
10 | * tab size: 8 (not used) | |
11 | * indentation:4 | |
12 | * | |
13 | * created on: 2002feb22 | |
14 | * created by: Markus W. Scherer | |
15 | * | |
16 | * Store additional Unicode character properties in bit set vectors. | |
17 | */ | |
18 | ||
19 | #ifndef __UPROPSVEC_H__ | |
20 | #define __UPROPSVEC_H__ | |
21 | ||
22 | #include "unicode/utypes.h" | |
23 | #include "utrie.h" | |
24 | ||
25 | /* | |
26 | * Unicode Properties Vectors associated with code point ranges. | |
27 | * Stored in an array of uint32_t. | |
28 | * | |
29 | * The array starts with a header, then rows of integers store | |
30 | * the range limits and the properties vectors. | |
31 | * | |
32 | * In each row, row[0] contains the start code point and | |
33 | * row[1] contains the limit code point, | |
34 | * which is the start of the next range. | |
35 | * | |
36 | * Initially, there is only one range [0..0x110000[ with values 0. | |
37 | * | |
38 | * It would be possible to store only one range boundary per row, | |
39 | * but self-contained rows allow to later sort them by contents. | |
40 | */ | |
41 | enum { | |
374ca955 | 42 | /* stores number of columns, plus two for start & limit values */ |
b75a7d8f A |
43 | UPVEC_COLUMNS, |
44 | UPVEC_MAXROWS, | |
45 | UPVEC_ROWS, | |
374ca955 A |
46 | /* search optimization: remember last row seen */ |
47 | UPVEC_PREV_ROW, | |
b75a7d8f A |
48 | UPVEC_HEADER_LENGTH |
49 | }; | |
50 | ||
374ca955 | 51 | U_CAPI uint32_t * U_EXPORT2 |
b75a7d8f A |
52 | upvec_open(int32_t columns, int32_t maxRows); |
53 | ||
374ca955 | 54 | U_CAPI void U_EXPORT2 |
b75a7d8f A |
55 | upvec_close(uint32_t *pv); |
56 | ||
374ca955 | 57 | U_CAPI UBool U_EXPORT2 |
b75a7d8f | 58 | upvec_setValue(uint32_t *pv, |
374ca955 | 59 | UChar32 start, UChar32 limit, |
b75a7d8f A |
60 | int32_t column, |
61 | uint32_t value, uint32_t mask, | |
62 | UErrorCode *pErrorCode); | |
63 | ||
374ca955 A |
64 | U_CAPI uint32_t U_EXPORT2 |
65 | upvec_getValue(uint32_t *pv, UChar32 c, int32_t column); | |
66 | ||
67 | /* | |
68 | * pRangeStart and pRangeLimit can be NULL. | |
69 | * @return NULL if rowIndex out of range and for illegal arguments | |
70 | */ | |
71 | U_CAPI uint32_t * U_EXPORT2 | |
b75a7d8f | 72 | upvec_getRow(uint32_t *pv, int32_t rowIndex, |
374ca955 | 73 | UChar32 *pRangeStart, UChar32 *pRangeLimit); |
b75a7d8f | 74 | |
73c04bcf A |
75 | /* |
76 | * Compact the vectors: | |
77 | * - modify the memory | |
78 | * - keep only unique vectors | |
79 | * - store them contiguously from the beginning of the memory | |
80 | * - for each (non-unique) row, call the handler function | |
81 | * | |
82 | * The handler's rowIndex is the uint32_t index of the row in the compacted | |
83 | * memory block. | |
84 | * (Therefore, it starts at 0 increases in increments of the columns value.) | |
85 | */ | |
86 | ||
87 | typedef void U_CALLCONV | |
88 | UPVecCompactHandler(void *context, | |
89 | UChar32 start, UChar32 limit, | |
90 | int32_t rowIndex, uint32_t *row, int32_t columns, | |
91 | UErrorCode *pErrorCode); | |
92 | ||
374ca955 | 93 | U_CAPI int32_t U_EXPORT2 |
73c04bcf A |
94 | upvec_compact(uint32_t *pv, UPVecCompactHandler *handler, void *context, UErrorCode *pErrorCode); |
95 | ||
96 | /* context=UNewTrie, stores the rowIndex values into the trie */ | |
97 | U_CAPI void U_CALLCONV | |
98 | upvec_compactToTrieHandler(void *context, | |
99 | UChar32 start, UChar32 limit, | |
100 | int32_t rowIndex, uint32_t *row, int32_t columns, | |
101 | UErrorCode *pErrorCode); | |
b75a7d8f A |
102 | |
103 | #endif |