sl@0: /* sl@0: ******************************************************************************* sl@0: * sl@0: * Copyright (C) 2004-2005, International Business Machines sl@0: * Corporation and others. All Rights Reserved. sl@0: * sl@0: ******************************************************************************* sl@0: * file name: ubidi_props.h sl@0: * encoding: US-ASCII sl@0: * tab size: 8 (not used) sl@0: * indentation:4 sl@0: * sl@0: * created on: 2004dec30 sl@0: * created by: Markus W. Scherer sl@0: * sl@0: * Low-level Unicode bidi/shaping properties access. sl@0: */ sl@0: sl@0: #ifndef __UBIDI_PROPS_H__ sl@0: #define __UBIDI_PROPS_H__ sl@0: sl@0: #include "unicode/utypes.h" sl@0: #include "unicode/uset.h" sl@0: #include "uset_imp.h" sl@0: #include "udataswp.h" sl@0: sl@0: U_CDECL_BEGIN sl@0: sl@0: /* library API -------------------------------------------------------------- */ sl@0: sl@0: struct UBiDiProps; sl@0: typedef struct UBiDiProps UBiDiProps; sl@0: sl@0: U_CAPI UBiDiProps * U_EXPORT2 sl@0: ubidi_openProps(UErrorCode *pErrorCode); sl@0: sl@0: U_CAPI UBiDiProps * U_EXPORT2 sl@0: ubidi_openBinary(const uint8_t *bin, int32_t length, UErrorCode *pErrorCode); sl@0: sl@0: U_CAPI void U_EXPORT2 sl@0: ubidi_closeProps(UBiDiProps *bdp); sl@0: sl@0: sl@0: U_CAPI const UBiDiProps * U_EXPORT2 sl@0: ubidi_getSingleton(UErrorCode *pErrorCode); sl@0: sl@0: /** sl@0: * Get a singleton dummy object, one that works with no real data. sl@0: * This can be used when the real data is not available. sl@0: * Using the dummy can reduce checks for available data after an initial failure. sl@0: */ sl@0: U_CAPI const UBiDiProps * U_EXPORT2 sl@0: ubidi_getDummy(UErrorCode *pErrorCode); sl@0: sl@0: sl@0: U_CAPI int32_t U_EXPORT2 sl@0: ubidi_swap(const UDataSwapper *ds, sl@0: const void *inData, int32_t length, void *outData, sl@0: UErrorCode *pErrorCode); sl@0: sl@0: U_CAPI void U_EXPORT2 sl@0: ubidi_addPropertyStarts(const UBiDiProps *bdp, const USetAdder *sa, UErrorCode *pErrorCode); sl@0: sl@0: /* property access functions */ sl@0: sl@0: U_CFUNC int32_t sl@0: ubidi_getMaxValue(const UBiDiProps *bdp, UProperty which); sl@0: sl@0: U_CAPI UCharDirection U_EXPORT2 sl@0: ubidi_getClass(const UBiDiProps *bdp, UChar32 c); sl@0: sl@0: U_CAPI UBool U_EXPORT2 sl@0: ubidi_isMirrored(const UBiDiProps *bdp, UChar32 c); sl@0: sl@0: U_CAPI UChar32 U_EXPORT2 sl@0: ubidi_getMirror(const UBiDiProps *bdp, UChar32 c); sl@0: sl@0: U_CAPI UBool U_EXPORT2 sl@0: ubidi_isBidiControl(const UBiDiProps *bdp, UChar32 c); sl@0: sl@0: U_CAPI UBool U_EXPORT2 sl@0: ubidi_isJoinControl(const UBiDiProps *bdp, UChar32 c); sl@0: sl@0: U_CAPI UJoiningType U_EXPORT2 sl@0: ubidi_getJoiningType(const UBiDiProps *bdp, UChar32 c); sl@0: sl@0: U_CAPI UJoiningGroup U_EXPORT2 sl@0: ubidi_getJoiningGroup(const UBiDiProps *bdp, UChar32 c); sl@0: sl@0: /* file definitions --------------------------------------------------------- */ sl@0: sl@0: #define UBIDI_DATA_NAME "ubidi" sl@0: #define UBIDI_DATA_TYPE "icu" sl@0: sl@0: /* format "BiDi" */ sl@0: #define UBIDI_FMT_0 0x42 sl@0: #define UBIDI_FMT_1 0x69 sl@0: #define UBIDI_FMT_2 0x44 sl@0: #define UBIDI_FMT_3 0x69 sl@0: sl@0: /* indexes into indexes[] */ sl@0: enum { sl@0: UBIDI_IX_INDEX_TOP, sl@0: UBIDI_IX_LENGTH, sl@0: UBIDI_IX_TRIE_SIZE, sl@0: UBIDI_IX_MIRROR_LENGTH, sl@0: sl@0: UBIDI_IX_JG_START, sl@0: UBIDI_IX_JG_LIMIT, sl@0: sl@0: UBIDI_MAX_VALUES_INDEX=15, sl@0: UBIDI_IX_TOP=16 sl@0: }; sl@0: sl@0: /* definitions for 16-bit bidi/shaping properties word ---------------------- */ sl@0: sl@0: enum { sl@0: /* UBIDI_CLASS_SHIFT=0, */ /* bidi class: 5 bits (4..0) */ sl@0: UBIDI_JT_SHIFT=5, /* joining type: 3 bits (7..5) */ sl@0: sl@0: /* UBIDI__SHIFT=8, reserved: 2 bits (9..8) */ sl@0: sl@0: UBIDI_JOIN_CONTROL_SHIFT=10, sl@0: UBIDI_BIDI_CONTROL_SHIFT=11, sl@0: sl@0: UBIDI_IS_MIRRORED_SHIFT=12, /* 'is mirrored' */ sl@0: UBIDI_MIRROR_DELTA_SHIFT=13, /* bidi mirroring delta: 3 bits (15..13) */ sl@0: sl@0: UBIDI_MAX_JG_SHIFT=16 /* max JG value in indexes[UBIDI_MAX_VALUES_INDEX] bits 23..16 */ sl@0: }; sl@0: sl@0: #define UBIDI_CLASS_MASK 0x0000001f sl@0: #define UBIDI_JT_MASK 0x000000e0 sl@0: sl@0: #define UBIDI_MAX_JG_MASK 0x00ff0000 sl@0: sl@0: #define UBIDI_GET_CLASS(props) ((props)&UBIDI_CLASS_MASK) sl@0: #define UBIDI_GET_FLAG(props, shift) (((props)>>(shift))&1) sl@0: sl@0: enum { sl@0: UBIDI_ESC_MIRROR_DELTA=-4, sl@0: UBIDI_MIN_MIRROR_DELTA=-3, sl@0: UBIDI_MAX_MIRROR_DELTA=3 sl@0: }; sl@0: sl@0: /* definitions for 32-bit mirror table entry -------------------------------- */ sl@0: sl@0: enum { sl@0: /* the source Unicode code point takes 21 bits (20..0) */ sl@0: UBIDI_MIRROR_INDEX_SHIFT=21, sl@0: UBIDI_MAX_MIRROR_INDEX=0x7ff sl@0: }; sl@0: sl@0: #define UBIDI_GET_MIRROR_CODE_POINT(m) (UChar32)((m)&0x1fffff) sl@0: sl@0: #define UBIDI_GET_MIRROR_INDEX(m) ((m)>>UBIDI_MIRROR_INDEX_SHIFT) sl@0: sl@0: U_CDECL_END sl@0: sl@0: #endif