ICU 55.1  55.1
ubidi.h
Go to the documentation of this file.
1 /*
2 ******************************************************************************
3 *
4 * Copyright (C) 1999-2013, International Business Machines
5 * Corporation and others. All Rights Reserved.
6 *
7 ******************************************************************************
8 * file name: ubidi.h
9 * encoding: US-ASCII
10 * tab size: 8 (not used)
11 * indentation:4
12 *
13 * created on: 1999jul27
14 * created by: Markus W. Scherer, updated by Matitiahu Allouche
15 */
16 
17 #ifndef UBIDI_H
18 #define UBIDI_H
19 
20 #include "unicode/utypes.h"
21 #include "unicode/uchar.h"
22 #include "unicode/localpointer.h"
23 
287 /*DOCXX_TAG*/
330 typedef uint8_t UBiDiLevel;
331 
356 #define UBIDI_DEFAULT_LTR 0xfe
357 
383 #define UBIDI_DEFAULT_RTL 0xff
384 
390 #define UBIDI_MAX_EXPLICIT_LEVEL 125
391 
396 #define UBIDI_LEVEL_OVERRIDE 0x80
397 
411 #define UBIDI_MAP_NOWHERE (-1)
412 
456 };
457 
459 typedef enum UBiDiDirection UBiDiDirection;
460 
471 struct UBiDi;
472 
474 typedef struct UBiDi UBiDi;
475 
491 U_STABLE UBiDi * U_EXPORT2
493 
528 U_STABLE UBiDi * U_EXPORT2
529 ubidi_openSized(int32_t maxLength, int32_t maxRunCount, UErrorCode *pErrorCode);
530 
551 U_STABLE void U_EXPORT2
553 
554 #if U_SHOW_CPLUSPLUS_API
555 
557 
568 
570 
571 #endif
572 
621 U_STABLE void U_EXPORT2
622 ubidi_setInverse(UBiDi *pBiDi, UBool isInverse);
623 
640 U_STABLE UBool U_EXPORT2
642 
663 U_STABLE void U_EXPORT2
664 ubidi_orderParagraphsLTR(UBiDi *pBiDi, UBool orderParagraphsLTR);
665 
677 U_STABLE UBool U_EXPORT2
679 
687 typedef enum UBiDiReorderingMode {
725 
877 U_STABLE void U_EXPORT2
879 
890 
898 typedef enum UBiDiReorderingOption {
906 
952 
970 
1019 
1033 U_STABLE void U_EXPORT2
1034 ubidi_setReorderingOptions(UBiDi *pBiDi, uint32_t reorderingOptions);
1035 
1044 U_STABLE uint32_t U_EXPORT2
1046 
1131 U_STABLE void U_EXPORT2
1133  const UChar *prologue, int32_t proLength,
1134  const UChar *epilogue, int32_t epiLength,
1135  UErrorCode *pErrorCode);
1136 
1216 U_STABLE void U_EXPORT2
1217 ubidi_setPara(UBiDi *pBiDi, const UChar *text, int32_t length,
1218  UBiDiLevel paraLevel, UBiDiLevel *embeddingLevels,
1219  UErrorCode *pErrorCode);
1220 
1267 U_STABLE void U_EXPORT2
1268 ubidi_setLine(const UBiDi *pParaBiDi,
1269  int32_t start, int32_t limit,
1270  UBiDi *pLineBiDi,
1271  UErrorCode *pErrorCode);
1272 
1288 U_STABLE UBiDiDirection U_EXPORT2
1290 
1318 U_STABLE UBiDiDirection U_EXPORT2
1319 ubidi_getBaseDirection(const UChar *text, int32_t length );
1320 
1332 U_STABLE const UChar * U_EXPORT2
1333 ubidi_getText(const UBiDi *pBiDi);
1334 
1343 U_STABLE int32_t U_EXPORT2
1344 ubidi_getLength(const UBiDi *pBiDi);
1345 
1361 U_STABLE UBiDiLevel U_EXPORT2
1363 
1372 U_STABLE int32_t U_EXPORT2
1374 
1409 U_STABLE int32_t U_EXPORT2
1410 ubidi_getParagraph(const UBiDi *pBiDi, int32_t charIndex, int32_t *pParaStart,
1411  int32_t *pParaLimit, UBiDiLevel *pParaLevel,
1412  UErrorCode *pErrorCode);
1413 
1441 U_STABLE void U_EXPORT2
1442 ubidi_getParagraphByIndex(const UBiDi *pBiDi, int32_t paraIndex,
1443  int32_t *pParaStart, int32_t *pParaLimit,
1444  UBiDiLevel *pParaLevel, UErrorCode *pErrorCode);
1445 
1461 U_STABLE UBiDiLevel U_EXPORT2
1462 ubidi_getLevelAt(const UBiDi *pBiDi, int32_t charIndex);
1463 
1482 U_STABLE const UBiDiLevel * U_EXPORT2
1483 ubidi_getLevels(UBiDi *pBiDi, UErrorCode *pErrorCode);
1484 
1509 U_STABLE void U_EXPORT2
1510 ubidi_getLogicalRun(const UBiDi *pBiDi, int32_t logicalPosition,
1511  int32_t *pLogicalLimit, UBiDiLevel *pLevel);
1512 
1528 U_STABLE int32_t U_EXPORT2
1529 ubidi_countRuns(UBiDi *pBiDi, UErrorCode *pErrorCode);
1530 
1587 U_STABLE UBiDiDirection U_EXPORT2
1588 ubidi_getVisualRun(UBiDi *pBiDi, int32_t runIndex,
1589  int32_t *pLogicalStart, int32_t *pLength);
1590 
1628 U_STABLE int32_t U_EXPORT2
1629 ubidi_getVisualIndex(UBiDi *pBiDi, int32_t logicalIndex, UErrorCode *pErrorCode);
1630 
1663 U_STABLE int32_t U_EXPORT2
1664 ubidi_getLogicalIndex(UBiDi *pBiDi, int32_t visualIndex, UErrorCode *pErrorCode);
1665 
1706 U_STABLE void U_EXPORT2
1707 ubidi_getLogicalMap(UBiDi *pBiDi, int32_t *indexMap, UErrorCode *pErrorCode);
1708 
1742 U_STABLE void U_EXPORT2
1743 ubidi_getVisualMap(UBiDi *pBiDi, int32_t *indexMap, UErrorCode *pErrorCode);
1744 
1765 U_STABLE void U_EXPORT2
1766 ubidi_reorderLogical(const UBiDiLevel *levels, int32_t length, int32_t *indexMap);
1767 
1788 U_STABLE void U_EXPORT2
1789 ubidi_reorderVisual(const UBiDiLevel *levels, int32_t length, int32_t *indexMap);
1790 
1823 U_STABLE void U_EXPORT2
1824 ubidi_invertMap(const int32_t *srcMap, int32_t *destMap, int32_t length);
1825 
1835 #define UBIDI_KEEP_BASE_COMBINING 1
1836 
1845 #define UBIDI_DO_MIRRORING 2
1846 
1859 #define UBIDI_INSERT_LRM_FOR_NUMERIC 4
1860 
1872 #define UBIDI_REMOVE_BIDI_CONTROLS 8
1873 
1888 #define UBIDI_OUTPUT_REVERSE 16
1889 
1928 U_STABLE int32_t U_EXPORT2
1930 
1958 U_STABLE int32_t U_EXPORT2
1960 
1968 #define U_BIDI_CLASS_DEFAULT U_CHAR_DIRECTION_COUNT
1969 
1990 typedef UCharDirection U_CALLCONV
1991 UBiDiClassCallback(const void *context, UChar32 c);
1992 
1994 
2010 U_STABLE UCharDirection U_EXPORT2
2012 
2040 U_STABLE void U_EXPORT2
2042  const void *newContext, UBiDiClassCallback **oldFn,
2043  const void **oldContext, UErrorCode *pErrorCode);
2044 
2057 U_STABLE void U_EXPORT2
2058 ubidi_getClassCallback(UBiDi *pBiDi, UBiDiClassCallback **fn, const void **context);
2059 
2125 U_STABLE int32_t U_EXPORT2
2127  UChar *dest, int32_t destSize,
2128  uint16_t options,
2129  UErrorCode *pErrorCode);
2130 
2177 U_STABLE int32_t U_EXPORT2
2178 ubidi_writeReverse(const UChar *src, int32_t srcLength,
2179  UChar *dest, int32_t destSize,
2180  uint16_t options,
2181  UErrorCode *pErrorCode);
2182 
2183 /*#define BIDI_SAMPLE_CODE*/
2186 #endif
ubidi_getClassCallback
void ubidi_getClassCallback(UBiDi *pBiDi, UBiDiClassCallback **fn, const void **context)
Get the current callback function used for Bidi class determination.
ubidi_setInverse
void ubidi_setInverse(UBiDi *pBiDi, UBool isInverse)
Modify the operation of the Bidi algorithm such that it approximates an "inverse Bidi" algorithm.
ubidi_writeReverse
int32_t ubidi_writeReverse(const UChar *src, int32_t srcLength, UChar *dest, int32_t destSize, uint16_t options, UErrorCode *pErrorCode)
Reverse a Right-To-Left run of Unicode text.
UBiDiReorderingOption
UBiDiReorderingOption
UBiDiReorderingOption values indicate which options are specified to affect the Bidi algorithm.
Definition: ubidi.h:898
ubidi_setLine
void ubidi_setLine(const UBiDi *pParaBiDi, int32_t start, int32_t limit, UBiDi *pLineBiDi, UErrorCode *pErrorCode)
ubidi_setLine() sets a UBiDi to contain the reordering information, especially the resolved levels,...
UBiDiReorderingMode
UBiDiReorderingMode
UBiDiReorderingMode values indicate which variant of the Bidi algorithm to use.
Definition: ubidi.h:687
ubidi_setReorderingOptions
void ubidi_setReorderingOptions(UBiDi *pBiDi, uint32_t reorderingOptions)
Specify which of the reordering options should be applied during Bidi transformations.
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
UBiDiLevel
uint8_t UBiDiLevel
UBiDiLevel is the type of the level values in this Bidi implementation.
Definition: ubidi.h:330
UBIDI_REORDER_INVERSE_NUMBERS_AS_L
@ UBIDI_REORDER_INVERSE_NUMBERS_AS_L
Visual to Logical algorithm which handles numbers like L (same algorithm as selected by ubidi_setInve...
Definition: ubidi.h:712
ubidi_open
UBiDi * ubidi_open(void)
Allocate a UBiDi structure.
ubidi_reorderLogical
void ubidi_reorderLogical(const UBiDiLevel *levels, int32_t length, int32_t *indexMap)
This is a convenience function that does not use a UBiDi object.
UBool
int8_t UBool
The ICU boolean type.
Definition: umachine.h:234
UBIDI_OPTION_INSERT_MARKS
@ UBIDI_OPTION_INSERT_MARKS
option bit for ubidi_setReorderingOptions: insert Bidi marks (LRM or RLM) when needed to ensure corre...
Definition: ubidi.h:951
ubidi_setContext
void ubidi_setContext(UBiDi *pBiDi, const UChar *prologue, int32_t proLength, const UChar *epilogue, int32_t epiLength, UErrorCode *pErrorCode)
Set the context before a call to ubidi_setPara().
ubidi_getLogicalIndex
int32_t ubidi_getLogicalIndex(UBiDi *pBiDi, int32_t visualIndex, UErrorCode *pErrorCode)
Get the logical text position from a visual position.
U_CALLCONV
#define U_CALLCONV
Similar to U_CDECL_BEGIN/U_CDECL_END, this qualifier is necessary in callback function typedefs to ma...
Definition: platform.h:756
ubidi_setReorderingMode
void ubidi_setReorderingMode(UBiDi *pBiDi, UBiDiReorderingMode reorderingMode)
Modify the operation of the Bidi algorithm such that it implements some variant to the basic Bidi alg...
UBIDI_OPTION_DEFAULT
@ UBIDI_OPTION_DEFAULT
option value for ubidi_setReorderingOptions: disable all the options which can be set with this funct...
Definition: ubidi.h:905
ubidi_countRuns
int32_t ubidi_countRuns(UBiDi *pBiDi, UErrorCode *pErrorCode)
Get the number of runs.
UBIDI_REORDER_GROUP_NUMBERS_WITH_R
@ UBIDI_REORDER_GROUP_NUMBERS_WITH_R
Logical to Visual algorithm grouping numbers with adjacent R characters (reversible algorithm).
Definition: ubidi.h:699
ubidi_getLevels
const UBiDiLevel * ubidi_getLevels(UBiDi *pBiDi, UErrorCode *pErrorCode)
Get an array of levels for each character.
ubidi_getParagraphByIndex
void ubidi_getParagraphByIndex(const UBiDi *pBiDi, int32_t paraIndex, int32_t *pParaStart, int32_t *pParaLimit, UBiDiLevel *pParaLevel, UErrorCode *pErrorCode)
Get a paragraph, given the index of this paragraph.
ubidi_countParagraphs
int32_t ubidi_countParagraphs(UBiDi *pBiDi)
Get the number of paragraphs.
UBIDI_NEUTRAL
@ UBIDI_NEUTRAL
No strongly directional text.
Definition: ubidi.h:455
ubidi_invertMap
void ubidi_invertMap(const int32_t *srcMap, int32_t *destMap, int32_t length)
Invert an index map.
ubidi_isInverse
UBool ubidi_isInverse(UBiDi *pBiDi)
Is this Bidi object set to perform the inverse Bidi algorithm?
UBIDI_REORDER_INVERSE_FOR_NUMBERS_SPECIAL
@ UBIDI_REORDER_INVERSE_FOR_NUMBERS_SPECIAL
Inverse Bidi (Visual to Logical) algorithm for the UBIDI_REORDER_NUMBERS_SPECIAL Bidi algorithm.
Definition: ubidi.h:720
UChar32
int32_t UChar32
Define UChar32 as a type for single Unicode code points.
Definition: umachine.h:332
ubidi_getBaseDirection
UBiDiDirection ubidi_getBaseDirection(const UChar *text, int32_t length)
Gets the base direction of the text provided according to the Unicode Bidirectional Algorithm.
UErrorCode
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers,...
Definition: utypes.h:476
UCharDirection
UCharDirection
This specifies the language directional property of a character set.
Definition: uchar.h:777
ubidi_getVisualMap
void ubidi_getVisualMap(UBiDi *pBiDi, int32_t *indexMap, UErrorCode *pErrorCode)
Get a visual-to-logical index map (array) for the characters in the UBiDi (paragraph or line) object.
ubidi_reorderVisual
void ubidi_reorderVisual(const UBiDiLevel *levels, int32_t length, int32_t *indexMap)
This is a convenience function that does not use a UBiDi object.
UBIDI_REORDER_NUMBERS_SPECIAL
@ UBIDI_REORDER_NUMBERS_SPECIAL
Logical to Visual algorithm which handles numbers in a way which mimicks the behavior of Windows XP.
Definition: ubidi.h:695
UBIDI_RTL
@ UBIDI_RTL
Right-to-left text.
Definition: ubidi.h:441
UBIDI_OPTION_STREAMING
@ UBIDI_OPTION_STREAMING
option bit for ubidi_setReorderingOptions: process the output as part of a stream to be continued
Definition: ubidi.h:1017
U_CDECL_END
#define U_CDECL_END
This is used to end a declaration of a library private ICU C API.
Definition: umachine.h:83
ubidi_setClassCallback
void ubidi_setClassCallback(UBiDi *pBiDi, UBiDiClassCallback *newFn, const void *newContext, UBiDiClassCallback **oldFn, const void **oldContext, UErrorCode *pErrorCode)
Set the callback function and callback data used by the UBA implementation for Bidi class determinati...
U_CDECL_BEGIN
#define U_CDECL_BEGIN
This is used to begin a declaration of a library private ICU C API.
Definition: umachine.h:82
ubidi_getText
const UChar * ubidi_getText(const UBiDi *pBiDi)
Get the pointer to the text.
UBIDI_LTR
@ UBIDI_LTR
Left-to-right text.
Definition: ubidi.h:429
ubidi_getReorderingMode
UBiDiReorderingMode ubidi_getReorderingMode(UBiDi *pBiDi)
What is the requested reordering mode for a given Bidi object?
ubidi_getReorderingOptions
uint32_t ubidi_getReorderingOptions(UBiDi *pBiDi)
What are the reordering options applied to a given Bidi object?
U_DEFINE_LOCAL_OPEN_POINTER
#define U_DEFINE_LOCAL_OPEN_POINTER(LocalPointerClassName, Type, closeFunction)
"Smart pointer" definition macro, deletes objects via the closeFunction.
Definition: localpointer.h:356
UBiDi
struct UBiDi UBiDi
Definition: ubidi.h:474
ubidi_getResultLength
int32_t ubidi_getResultLength(const UBiDi *pBiDi)
Get the length of the reordered text resulting from the last call to ubidi_setPara().
ubidi_getParagraph
int32_t ubidi_getParagraph(const UBiDi *pBiDi, int32_t charIndex, int32_t *pParaStart, int32_t *pParaLimit, UBiDiLevel *pParaLevel, UErrorCode *pErrorCode)
Get a paragraph, given a position within the text.
UBIDI_REORDER_DEFAULT
@ UBIDI_REORDER_DEFAULT
Regular Logical to Visual Bidi algorithm according to Unicode.
Definition: ubidi.h:691
UBiDiDirection
UBiDiDirection
UBiDiDirection values indicate the text direction.
Definition: ubidi.h:417
ubidi_getCustomizedClass
UCharDirection ubidi_getCustomizedClass(UBiDi *pBiDi, UChar32 c)
Retrieve the Bidi class for a given code point.
ubidi_getLength
int32_t ubidi_getLength(const UBiDi *pBiDi)
Get the length of the text.
ubidi_getLogicalRun
void ubidi_getLogicalRun(const UBiDi *pBiDi, int32_t logicalPosition, int32_t *pLogicalLimit, UBiDiLevel *pLevel)
Get a logical run.
ubidi_close
void ubidi_close(UBiDi *pBiDi)
ubidi_close() must be called to free the memory associated with a UBiDi object.
LocalUBiDiPointer
"Smart pointer" class, closes a UBiDi via ubidi_close().
ubidi_orderParagraphsLTR
void ubidi_orderParagraphsLTR(UBiDi *pBiDi, UBool orderParagraphsLTR)
Specify whether block separators must be allocated level zero, so that successive paragraphs will pro...
UBiDiClassCallback
UCharDirection UBiDiClassCallback(const void *context, UChar32 c)
Callback type declaration for overriding default Bidi class values with custom ones.
Definition: ubidi.h:1991
ubidi_isOrderParagraphsLTR
UBool ubidi_isOrderParagraphsLTR(UBiDi *pBiDi)
Is this Bidi object set to allocate level 0 to block separators so that successive paragraphs progres...
localpointer.h
C++ API: "Smart pointers" for use with and in ICU4C C++ code.
ubidi_setPara
void ubidi_setPara(UBiDi *pBiDi, const UChar *text, int32_t length, UBiDiLevel paraLevel, UBiDiLevel *embeddingLevels, UErrorCode *pErrorCode)
Perform the Unicode Bidi algorithm.
ubidi_getLogicalMap
void ubidi_getLogicalMap(UBiDi *pBiDi, int32_t *indexMap, UErrorCode *pErrorCode)
Get a logical-to-visual index map (array) for the characters in the UBiDi (paragraph or line) object.
UBIDI_REORDER_INVERSE_LIKE_DIRECT
@ UBIDI_REORDER_INVERSE_LIKE_DIRECT
Visual to Logical algorithm equivalent to the regular Logical to Visual algorithm.
Definition: ubidi.h:716
ubidi_openSized
UBiDi * ubidi_openSized(int32_t maxLength, int32_t maxRunCount, UErrorCode *pErrorCode)
Allocate a UBiDi structure with preallocated memory for internal structures.
ubidi_getVisualRun
UBiDiDirection ubidi_getVisualRun(UBiDi *pBiDi, int32_t runIndex, int32_t *pLogicalStart, int32_t *pLength)
Get one run's logical start, length, and directionality, which can be 0 for LTR or 1 for RTL.
UBIDI_MIXED
@ UBIDI_MIXED
Mixed-directional text.
Definition: ubidi.h:448
U_STABLE
#define U_STABLE
This is used to declare a function as a stable public ICU C API.
Definition: umachine.h:109
uchar.h
C API: Unicode Properties.
UChar
uint16_t UChar
Define UChar to be UCHAR_TYPE, if that is #defined (for example, to char16_t), or wchar_t if that is ...
Definition: umachine.h:312
UBIDI_REORDER_COUNT
@ UBIDI_REORDER_COUNT
Number of values for reordering mode.
Definition: ubidi.h:723
ubidi_getProcessedLength
int32_t ubidi_getProcessedLength(const UBiDi *pBiDi)
Get the length of the source text processed by the last call to ubidi_setPara().
UBIDI_REORDER_RUNS_ONLY
@ UBIDI_REORDER_RUNS_ONLY
Reorder runs only to transform a Logical LTR string to the Logical RTL string with the same display,...
Definition: ubidi.h:707
ubidi_getLevelAt
UBiDiLevel ubidi_getLevelAt(const UBiDi *pBiDi, int32_t charIndex)
Get the level for one character.
ubidi_getDirection
UBiDiDirection ubidi_getDirection(const UBiDi *pBiDi)
Get the directionality of the text.
ubidi_getVisualIndex
int32_t ubidi_getVisualIndex(UBiDi *pBiDi, int32_t logicalIndex, UErrorCode *pErrorCode)
Get the visual position from a logical text position.
ubidi_getParaLevel
UBiDiLevel ubidi_getParaLevel(const UBiDi *pBiDi)
Get the paragraph level of the text.
U_NAMESPACE_END
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:130
U_NAMESPACE_BEGIN
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:129
UBIDI_OPTION_REMOVE_CONTROLS
@ UBIDI_OPTION_REMOVE_CONTROLS
option bit for ubidi_setReorderingOptions: remove Bidi control characters
Definition: ubidi.h:969
ubidi_writeReordered
int32_t ubidi_writeReordered(UBiDi *pBiDi, UChar *dest, int32_t destSize, uint16_t options, UErrorCode *pErrorCode)
Take a UBiDi object containing the reordering information for a piece of text (one or more paragraphs...