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

U_STABLE UBool U_EXPORT2 utext_moveIndex32 ( UText ut,
int32_t  delta 
)

Move the iterator postion by delta code points. The number of code points is a signed number; a negative delta will move the iterator backwards, towards the start of the text.

The index is moved by delta code points forward or backward, but no further backward than to 0 and no further forward than to utext_nativeLength(). The resulting index value will be in between 0 and length, inclusive.

Parameters:
ut the text to be accessed.
delta the signed number of code points to move the iteration position.
Returns:
TRUE if the position could be moved the requested number of positions while staying within the range [0 - text length]. ICU 3.4

Definition at line 41 of file utext.cpp.

References UText::chunkContents, UText::chunkLength, UText::chunkNativeLimit, UText::chunkNativeStart, UText::chunkOffset, FALSE, TRUE, U16_IS_SURROGATE, and U_SENTINEL.

                                            {
    UChar32  c;
    if (delta > 0) {
        do {
            if(ut->chunkOffset>=ut->chunkLength && !utext_access(ut, ut->chunkNativeLimit, TRUE)) {
                return FALSE;
            }
            c = ut->chunkContents[ut->chunkOffset];
            if (U16_IS_SURROGATE(c)) {
                c = utext_next32(ut);
                if (c == U_SENTINEL) {
                    return FALSE;
                }
            } else {
                ut->chunkOffset++;
            }
        } while(--delta>0);

    } else if (delta<0) {
        do {
            if(ut->chunkOffset<=0 && !utext_access(ut, ut->chunkNativeStart, FALSE)) {
                return FALSE;
            }
            c = ut->chunkContents[ut->chunkOffset-1];
            if (U16_IS_SURROGATE(c)) {
                c = utext_previous32(ut);
                if (c == U_SENTINEL) {
                    return FALSE;
                }
            } else {
                ut->chunkOffset--;
            }
        } while(++delta<0);
    }

    return TRUE;
}


Generated by  Doxygen 1.6.0   Back to index