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

U_STABLE void U_EXPORT2 usearch_setText ( UStringSearch strsrch,
const UChar *  text,
int32_t  textlength,
UErrorCode status 
)

Set the string text to be searched. Text iteration will hence begin at the start of the text string. This method is useful if you want to re-use an iterator to search for the same pattern within a different body of text.

Parameters:
strsrch search iterator data struct
text new string to look for match
textlength length of the new string, -1 for null-termination
status for errors if it occurs. If text is NULL, or textlength is 0 then an U_ILLEGAL_ARGUMENT_ERROR is returned with no change done to strsrch.
See also:
usearch_getText ICU 2.4

Definition at line 2961 of file usearch.cpp.

References NULL, TRUE, U_ILLEGAL_ARGUMENT_ERROR, u_strlen(), U_SUCCESS, and USEARCH_DONE.

{
    if (U_SUCCESS(*status)) {
        if (strsrch == NULL || text == NULL || textlength < -1 ||
            textlength == 0) {
            *status = U_ILLEGAL_ARGUMENT_ERROR;
        }
        else {
            if (textlength == -1) {
                textlength = u_strlen(text);
            }
            strsrch->search->text       = text;
            strsrch->search->textLength = textlength;
            ucol_setText(strsrch->textIter, text, textlength, status);
            strsrch->search->matchedIndex  = USEARCH_DONE;
            strsrch->search->matchedLength = 0;
            strsrch->search->reset         = TRUE;
#if !UCONFIG_NO_BREAK_ITERATION
            if (strsrch->search->breakIter != NULL) {
                ubrk_setText(strsrch->search->breakIter, text,
                             textlength, status);
            }
            ubrk_setText(strsrch->search->internalBreakIter, text, textlength, status);
#endif
        }
    }
}


Generated by  Doxygen 1.6.0   Back to index