Proposal: new UnicodeSet constructor, applyPattern
Alan Liu <[email protected]>
| Newsgroups | gmane.comp.lib.icu.general |
|---|---|
| Message-ID | <OF2F7A68C5.C3EEDE77-ON88256DBF.007813B8-88256DBF.007885EF@us.ibm.com> |
Jitterbug 3262
http://www.jtcsv.com/cgibin/icu-bugs/others?id=3262
Expires: Oct 21 2003
I've added two new API to UnicodeSet:
/**
* Constructs a set from the given pattern. See the class description
* for the syntax of the pattern language.
* @param pattern a string specifying what characters are in the set
* @param pos on input, the position in pattern at which to start
parsing.
* On output, the position after the last character parsed.
* @param options bitmask for options to apply to the pattern.
* Valid options are USET_IGNORE_SPACE and USET_CASE_INSENSITIVE.
* @param symbols a symbol table mapping variable names to values
* and stand-in characters to UnicodeSets; may be NULL
* @param status input-output error code
* @draft ICU 2.8
*/
UnicodeSet(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.
*
* @param 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.
* @param 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.
* @param options bitmask for options to apply to the pattern.
* Valid options are USET_IGNORE_SPACE and USET_CASE_INSENSITIVE.
* @param symbols a symbol table mapping variable names to
* values and stand-ins to UnicodeSets; may be NULL
* @return a reference to this
* @draft ICU 2.8
*/
UnicodeSet& applyPattern(const UnicodeString& pattern,
ParsePosition& pos,
uint32_t options,
const SymbolTable* symbols,
UErrorCode& status);
These API expose previously "hidden" functionality of UnicodeSet:
1. The ability to parse part of a string (ParsePosition).
2. The ability to specify control options for white space and case
sensitivity (and other options in the future).
3. The ability to pass in a SymbolTable to control variable dereferencing
and stand-in expansion to nested UnicodeSets.
Please send comments to this mailing list.
Alan Liu
IBM GCoC - San Jose