00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef UBIDI_H
00020 #define UBIDI_H
00021
00022 #include "unicode/utypes.h"
00023 #include "unicode/uchar.h"
00024 #include "unicode/localpointer.h"
00025
00289
00332 typedef uint8_t UBiDiLevel;
00333
00358 #define UBIDI_DEFAULT_LTR 0xfe
00359
00385 #define UBIDI_DEFAULT_RTL 0xff
00386
00392 #define UBIDI_MAX_EXPLICIT_LEVEL 125
00393
00398 #define UBIDI_LEVEL_OVERRIDE 0x80
00399
00413 #define UBIDI_MAP_NOWHERE (-1)
00414
00419 enum UBiDiDirection {
00431 UBIDI_LTR,
00443 UBIDI_RTL,
00450 UBIDI_MIXED,
00457 UBIDI_NEUTRAL
00458 };
00459
00461 typedef enum UBiDiDirection UBiDiDirection;
00462
00473 struct UBiDi;
00474
00476 typedef struct UBiDi UBiDi;
00477
00493 U_STABLE UBiDi * U_EXPORT2
00494 ubidi_open(void);
00495
00530 U_STABLE UBiDi * U_EXPORT2
00531 ubidi_openSized(int32_t maxLength, int32_t maxRunCount, UErrorCode *pErrorCode);
00532
00553 U_STABLE void U_EXPORT2
00554 ubidi_close(UBiDi *pBiDi);
00555
00556 #if U_SHOW_CPLUSPLUS_API
00557
00558 U_NAMESPACE_BEGIN
00559
00569 U_DEFINE_LOCAL_OPEN_POINTER(LocalUBiDiPointer, UBiDi, ubidi_close);
00570
00571 U_NAMESPACE_END
00572
00573 #endif
00574
00623 U_STABLE void U_EXPORT2
00624 ubidi_setInverse(UBiDi *pBiDi, UBool isInverse);
00625
00642 U_STABLE UBool U_EXPORT2
00643 ubidi_isInverse(UBiDi *pBiDi);
00644
00665 U_STABLE void U_EXPORT2
00666 ubidi_orderParagraphsLTR(UBiDi *pBiDi, UBool orderParagraphsLTR);
00667
00679 U_STABLE UBool U_EXPORT2
00680 ubidi_isOrderParagraphsLTR(UBiDi *pBiDi);
00681
00689 typedef enum UBiDiReorderingMode {
00693 UBIDI_REORDER_DEFAULT = 0,
00697 UBIDI_REORDER_NUMBERS_SPECIAL,
00701 UBIDI_REORDER_GROUP_NUMBERS_WITH_R,
00709 UBIDI_REORDER_RUNS_ONLY,
00714 UBIDI_REORDER_INVERSE_NUMBERS_AS_L,
00718 UBIDI_REORDER_INVERSE_LIKE_DIRECT,
00722 UBIDI_REORDER_INVERSE_FOR_NUMBERS_SPECIAL,
00723 #ifndef U_HIDE_DEPRECATED_API
00724
00728 UBIDI_REORDER_COUNT
00729 #endif // U_HIDE_DEPRECATED_API
00730 } UBiDiReorderingMode;
00731
00883 U_STABLE void U_EXPORT2
00884 ubidi_setReorderingMode(UBiDi *pBiDi, UBiDiReorderingMode reorderingMode);
00885
00894 U_STABLE UBiDiReorderingMode U_EXPORT2
00895 ubidi_getReorderingMode(UBiDi *pBiDi);
00896
00904 typedef enum UBiDiReorderingOption {
00911 UBIDI_OPTION_DEFAULT = 0,
00912
00957 UBIDI_OPTION_INSERT_MARKS = 1,
00958
00975 UBIDI_OPTION_REMOVE_CONTROLS = 2,
00976
01023 UBIDI_OPTION_STREAMING = 4
01024 } UBiDiReorderingOption;
01025
01039 U_STABLE void U_EXPORT2
01040 ubidi_setReorderingOptions(UBiDi *pBiDi, uint32_t reorderingOptions);
01041
01050 U_STABLE uint32_t U_EXPORT2
01051 ubidi_getReorderingOptions(UBiDi *pBiDi);
01052
01137 U_STABLE void U_EXPORT2
01138 ubidi_setContext(UBiDi *pBiDi,
01139 const UChar *prologue, int32_t proLength,
01140 const UChar *epilogue, int32_t epiLength,
01141 UErrorCode *pErrorCode);
01142
01225 U_STABLE void U_EXPORT2
01226 ubidi_setPara(UBiDi *pBiDi, const UChar *text, int32_t length,
01227 UBiDiLevel paraLevel, UBiDiLevel *embeddingLevels,
01228 UErrorCode *pErrorCode);
01229
01276 U_STABLE void U_EXPORT2
01277 ubidi_setLine(const UBiDi *pParaBiDi,
01278 int32_t start, int32_t limit,
01279 UBiDi *pLineBiDi,
01280 UErrorCode *pErrorCode);
01281
01297 U_STABLE UBiDiDirection U_EXPORT2
01298 ubidi_getDirection(const UBiDi *pBiDi);
01299
01327 U_STABLE UBiDiDirection U_EXPORT2
01328 ubidi_getBaseDirection(const UChar *text, int32_t length );
01329
01341 U_STABLE const UChar * U_EXPORT2
01342 ubidi_getText(const UBiDi *pBiDi);
01343
01352 U_STABLE int32_t U_EXPORT2
01353 ubidi_getLength(const UBiDi *pBiDi);
01354
01370 U_STABLE UBiDiLevel U_EXPORT2
01371 ubidi_getParaLevel(const UBiDi *pBiDi);
01372
01381 U_STABLE int32_t U_EXPORT2
01382 ubidi_countParagraphs(UBiDi *pBiDi);
01383
01418 U_STABLE int32_t U_EXPORT2
01419 ubidi_getParagraph(const UBiDi *pBiDi, int32_t charIndex, int32_t *pParaStart,
01420 int32_t *pParaLimit, UBiDiLevel *pParaLevel,
01421 UErrorCode *pErrorCode);
01422
01450 U_STABLE void U_EXPORT2
01451 ubidi_getParagraphByIndex(const UBiDi *pBiDi, int32_t paraIndex,
01452 int32_t *pParaStart, int32_t *pParaLimit,
01453 UBiDiLevel *pParaLevel, UErrorCode *pErrorCode);
01454
01470 U_STABLE UBiDiLevel U_EXPORT2
01471 ubidi_getLevelAt(const UBiDi *pBiDi, int32_t charIndex);
01472
01491 U_STABLE const UBiDiLevel * U_EXPORT2
01492 ubidi_getLevels(UBiDi *pBiDi, UErrorCode *pErrorCode);
01493
01518 U_STABLE void U_EXPORT2
01519 ubidi_getLogicalRun(const UBiDi *pBiDi, int32_t logicalPosition,
01520 int32_t *pLogicalLimit, UBiDiLevel *pLevel);
01521
01537 U_STABLE int32_t U_EXPORT2
01538 ubidi_countRuns(UBiDi *pBiDi, UErrorCode *pErrorCode);
01539
01596 U_STABLE UBiDiDirection U_EXPORT2
01597 ubidi_getVisualRun(UBiDi *pBiDi, int32_t runIndex,
01598 int32_t *pLogicalStart, int32_t *pLength);
01599
01637 U_STABLE int32_t U_EXPORT2
01638 ubidi_getVisualIndex(UBiDi *pBiDi, int32_t logicalIndex, UErrorCode *pErrorCode);
01639
01672 U_STABLE int32_t U_EXPORT2
01673 ubidi_getLogicalIndex(UBiDi *pBiDi, int32_t visualIndex, UErrorCode *pErrorCode);
01674
01715 U_STABLE void U_EXPORT2
01716 ubidi_getLogicalMap(UBiDi *pBiDi, int32_t *indexMap, UErrorCode *pErrorCode);
01717
01751 U_STABLE void U_EXPORT2
01752 ubidi_getVisualMap(UBiDi *pBiDi, int32_t *indexMap, UErrorCode *pErrorCode);
01753
01774 U_STABLE void U_EXPORT2
01775 ubidi_reorderLogical(const UBiDiLevel *levels, int32_t length, int32_t *indexMap);
01776
01797 U_STABLE void U_EXPORT2
01798 ubidi_reorderVisual(const UBiDiLevel *levels, int32_t length, int32_t *indexMap);
01799
01832 U_STABLE void U_EXPORT2
01833 ubidi_invertMap(const int32_t *srcMap, int32_t *destMap, int32_t length);
01834
01844 #define UBIDI_KEEP_BASE_COMBINING 1
01845
01854 #define UBIDI_DO_MIRRORING 2
01855
01868 #define UBIDI_INSERT_LRM_FOR_NUMERIC 4
01869
01881 #define UBIDI_REMOVE_BIDI_CONTROLS 8
01882
01897 #define UBIDI_OUTPUT_REVERSE 16
01898
01937 U_STABLE int32_t U_EXPORT2
01938 ubidi_getProcessedLength(const UBiDi *pBiDi);
01939
01967 U_STABLE int32_t U_EXPORT2
01968 ubidi_getResultLength(const UBiDi *pBiDi);
01969
01970 U_CDECL_BEGIN
01971
01972 #ifndef U_HIDE_DEPRECATED_API
01973
01982 #define U_BIDI_CLASS_DEFAULT U_CHAR_DIRECTION_COUNT
01983 #endif // U_HIDE_DEPRECATED_API
01984
02005 typedef UCharDirection U_CALLCONV
02006 UBiDiClassCallback(const void *context, UChar32 c);
02007
02008 U_CDECL_END
02009
02025 U_STABLE UCharDirection U_EXPORT2
02026 ubidi_getCustomizedClass(UBiDi *pBiDi, UChar32 c);
02027
02055 U_STABLE void U_EXPORT2
02056 ubidi_setClassCallback(UBiDi *pBiDi, UBiDiClassCallback *newFn,
02057 const void *newContext, UBiDiClassCallback **oldFn,
02058 const void **oldContext, UErrorCode *pErrorCode);
02059
02072 U_STABLE void U_EXPORT2
02073 ubidi_getClassCallback(UBiDi *pBiDi, UBiDiClassCallback **fn, const void **context);
02074
02140 U_STABLE int32_t U_EXPORT2
02141 ubidi_writeReordered(UBiDi *pBiDi,
02142 UChar *dest, int32_t destSize,
02143 uint16_t options,
02144 UErrorCode *pErrorCode);
02145
02192 U_STABLE int32_t U_EXPORT2
02193 ubidi_writeReverse(const UChar *src, int32_t srcLength,
02194 UChar *dest, int32_t destSize,
02195 uint16_t options,
02196 UErrorCode *pErrorCode);
02197
02198
02201 #endif