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

int32_t UnicodeSet::matchRest ( const Replaceable text,
int32_t  start,
int32_t  limit,
const UnicodeString s 
) [static, private]

Returns the longest match for s in text at the given position. If limit > start then match forward from start+1 to limit matching all characters except s.charAt(0). If limit < start, go backward starting from start-1 matching all characters except s.charAt(s.length()-1). This method assumes that the first character, text.charAt(start), matches s, so it does not check it.

text the text to match
start the first character to match. In the forward direction, text.charAt(start) is matched against s.charAt(0). In the reverse direction, it is matched against s.charAt(s.length()-1).
limit the limit offset for matching, either last+1 in the forward direction, or last-1 in the reverse direction, where last is the index of the last character to match.
If part of s matches up to the limit, return |limit - start|. If all of s matches before reaching the limit, return s.length(). If there is a mismatch between s and text, return 0

Definition at line 730 of file uniset.cpp.

References UnicodeString::charAt(), Replaceable::charAt(), and UnicodeString::length().

Referenced by matches().

    int32_t i;
    int32_t maxLen;
    int32_t slen = s.length();
    if (start < limit) {
        maxLen = limit - start;
        if (maxLen > slen) maxLen = slen;
        for (i = 1; i < maxLen; ++i) {
            if (text.charAt(start + i) != s.charAt(i)) return 0;
    } else {
        maxLen = start - limit;
        if (maxLen > slen) maxLen = slen;
        --slen; // <=> slen = s.length() - 1;
        for (i = 1; i < maxLen; ++i) {
            if (text.charAt(start - i) != s.charAt(slen - i)) return 0;
    return maxLen;

Generated by  Doxygen 1.6.0   Back to index