00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef UBIDI_H
00018 #define UBIDI_H
00019
00020 #include "unicode/utypes.h"
00021 #include "unicode/uchar.h"
00022 #include "unicode/localpointer.h"
00023
00287
00330 typedef uint8_t UBiDiLevel;
00331
00356 #define UBIDI_DEFAULT_LTR 0xfe
00357
00383 #define UBIDI_DEFAULT_RTL 0xff
00384
00390 #define UBIDI_MAX_EXPLICIT_LEVEL 61
00391
00396 #define UBIDI_LEVEL_OVERRIDE 0x80
00397
00411 #define UBIDI_MAP_NOWHERE (-1)
00412
00417 enum UBiDiDirection {
00429 UBIDI_LTR,
00441 UBIDI_RTL,
00448 UBIDI_MIXED,
00455 UBIDI_NEUTRAL
00456 };
00457
00459 typedef enum UBiDiDirection UBiDiDirection;
00460
00471 struct UBiDi;
00472
00474 typedef struct UBiDi UBiDi;
00475
00491 U_STABLE UBiDi * U_EXPORT2
00492 ubidi_open(void);
00493
00528 U_STABLE UBiDi * U_EXPORT2
00529 ubidi_openSized(int32_t maxLength, int32_t maxRunCount, UErrorCode *pErrorCode);
00530
00551 U_STABLE void U_EXPORT2
00552 ubidi_close(UBiDi *pBiDi);
00553
00554 #if U_SHOW_CPLUSPLUS_API
00555
00556 U_NAMESPACE_BEGIN
00557
00567 U_DEFINE_LOCAL_OPEN_POINTER(LocalUBiDiPointer, UBiDi, ubidi_close);
00568
00569 U_NAMESPACE_END
00570
00571 #endif
00572
00621 U_STABLE void U_EXPORT2
00622 ubidi_setInverse(UBiDi *pBiDi, UBool isInverse);
00623
00640 U_STABLE UBool U_EXPORT2
00641 ubidi_isInverse(UBiDi *pBiDi);
00642
00663 U_STABLE void U_EXPORT2
00664 ubidi_orderParagraphsLTR(UBiDi *pBiDi, UBool orderParagraphsLTR);
00665
00677 U_STABLE UBool U_EXPORT2
00678 ubidi_isOrderParagraphsLTR(UBiDi *pBiDi);
00679
00687 typedef enum UBiDiReorderingMode {
00691 UBIDI_REORDER_DEFAULT = 0,
00695 UBIDI_REORDER_NUMBERS_SPECIAL,
00699 UBIDI_REORDER_GROUP_NUMBERS_WITH_R,
00707 UBIDI_REORDER_RUNS_ONLY,
00712 UBIDI_REORDER_INVERSE_NUMBERS_AS_L,
00716 UBIDI_REORDER_INVERSE_LIKE_DIRECT,
00720 UBIDI_REORDER_INVERSE_FOR_NUMBERS_SPECIAL,
00723 UBIDI_REORDER_COUNT
00724 } UBiDiReorderingMode;
00725
00877 U_STABLE void U_EXPORT2
00878 ubidi_setReorderingMode(UBiDi *pBiDi, UBiDiReorderingMode reorderingMode);
00879
00888 U_STABLE UBiDiReorderingMode U_EXPORT2
00889 ubidi_getReorderingMode(UBiDi *pBiDi);
00890
00898 typedef enum UBiDiReorderingOption {
00905 UBIDI_OPTION_DEFAULT = 0,
00906
00951 UBIDI_OPTION_INSERT_MARKS = 1,
00952
00969 UBIDI_OPTION_REMOVE_CONTROLS = 2,
00970
01017 UBIDI_OPTION_STREAMING = 4
01018 } UBiDiReorderingOption;
01019
01033 U_STABLE void U_EXPORT2
01034 ubidi_setReorderingOptions(UBiDi *pBiDi, uint32_t reorderingOptions);
01035
01044 U_STABLE uint32_t U_EXPORT2
01045 ubidi_getReorderingOptions(UBiDi *pBiDi);
01046
01131 U_STABLE void U_EXPORT2
01132 ubidi_setContext(UBiDi *pBiDi,
01133 const UChar *prologue, int32_t proLength,
01134 const UChar *epilogue, int32_t epiLength,
01135 UErrorCode *pErrorCode);
01136
01216 U_STABLE void U_EXPORT2
01217 ubidi_setPara(UBiDi *pBiDi, const UChar *text, int32_t length,
01218 UBiDiLevel paraLevel, UBiDiLevel *embeddingLevels,
01219 UErrorCode *pErrorCode);
01220
01267 U_STABLE void U_EXPORT2
01268 ubidi_setLine(const UBiDi *pParaBiDi,
01269 int32_t start, int32_t limit,
01270 UBiDi *pLineBiDi,
01271 UErrorCode *pErrorCode);
01272
01288 U_STABLE UBiDiDirection U_EXPORT2
01289 ubidi_getDirection(const UBiDi *pBiDi);
01290
01318 U_STABLE UBiDiDirection U_EXPORT2
01319 ubidi_getBaseDirection(const UChar *text, int32_t length );
01320
01332 U_STABLE const UChar * U_EXPORT2
01333 ubidi_getText(const UBiDi *pBiDi);
01334
01343 U_STABLE int32_t U_EXPORT2
01344 ubidi_getLength(const UBiDi *pBiDi);
01345
01361 U_STABLE UBiDiLevel U_EXPORT2
01362 ubidi_getParaLevel(const UBiDi *pBiDi);
01363
01372 U_STABLE int32_t U_EXPORT2
01373 ubidi_countParagraphs(UBiDi *pBiDi);
01374
01409 U_STABLE int32_t U_EXPORT2
01410 ubidi_getParagraph(const UBiDi *pBiDi, int32_t charIndex, int32_t *pParaStart,
01411 int32_t *pParaLimit, UBiDiLevel *pParaLevel,
01412 UErrorCode *pErrorCode);
01413
01441 U_STABLE void U_EXPORT2
01442 ubidi_getParagraphByIndex(const UBiDi *pBiDi, int32_t paraIndex,
01443 int32_t *pParaStart, int32_t *pParaLimit,
01444 UBiDiLevel *pParaLevel, UErrorCode *pErrorCode);
01445
01461 U_STABLE UBiDiLevel U_EXPORT2
01462 ubidi_getLevelAt(const UBiDi *pBiDi, int32_t charIndex);
01463
01482 U_STABLE const UBiDiLevel * U_EXPORT2
01483 ubidi_getLevels(UBiDi *pBiDi, UErrorCode *pErrorCode);
01484
01509 U_STABLE void U_EXPORT2
01510 ubidi_getLogicalRun(const UBiDi *pBiDi, int32_t logicalPosition,
01511 int32_t *pLogicalLimit, UBiDiLevel *pLevel);
01512
01528 U_STABLE int32_t U_EXPORT2
01529 ubidi_countRuns(UBiDi *pBiDi, UErrorCode *pErrorCode);
01530
01587 U_STABLE UBiDiDirection U_EXPORT2
01588 ubidi_getVisualRun(UBiDi *pBiDi, int32_t runIndex,
01589 int32_t *pLogicalStart, int32_t *pLength);
01590
01628 U_STABLE int32_t U_EXPORT2
01629 ubidi_getVisualIndex(UBiDi *pBiDi, int32_t logicalIndex, UErrorCode *pErrorCode);
01630
01663 U_STABLE int32_t U_EXPORT2
01664 ubidi_getLogicalIndex(UBiDi *pBiDi, int32_t visualIndex, UErrorCode *pErrorCode);
01665
01706 U_STABLE void U_EXPORT2
01707 ubidi_getLogicalMap(UBiDi *pBiDi, int32_t *indexMap, UErrorCode *pErrorCode);
01708
01742 U_STABLE void U_EXPORT2
01743 ubidi_getVisualMap(UBiDi *pBiDi, int32_t *indexMap, UErrorCode *pErrorCode);
01744
01765 U_STABLE void U_EXPORT2
01766 ubidi_reorderLogical(const UBiDiLevel *levels, int32_t length, int32_t *indexMap);
01767
01788 U_STABLE void U_EXPORT2
01789 ubidi_reorderVisual(const UBiDiLevel *levels, int32_t length, int32_t *indexMap);
01790
01823 U_STABLE void U_EXPORT2
01824 ubidi_invertMap(const int32_t *srcMap, int32_t *destMap, int32_t length);
01825
01835 #define UBIDI_KEEP_BASE_COMBINING 1
01836
01845 #define UBIDI_DO_MIRRORING 2
01846
01859 #define UBIDI_INSERT_LRM_FOR_NUMERIC 4
01860
01872 #define UBIDI_REMOVE_BIDI_CONTROLS 8
01873
01888 #define UBIDI_OUTPUT_REVERSE 16
01889
01928 U_STABLE int32_t U_EXPORT2
01929 ubidi_getProcessedLength(const UBiDi *pBiDi);
01930
01958 U_STABLE int32_t U_EXPORT2
01959 ubidi_getResultLength(const UBiDi *pBiDi);
01960
01961 U_CDECL_BEGIN
01968 #define U_BIDI_CLASS_DEFAULT U_CHAR_DIRECTION_COUNT
01969
01990 typedef UCharDirection U_CALLCONV
01991 UBiDiClassCallback(const void *context, UChar32 c);
01992
01993 U_CDECL_END
01994
02010 U_STABLE UCharDirection U_EXPORT2
02011 ubidi_getCustomizedClass(UBiDi *pBiDi, UChar32 c);
02012
02040 U_STABLE void U_EXPORT2
02041 ubidi_setClassCallback(UBiDi *pBiDi, UBiDiClassCallback *newFn,
02042 const void *newContext, UBiDiClassCallback **oldFn,
02043 const void **oldContext, UErrorCode *pErrorCode);
02044
02057 U_STABLE void U_EXPORT2
02058 ubidi_getClassCallback(UBiDi *pBiDi, UBiDiClassCallback **fn, const void **context);
02059
02125 U_STABLE int32_t U_EXPORT2
02126 ubidi_writeReordered(UBiDi *pBiDi,
02127 UChar *dest, int32_t destSize,
02128 uint16_t options,
02129 UErrorCode *pErrorCode);
02130
02177 U_STABLE int32_t U_EXPORT2
02178 ubidi_writeReverse(const UChar *src, int32_t srcLength,
02179 UChar *dest, int32_t destSize,
02180 uint16_t options,
02181 UErrorCode *pErrorCode);
02182
02183
02186 #endif