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

UnicodeSet & UnicodeSet::applyPattern ( const UnicodeString pattern,
ParsePosition pos,
uint32_t  options,
const SymbolTable symbols,
UErrorCode status 

Parses the given pattern, starting at the given position. The character at pattern.charAt(pos.getIndex()) must be '[', or the parse fails. Parsing continues until the corresponding closing ']'. If a syntax error is encountered between the opening and closing brace, the parse fails. Upon return from a successful parse, the ParsePosition is updated to point to the character following the closing ']', and a StringBuffer containing a pairs list for the parsed pattern is returned. This method calls itself recursively to parse embedded subpatterns. Empties the set passed before applying the pattern. A frozen set will not be modified.

pattern the string containing the pattern to be parsed. The portion of the string from pos.getIndex(), which must be a '[', to the corresponding closing ']', is parsed.
pos upon entry, the position at which to being parsing. The character at pattern.charAt(pos.getIndex()) must be a '['. Upon return from a successful parse, pos.getIndex() is either the character after the closing ']' of the parsed pattern, or pattern.length() if the closing ']' is the last character of the pattern string.
options bitmask for options to apply to the pattern. Valid options are USET_IGNORE_SPACE and USET_CASE_INSENSITIVE.
symbols a symbol table mapping variable names to values and stand-ins to UnicodeSets; may be NULL
status returns U_ILLEGAL_ARGUMENT_ERROR if the pattern contains a syntax error.
a reference to this ICU 2.8

Definition at line 448 of file uniset_props.cpp.

References applyPattern(), RuleCharacterIterator::inVariable(), isFrozen(), setPattern(), U_FAILURE, and U_MALFORMED_SET.

    if (U_FAILURE(status) || isFrozen()) {
        return *this;
    // Need to build the pattern in a temporary string because
    // _applyPattern calls add() etc., which set pat to empty.
    UnicodeString rebuiltPat;
    RuleCharacterIterator chars(pattern, symbols, pos);
    applyPattern(chars, symbols, rebuiltPat, options, status);
    if (U_FAILURE(status)) return *this;
    if (chars.inVariable()) {
        // syntaxError(chars, "Extra chars in variable value");
        status = U_MALFORMED_SET;
        return *this;
    return *this;

Generated by  Doxygen 1.6.0   Back to index