Logo Search packages:      
Sourcecode: icu version File versions  Download package

U_STABLE const UBiDiLevel* U_EXPORT2 ubidi_getLevels ( UBiDi pBiDi,
UErrorCode pErrorCode 
)

Get an array of levels for each character.

Note that this function may allocate memory under some circumstances, unlike ubidi_getLevelAt().

Parameters:
pBiDi is the paragraph or line UBiDi object, whose text length must be strictly positive.
pErrorCode must be a valid pointer to an error code value.
Returns:
The levels array for the text, or NULL if an error occurs.
See also:
UBiDiLevel

ubidi_getProcessedLength ICU 2.0

Definition at line 261 of file ubidiln.c.

References NULL, U_ILLEGAL_ARGUMENT_ERROR, and U_MEMORY_ALLOCATION_ERROR.

                                                      {
    int32_t start, length;

    RETURN_IF_NULL_OR_FAILING_ERRCODE(pErrorCode, NULL);
    RETURN_IF_NOT_VALID_PARA_OR_LINE(pBiDi, *pErrorCode, NULL);
    if((length=pBiDi->length)<=0) {
        *pErrorCode=U_ILLEGAL_ARGUMENT_ERROR;
        return NULL;
    }
    if((start=pBiDi->trailingWSStart)==length) {
        /* the current levels array reflects the WS run */
        return pBiDi->levels;
    }

    /*
     * After the previous if(), we know that the levels array
     * has an implicit trailing WS run and therefore does not fully
     * reflect itself all the levels.
     * This must be a UBiDi object for a line, and
     * we need to create a new levels array.
     */
    if(getLevelsMemory(pBiDi, length)) {
        UBiDiLevel *levels=pBiDi->levelsMemory;

        if(start>0 && levels!=pBiDi->levels) {
            uprv_memcpy(levels, pBiDi->levels, start);
        }
        /* pBiDi->paraLevel is ok even if contextual multiple paragraphs,
           since pBidi is a line object                                     */
        uprv_memset(levels+start, pBiDi->paraLevel, length-start);

        /* this new levels array is set for the line and reflects the WS run */
        pBiDi->trailingWSStart=length;
        return pBiDi->levels=levels;
    } else {
        /* out of memory */
        *pErrorCode=U_MEMORY_ALLOCATION_ERROR;
        return NULL;
    }
}


Generated by  Doxygen 1.6.0   Back to index