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

U_STABLE int32_t U_EXPORT2 uset_applyPattern ( USet set,
const UChar *  pattern,
int32_t  patternLength,
uint32_t  options,
UErrorCode status 

Modifies the set to represent the set specified by the given pattern. See the UnicodeSet class description for the syntax of the pattern language. See also the User Guide chapter about UnicodeSet. Empties the set passed before applying the pattern. A frozen set will not be modified.

set The set to which the pattern is to be applied.
pattern A pointer to UChar string specifying what characters are in the set. The character at pattern[0] must be a '['.
patternLength The length of the UChar string. -1 if NUL terminated.
options A bitmask for options to apply to the pattern. Valid options are USET_IGNORE_SPACE and USET_CASE_INSENSITIVE.
status Returns an error if the pattern cannot be parsed.
Upon successful parse, the value is either the index of the character after the closing ']' of the parsed pattern. If the status code indicates failure, then the return value is the index of the error in the source.
ICU 2.8

Definition at line 71 of file uset_props.cpp.

References ParsePosition::getIndex(), NULL, U_FAILURE, and U_ILLEGAL_ARGUMENT_ERROR.


    // status code needs to be checked since we 
    // dereference it
    if(status == NULL || U_FAILURE(*status)){
        return 0;

    // check only the set paramenter
    // if pattern is NULL or null terminate
    // UnicodeString constructor takes care of it
    if(set == NULL){
        *status = U_ILLEGAL_ARGUMENT_ERROR;
        return 0;

    UnicodeString pat(pattern, patternLength);

    ParsePosition pos;
    ((UnicodeSet*) set)->applyPattern(pat, pos, options, NULL, *status);
    return pos.getIndex();

Generated by  Doxygen 1.6.0   Back to index