From 9e868b81f110d1c201d05164b5fc356fadd646eb Mon Sep 17 00:00:00 2001 From: Markus Scherer Date: Thu, 18 May 2000 20:22:21 +0000 Subject: [PATCH] ICU-107 add api & functionality for inverse BiDi (visual->logical) X-SVN-Rev: 1406 --- icu4c/source/common/unicode/bidi.h | 87 +++++++++++++++++++++++++++++- 1 file changed, 86 insertions(+), 1 deletion(-) diff --git a/icu4c/source/common/unicode/bidi.h b/icu4c/source/common/unicode/bidi.h index b9016df52e2..a30b9565aea 100644 --- a/icu4c/source/common/unicode/bidi.h +++ b/icu4c/source/common/unicode/bidi.h @@ -1,7 +1,7 @@ /* ******************************************************************************* * -* Copyright (C) 1999, International Business Machines +* Copyright (C) 1999-2000, International Business Machines * Corporation and others. All Rights Reserved. * ******************************************************************************* @@ -55,6 +55,29 @@ public: */ ~BiDi(); + /** + * Modify the operation of the BiDi algorithm such that it + * approximates an "inverse BiDi" algorithm. This function + * must be called before setPara(). + * + * @param isInverse specifies "forward" or "inverse" BiDi operation + * + * @see setPara + * @see writeReordered + * @draft + */ + void + setInverse(bool_t isInverse); + + /** + * Is this BiDi object set to perform the inverse BiDi algorithm? + * + * @see setInverse + * @draft + */ + bool_t + isInverse(); + /** @memo Set this object for one paragraph's text. * @stable */ @@ -78,6 +101,12 @@ public: UBiDiDirection getDirection() const; + /** @memo Get the pointer to the text. + * @draft + */ + const UChar * + getText() const; + /** @memo Get the length of the text. * @stable */ @@ -169,6 +198,32 @@ public: static void invertMap(const UTextOffset *srcMap, UTextOffset *destMap, UTextOffset length); + /** + * Use the BiDi object containing the reordering + * information for one paragraph or line of text as set by + * setPara() or setLine() and + * write a reordered string to the destination buffer. + * + * @see ubidi_writeReordered + * @draft + */ + UTextOffset + writeReordered(UChar *dest, int32_t destSize, + uint16_t options, + UErrorCode &rErrorCode); + + /** + * Reverse a Right-To-Left run of Unicode text. + * + * @see ubidi_writeReverse + * @draft + */ + static UTextOffset + writeReverse(const UChar *src, int32_t srcLength, + UChar *dest, int32_t destSize, + uint16_t options, + UErrorCode &rErrorCode); + protected: UBiDi *pBiDi; }; @@ -199,6 +254,16 @@ inline BiDi::~BiDi() { pBiDi=0; } +inline void +BiDi::setInverse(bool_t isInverse) { + ubidi_setInverse(pBiDi, isInverse); +} + +inline bool_t +BiDi::isInverse() { + return ubidi_isInverse(pBiDi); +} + inline BiDi & BiDi::setPara(const UChar *text, UTextOffset length, UBiDiLevel paraLevel, UBiDiLevel *embeddingLevels, @@ -221,6 +286,11 @@ BiDi::getDirection() const { return ubidi_getDirection(pBiDi); } +inline const UChar * +BiDi::getText() const { + return ubidi_getText(pBiDi); +} + inline UTextOffset BiDi::getLength() const { return ubidi_getLength(pBiDi); @@ -292,4 +362,19 @@ BiDi::invertMap(const UTextOffset *srcMap, UTextOffset *destMap, UTextOffset len ubidi_invertMap(srcMap, destMap, length); } +inline UTextOffset +BiDi::writeReordered(UChar *dest, int32_t destSize, + uint16_t options, + UErrorCode &rErrorCode) { + return ubidi_writeReordered(pBiDi, dest, destSize, options, &rErrorCode); +} + +inline UTextOffset +BiDi::writeReverse(const UChar *src, int32_t srcLength, + UChar *dest, int32_t destSize, + uint16_t options, + UErrorCode &rErrorCode) { + return ubidi_writeReverse(src, srcLength, dest, destSize, options, &rErrorCode); +} + #endif