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

U_STABLE void U_EXPORT2 ucol_setText ( UCollationElements elems,
const UChar *  text,
int32_t  textLength,
UErrorCode status 
)

Set the text containing the collation elements. Property settings for collation will remain the same. In order to reset the iterator to the current collation property settings, the API reset() has to be called.

Parameters:
elems The UCollationElements to set.
text The source text containing the collation elements.
textLength The length of text, or -1 if null-terminated.
status A pointer to an UErrorCode to receive any errors.
See also:
ucol_getText ICU 2.0

Definition at line 665 of file ucoleitr.cpp.

References FALSE, NULL, TRUE, and U_FAILURE.

{
    if (U_FAILURE(*status)) {
        return;
    }

    if (elems->isWritable && elems->iteratordata_.string != NULL)
    {
        uprv_free((UChar *)elems->iteratordata_.string);
    }

    if (text == NULL) {
        textLength = 0;
    }

    elems->isWritable = FALSE;
    
    /* free offset buffer to avoid memory leak before initializing. */
    ucol_freeOffsetBuffer(&(elems->iteratordata_));
    /* Ensure that previously allocated extendCEs is freed before setting to NULL. */
    if (elems->iteratordata_.extendCEs != NULL) {
        uprv_free(elems->iteratordata_.extendCEs);
    }
    uprv_init_collIterate(elems->iteratordata_.coll, text, textLength, 
                          &elems->iteratordata_, status);

    elems->reset_   = TRUE;
}


Generated by  Doxygen 1.6.0   Back to index