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

int32_t StringMatcher::replace ( Replaceable text,
int32_t  start,
int32_t  limit,
int32_t &  cursor 
) [virtual]

Replace characters in 'text' from 'start' to 'limit' with the output text of this object. Update the 'cursor' parameter to give the cursor position and return the length of the replacement text.

text the text to be matched
start inclusive start index of text to be replaced
limit exclusive end index of text to be replaced; must be greater than or equal to start
cursor output parameter for the cursor position. Not all replacer objects will update this, but in a complete tree of replacer objects, representing the entire output side of a transliteration rule, at least one must update it.
the number of 16-bit code units in the text replacing the characters at offsets start..(limit-1) in text
UnicodeReplacer API

Implements UnicodeReplacer.

Definition at line 213 of file strmatch.cpp.

References Replaceable::copy(), Replaceable::handleReplaceBetween(), matchLimit, and matchStart.

    int32_t outLen = 0;
    // Copy segment with out-of-band data
    int32_t dest = limit;
    // If there was no match, that means that a quantifier
    // matched zero-length.  E.g., x (a)* y matched "xy".
    if (matchStart >= 0) {
        if (matchStart != matchLimit) {
            text.copy(matchStart, matchLimit, dest);
            outLen = matchLimit - matchStart;
    text.handleReplaceBetween(start, limit, EMPTY); // delete original text
    return outLen;

Generated by  Doxygen 1.6.0   Back to index