]> git.saurik.com Git - apple/icu.git/blame - icuSources/common/ubidi_props.h
ICU-8.11.4.tar.gz
[apple/icu.git] / icuSources / common / ubidi_props.h
CommitLineData
73c04bcf
A
1/*
2*******************************************************************************
3*
4* Copyright (C) 2004-2005, International Business Machines
5* Corporation and others. All Rights Reserved.
6*
7*******************************************************************************
8* file name: ubidi_props.h
9* encoding: US-ASCII
10* tab size: 8 (not used)
11* indentation:4
12*
13* created on: 2004dec30
14* created by: Markus W. Scherer
15*
16* Low-level Unicode bidi/shaping properties access.
17*/
18
19#ifndef __UBIDI_PROPS_H__
20#define __UBIDI_PROPS_H__
21
22#include "unicode/utypes.h"
23#include "unicode/uset.h"
24#include "uset_imp.h"
25#include "udataswp.h"
26
27U_CDECL_BEGIN
28
29/* library API -------------------------------------------------------------- */
30
31struct UBiDiProps;
32typedef struct UBiDiProps UBiDiProps;
33
34U_CAPI UBiDiProps * U_EXPORT2
35ubidi_openProps(UErrorCode *pErrorCode);
36
37U_CAPI UBiDiProps * U_EXPORT2
38ubidi_openBinary(const uint8_t *bin, int32_t length, UErrorCode *pErrorCode);
39
40U_CAPI void U_EXPORT2
41ubidi_closeProps(UBiDiProps *bdp);
42
43
44U_CAPI const UBiDiProps * U_EXPORT2
45ubidi_getSingleton(UErrorCode *pErrorCode);
46
47/**
48 * Get a singleton dummy object, one that works with no real data.
49 * This can be used when the real data is not available.
50 * Using the dummy can reduce checks for available data after an initial failure.
51 */
52U_CAPI const UBiDiProps * U_EXPORT2
53ubidi_getDummy(UErrorCode *pErrorCode);
54
55
56U_CAPI int32_t U_EXPORT2
57ubidi_swap(const UDataSwapper *ds,
58 const void *inData, int32_t length, void *outData,
59 UErrorCode *pErrorCode);
60
61U_CAPI void U_EXPORT2
62ubidi_addPropertyStarts(const UBiDiProps *bdp, const USetAdder *sa, UErrorCode *pErrorCode);
63
64/* property access functions */
65
66U_CFUNC int32_t
67ubidi_getMaxValue(const UBiDiProps *bdp, UProperty which);
68
69U_CAPI UCharDirection U_EXPORT2
70ubidi_getClass(const UBiDiProps *bdp, UChar32 c);
71
72U_CAPI UBool U_EXPORT2
73ubidi_isMirrored(const UBiDiProps *bdp, UChar32 c);
74
75U_CAPI UChar32 U_EXPORT2
76ubidi_getMirror(const UBiDiProps *bdp, UChar32 c);
77
78U_CAPI UBool U_EXPORT2
79ubidi_isBidiControl(const UBiDiProps *bdp, UChar32 c);
80
81U_CAPI UBool U_EXPORT2
82ubidi_isJoinControl(const UBiDiProps *bdp, UChar32 c);
83
84U_CAPI UJoiningType U_EXPORT2
85ubidi_getJoiningType(const UBiDiProps *bdp, UChar32 c);
86
87U_CAPI UJoiningGroup U_EXPORT2
88ubidi_getJoiningGroup(const UBiDiProps *bdp, UChar32 c);
89
90/* file definitions --------------------------------------------------------- */
91
92#define UBIDI_DATA_NAME "ubidi"
93#define UBIDI_DATA_TYPE "icu"
94
95/* format "BiDi" */
96#define UBIDI_FMT_0 0x42
97#define UBIDI_FMT_1 0x69
98#define UBIDI_FMT_2 0x44
99#define UBIDI_FMT_3 0x69
100
101/* indexes into indexes[] */
102enum {
103 UBIDI_IX_INDEX_TOP,
104 UBIDI_IX_LENGTH,
105 UBIDI_IX_TRIE_SIZE,
106 UBIDI_IX_MIRROR_LENGTH,
107
108 UBIDI_IX_JG_START,
109 UBIDI_IX_JG_LIMIT,
110
111 UBIDI_MAX_VALUES_INDEX=15,
112 UBIDI_IX_TOP=16
113};
114
115/* definitions for 16-bit bidi/shaping properties word ---------------------- */
116
117enum {
118 /* UBIDI_CLASS_SHIFT=0, */ /* bidi class: 5 bits (4..0) */
119 UBIDI_JT_SHIFT=5, /* joining type: 3 bits (7..5) */
120
121 /* UBIDI__SHIFT=8, reserved: 2 bits (9..8) */
122
123 UBIDI_JOIN_CONTROL_SHIFT=10,
124 UBIDI_BIDI_CONTROL_SHIFT=11,
125
126 UBIDI_IS_MIRRORED_SHIFT=12, /* 'is mirrored' */
127 UBIDI_MIRROR_DELTA_SHIFT=13, /* bidi mirroring delta: 3 bits (15..13) */
128
129 UBIDI_MAX_JG_SHIFT=16 /* max JG value in indexes[UBIDI_MAX_VALUES_INDEX] bits 23..16 */
130};
131
132#define UBIDI_CLASS_MASK 0x0000001f
133#define UBIDI_JT_MASK 0x000000e0
134
135#define UBIDI_MAX_JG_MASK 0x00ff0000
136
137#define UBIDI_GET_CLASS(props) ((props)&UBIDI_CLASS_MASK)
138#define UBIDI_GET_FLAG(props, shift) (((props)>>(shift))&1)
139
140enum {
141 UBIDI_ESC_MIRROR_DELTA=-4,
142 UBIDI_MIN_MIRROR_DELTA=-3,
143 UBIDI_MAX_MIRROR_DELTA=3
144};
145
146/* definitions for 32-bit mirror table entry -------------------------------- */
147
148enum {
149 /* the source Unicode code point takes 21 bits (20..0) */
150 UBIDI_MIRROR_INDEX_SHIFT=21,
151 UBIDI_MAX_MIRROR_INDEX=0x7ff
152};
153
154#define UBIDI_GET_MIRROR_CODE_POINT(m) (UChar32)((m)&0x1fffff)
155
156#define UBIDI_GET_MIRROR_INDEX(m) ((m)>>UBIDI_MIRROR_INDEX_SHIFT)
157
158U_CDECL_END
159
160#endif