home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 6 / AACD06.ISO / AACD / Programming / ICU / include / uniset.h < prev    next >
C/C++ Source or Header  |  1999-11-12  |  24KB  |  617 lines

  1. /*
  2. **********************************************************************
  3. *   Copyright (C) 1999 Alan Liu and others. All rights reserved.
  4. **********************************************************************
  5. *   Date        Name        Description
  6. *   10/20/99    alan        Creation.
  7. **********************************************************************
  8. */
  9.  
  10. #ifndef UNICODESET_H
  11. #define UNICODESET_H
  12.  
  13. #include "utypes.h"
  14. #include "unistr.h"
  15.  
  16. class ParsePosition;
  17.  
  18. /**
  19.  * A mutable set of Unicode characters.  Objects of this class
  20.  * represent <em>character classes</em> used in regular expressions.
  21.  * Such classes specify a subset of the set of all Unicode characters,
  22.  * which in this implementation is the characters from U+0000 to
  23.  * U+FFFF, ignoring surrogates.
  24.  *
  25.  * <p>This class supports two APIs.  The first is modeled after Java 2's
  26.  * <code>java.util.Set</code> interface, although this class does not
  27.  * implement that interface.  All methods of <code>Set</code> are
  28.  * supported, with the modification that they take a character range
  29.  * or single character instead of an <code>Object</code>, and they
  30.  * take a <code>UnicodeSet</code> instead of a <code>Collection</code>.
  31.  *
  32.  * <p>The second API is the
  33.  * <code>applyPattern()</code>/<code>toPattern()</code> API from the
  34.  * <code>Format</code>-derived classes.  Unlike the
  35.  * methods that add characters, add categories, and control the logic
  36.  * of the set, the method <code>applyPattern()</code> sets all
  37.  * attributes of a <code>UnicodeSet</code> at once, based on a
  38.  * string pattern.
  39.  *
  40.  * <p>In addition, the set complement operation is supported through
  41.  * the <code>complement()</code> method.
  42.  *
  43.  * <p><b>Pattern syntax</b></p>
  44.  *
  45.  * Patterns are accepted by the constructors and the
  46.  * <code>applyPattern()</code> methods and returned by the
  47.  * <code>toPattern()</code> method.  These patterns follow a syntax
  48.  * similar to that employed by version 8 regular expression character
  49.  * classes:
  50.  *
  51.  * <blockquote><code>
  52.  * pattern := ('[' '^'? item* ']') | ('[:' '^'? category ':]')<br>
  53.  * item := char | (char '-' char) | pattern-expr<br>
  54.  * pattern-expr := pattern | pattern-expr pattern | pattern-expr op pattern<br>
  55.  * op := '&' | '-'<br>
  56.  * special := '[' | ']' | '-'<br>
  57.  * char := <em>any character that is not</em> special |
  58.  *        ('\' <em>any character</em>) |
  59.  *        ('\\u' hex hex hex hex)<br>
  60.  * hex := <em>any hex digit, as defined by </em>Character.digit(c, 16)
  61.  * </code>
  62.  *
  63.  * <br>Legend:
  64.  *
  65.  * <table>
  66.  * <tr><td width=20%><code>a:=b</code>
  67.  * <td><code>a</code> may be replaced by
  68.  * <code>b</code>
  69.  * <tr><td><code>a?</code>
  70.  * <td>zero or one instance of <code>a</code><br>
  71.  * <tr><td><code>a*</code>
  72.  * <td>one or more instances of <code>a</code><br>
  73.  * <tr><td><code>a|b</code>
  74.  * <td>either <code>a</code> or <code>b</code><br>
  75.  * <tr><td><code>'a'</code>
  76.  * <td>the literal string between the quotes
  77.  * </table>
  78.  * </blockquote>
  79.  *
  80.  * Patterns specify individual characters, ranges of characters, and
  81.  * Unicode character categories.  When elements are concatenated, they
  82.  * specify their union.  To complement a set, place a '^' immediately
  83.  * after the opening '[' or '[:'.  In any other location, '^' has no
  84.  * special meaning.
  85.  *
  86.  * <p>Ranges are indicated by placing two a '-' between two
  87.  * characters, as in "a-z".  This specifies the range of all
  88.  * characters from the left to the right, in Unicode order.  If the
  89.  * left and right characters are the same, then the range consists of
  90.  * just that character.  If the left character is greater than the
  91.  * right character it is a syntax error.  If a '-' occurs as the first
  92.  * character after the opening '[' or '[^', or if it occurs as the
  93.  * last character before the closing ']', then it is taken as a
  94.  * literal.  Thus "[a\-b]", "[-ab]", and "[ab-]" all indicate the same
  95.  * set of three characters, 'a', 'b', and '-'.
  96.  *
  97.  * <p>Sets may be intersected using the '&' operator or the asymmetric
  98.  * set difference may be taken using the '-' operator, for example,
  99.  * "[[:L:]&[\u0000-\u0FFF]]" indicates the set of all Unicode letters
  100.  * with values less than 4096.  Operators ('&' and '|') have equal
  101.  * precedence and bind left-to-right.  Thus
  102.  * "[[:L:]-[a-z]-[\u0100-\u01FF]]" is equivalent to
  103.  * "[[[:L:]-[a-z]]-[\u0100-\u01FF]]".  This only really matters for
  104.  * difference; intersection is commutative.
  105.  *
  106.  * <table>
  107.  * <tr valign=top><td nowrap><code>[a]</code><td>The set containing 'a'
  108.  * <tr valign=top><td nowrap><code>[a-z]</code><td>The set containing 'a'
  109.  * through 'z' and all letters in between, in Unicode order
  110.  * <tr valign=top><td nowrap><code>[^a-z]</code><td>The set containing
  111.  * all characters but 'a' through 'z',
  112.  * that is, U+0000 through 'a'-1 and 'z'+1 through U+FFFF
  113.  * <tr valign=top><td nowrap><code>[[<em>pat1</em>][<em>pat2</em>]]</code>
  114.  * <td>The union of sets specified by <em>pat1</em> and <em>pat2</em>
  115.  * <tr valign=top><td nowrap><code>[[<em>pat1</em>]&[<em>pat2</em>]]</code>
  116.  * <td>The intersection of sets specified by <em>pat1</em> and <em>pat2</em>
  117.  * <tr valign=top><td nowrap><code>[[<em>pat1</em>]-[<em>pat2</em>]]</code>
  118.  * <td>The asymmetric difference of sets specified by <em>pat1</em> and
  119.  * <em>pat2</em>
  120.  * <tr valign=top><td nowrap><code>[:Lu:]</code>
  121.  * <td>The set of characters belonging to the given
  122.  * Unicode category, as defined by <code>Character.getType()</code>; in
  123.  * this case, Unicode uppercase letters
  124.  * <tr valign=top><td nowrap><code>[:L:]</code>
  125.  * <td>The set of characters belonging to all Unicode categories
  126.  * starting wih 'L', that is, <code>[[:Lu:][:Ll:][:Lt:][:Lm:][:Lo:]]</code>.
  127.  * </table>
  128.  *
  129.  * <p><b>Character categories.</b>
  130.  *
  131.  * Character categories are specified using the POSIX-like syntax
  132.  * '[:Lu:]'.  The complement of a category is specified by inserting
  133.  * '^' after the opening '[:'.  The following category names are
  134.  * recognized.  Actual determination of category data uses
  135.  * <code>Unicode::getType()</code>, so it reflects the underlying
  136.  * data used by <code>Unicode</code>.
  137.  *
  138.  * <pre>
  139.  * Normative
  140.  *     Mn = Mark, Non-Spacing
  141.  *     Mc = Mark, Spacing Combining
  142.  *     Me = Mark, Enclosing
  143.  * 
  144.  *     Nd = Number, Decimal Digit
  145.  *     Nl = Number, Letter
  146.  *     No = Number, Other
  147.  * 
  148.  *     Zs = Separator, Space
  149.  *     Zl = Separator, Line
  150.  *     Zp = Separator, Paragraph
  151.  * 
  152.  *     Cc = Other, Control
  153.  *     Cf = Other, Format
  154.  *     Cs = Other, Surrogate
  155.  *     Co = Other, Private Use
  156.  *     Cn = Other, Not Assigned
  157.  * 
  158.  * Informative
  159.  *     Lu = Letter, Uppercase
  160.  *     Ll = Letter, Lowercase
  161.  *     Lt = Letter, Titlecase
  162.  *     Lm = Letter, Modifier
  163.  *     Lo = Letter, Other
  164.  * 
  165.  *     Pc = Punctuation, Connector
  166.  *     Pd = Punctuation, Dash
  167.  *     Ps = Punctuation, Open
  168.  *     Pe = Punctuation, Close
  169.  *     Pi = Punctuation, Initial quote
  170.  *     Pf = Punctuation, Final quote
  171.  *     Po = Punctuation, Other
  172.  * 
  173.  *     Sm = Symbol, Math
  174.  *     Sc = Symbol, Currency
  175.  *     Sk = Symbol, Modifier
  176.  *     So = Symbol, Other
  177.  * </pre>
  178.  *
  179.  * @author Alan Liu
  180.  */
  181. class U_I18N_API UnicodeSet {
  182.  
  183.     /**
  184.      * The internal representation is a UnicodeString of even length.
  185.      * Each pair of characters represents a range that is included in
  186.      * the set.  A single character c is represented as cc.  Thus, the
  187.      * ranges in the set are (a,b), a and b inclusive, where a =
  188.      * pairs.charAt(i) and b = pairs.charAt(i+1) for all even i, 0 <=
  189.      * i <= pairs.length()-2.  Pairs are always stored in ascending
  190.      * Unicode order.  Pairs are always stored in shortest form.  For
  191.      * example, if the pair "hh", representing the single character
  192.      * 'h', is added to the pairs list "agik", representing the ranges
  193.      * 'a'-'g' and 'i'-'k', the result is "ak", not "aghhik".
  194.      */
  195.     UnicodeString pairs;
  196.  
  197.     static const UnicodeString CATEGORY_NAMES;
  198.  
  199.     /**
  200.      * A cache mapping character category integers, as returned by
  201.      * Unicode::getType(), to pairs strings.  Entries are initially
  202.      * zero length and are filled in on demand.
  203.      */
  204.     static UnicodeString* CATEGORY_PAIRS_CACHE;
  205.  
  206.     //----------------------------------------------------------------
  207.     // Debugging and testing
  208.     //----------------------------------------------------------------
  209.  
  210. public:
  211.  
  212.     /**
  213.      * Return the representation of this set as a list of character
  214.      * ranges.  Ranges are listed in ascending Unicode order.  For
  215.      * example, the set [a-zA-M3] is represented as "33AMaz".
  216.      */
  217.     const UnicodeString& getPairs() const;
  218.  
  219.     //----------------------------------------------------------------
  220.     // Constructors &c
  221.     //----------------------------------------------------------------
  222.  
  223. public:
  224.  
  225.     /**
  226.      * Constructs an empty set.
  227.      */
  228.     UnicodeSet();
  229.  
  230.     /**
  231.      * Constructs a set from the given pattern.  See the class
  232.      * description for the syntax of the pattern language.
  233.      * @param pattern a string specifying what characters are in the set
  234.      * @exception <code>IllegalArgumentException</code> if the pattern
  235.      * contains a syntax error.
  236.      */
  237.     UnicodeSet(const UnicodeString& pattern,
  238.                UErrorCode& status);
  239.  
  240.     /**
  241.      * Constructs a set from the given pattern, optionally ignoring
  242.      * white space.  See the class description for the syntax of the
  243.      * pattern language.
  244.      * @param pattern a string specifying what characters are in the set
  245.      * @param ignoreSpaces if <code>true</code>, all spaces in the
  246.      * pattern are ignored, except those preceded by '\\'.  Spaces are
  247.      * those characters for which <code>Character.isSpaceChar()</code>
  248.      * is <code>true</code>.
  249.      * @exception <code>IllegalArgumentException</code> if the pattern
  250.      * contains a syntax error.
  251.      */
  252.     UnicodeSet(const UnicodeString& pattern, bool_t ignoreSpaces,
  253.                UErrorCode& status);
  254.  
  255.     /**
  256.      * Constructs a set from the given Unicode character category.
  257.      * @param category an integer indicating the character category as
  258.      * returned by <code>Character.getType()</code>.
  259.      * @exception <code>IllegalArgumentException</code> if the given
  260.      * category is invalid.
  261.      */
  262.     UnicodeSet(int8_t category, UErrorCode& status);
  263.  
  264.     /**
  265.      * Constructs a set that is identical to the given UnicodeSet.
  266.      */
  267.     UnicodeSet(const UnicodeSet& o);
  268.  
  269.     /**
  270.      * Destructs the set.
  271.      */
  272.     virtual ~UnicodeSet();
  273.  
  274.     /**
  275.      * Assigns this object to be a copy of another.
  276.      */
  277.     UnicodeSet& operator=(const UnicodeSet& o);
  278.  
  279.     /**
  280.      * Compares the specified object with this set for equality.  Returns
  281.      * <tt>true</tt> if the two sets
  282.      * have the same size, and every member of the specified set is
  283.      * contained in this set (or equivalently, every member of this set is
  284.      * contained in the specified set).
  285.      *
  286.      * @param o set to be compared for equality with this set.
  287.      * @return <tt>true</tt> if the specified set is equal to this set.
  288.      */
  289.     virtual bool_t operator==(const UnicodeSet& o) const;
  290.  
  291.     /**
  292.      * Compares the specified object with this set for equality.  Returns
  293.      * <tt>true</tt> if the specified set is not equal to this set.
  294.      */
  295.     bool_t operator!=(const UnicodeSet& o) const;
  296.  
  297.     /**
  298.      * Returns the hash code value for this set.
  299.      *
  300.      * @return the hash code value for this set.
  301.      * @see Object#hashCode()
  302.      */
  303.     virtual int32_t hashCode() const;
  304.  
  305.     //----------------------------------------------------------------
  306.     // Public API
  307.     //----------------------------------------------------------------
  308.  
  309.     /**
  310.      * Modifies this set to represent the set specified by the given
  311.      * pattern, optionally ignoring white space.  See the class
  312.      * description for the syntax of the pattern language.
  313.      * @param pattern a string specifying what characters are in the set
  314.      * @param ignoreSpaces if <code>true</code>, all spaces in the
  315.      * pattern are ignored.  Spaces are those characters for which
  316.      * <code>Character.isSpaceChar()</code> is <code>true</code>.
  317.      * Characters preceded by '\\' are escaped, losing any special
  318.      * meaning they otherwise have.  Spaces may be included by
  319.      * escaping them.
  320.      * @exception <code>IllegalArgumentException</code> if the pattern
  321.      * contains a syntax error.
  322.      */
  323.     virtual void applyPattern(const UnicodeString& pattern,
  324.                               bool_t ignoreSpaces,
  325.                               UErrorCode& status);
  326.  
  327.     /**
  328.      * Modifies this set to represent the set specified by the given
  329.      * pattern.  See the class description for the syntax of the pattern
  330.      * language.
  331.      * @param pattern a string specifying what characters are in the set
  332.      * @exception <code>IllegalArgumentException</code> if the pattern
  333.      * contains a syntax error.
  334.      */
  335.     void applyPattern(const UnicodeString& pattern,
  336.                       UErrorCode& status);
  337.  
  338.     /**
  339.      * Returns a string representation of this set.  If the result of
  340.      * calling this function is passed to a UnicodeSet constructor, it
  341.      * will produce another set that is equal to this one.
  342.      */
  343.     virtual UnicodeString& toPattern(UnicodeString& result) const;
  344.  
  345.     /**
  346.      * Returns the number of elements in this set (its cardinality),
  347.      * <em>n</em>, where <code>0 <= </code><em>n</em><code> <= 65536</code>.
  348.      *
  349.      * @return the number of elements in this set (its cardinality).
  350.      */
  351.     virtual int32_t size() const;
  352.  
  353.     /**
  354.      * Returns <tt>true</tt> if this set contains no elements.
  355.      *
  356.      * @return <tt>true</tt> if this set contains no elements.
  357.      */
  358.     virtual bool_t isEmpty() const;
  359.  
  360.     /**
  361.      * Returns <tt>true</tt> if this set contains the specified range
  362.      * of chars.
  363.      *
  364.      * @return <tt>true</tt> if this set contains the specified range
  365.      * of chars.
  366.      */
  367.     virtual bool_t contains(UChar first, UChar last) const;
  368.  
  369.     /**
  370.      * Returns <tt>true</tt> if this set contains the specified char.
  371.      *
  372.      * @return <tt>true</tt> if this set contains the specified char.
  373.      */
  374.     virtual bool_t contains(UChar c) const;
  375.  
  376.     /**
  377.      * Adds the specified range to this set if it is not already
  378.      * present.  If this set already contains the specified range,
  379.      * the call leaves this set unchanged.  If <code>last > first</code>
  380.      * then an empty range is added, leaving the set unchanged.
  381.      *
  382.      * @param first first character, inclusive, of range to be added
  383.      * to this set.
  384.      * @param last last character, inclusive, of range to be added
  385.      * to this set.
  386.      */
  387.     virtual void add(UChar first, UChar last);
  388.  
  389.     /**
  390.      * Adds the specified character to this set if it is not already
  391.      * present.  If this set already contains the specified character,
  392.      * the call leaves this set unchanged.
  393.      */
  394.     virtual void add(UChar c);
  395.  
  396.     /**
  397.      * Removes the specified range from this set if it is present.
  398.      * The set will not contain the specified range once the call
  399.      * returns.  If <code>last > first</code> then an empty range is
  400.      * removed, leaving the set unchanged.
  401.      * 
  402.      * @param first first character, inclusive, of range to be removed
  403.      * from this set.
  404.      * @param last last character, inclusive, of range to be removed
  405.      * from this set.
  406.      */
  407.     virtual void remove(UChar first, UChar last);
  408.  
  409.     /**
  410.      * Removes the specified character from this set if it is present.
  411.      * The set will not contain the specified range once the call
  412.      * returns.
  413.      */
  414.     virtual void remove(UChar c);
  415.  
  416.     /**
  417.      * Returns <tt>true</tt> if the specified set is a <i>subset</i>
  418.      * of this set.
  419.      *
  420.      * @param c set to be checked for containment in this set.
  421.      * @return <tt>true</tt> if this set contains all of the elements of the
  422.      *            specified set.
  423.      */
  424.     virtual bool_t containsAll(const UnicodeSet& c) const;
  425.  
  426.     /**
  427.      * Adds all of the elements in the specified set to this set if
  428.      * they're not already present.  This operation effectively
  429.      * modifies this set so that its value is the <i>union</i> of the two
  430.      * sets.  The behavior of this operation is unspecified if the specified
  431.      * collection is modified while the operation is in progress.
  432.      *
  433.      * @param c set whose elements are to be added to this set.
  434.      * @see #add(char, char)
  435.      */
  436.     virtual void addAll(const UnicodeSet& c);
  437.  
  438.     /**
  439.      * Retains only the elements in this set that are contained in the
  440.      * specified set.  In other words, removes from this set all of
  441.      * its elements that are not contained in the specified set.  This
  442.      * operation effectively modifies this set so that its value is
  443.      * the <i>intersection</i> of the two sets.
  444.      *
  445.      * @param c set that defines which elements this set will retain.
  446.      */
  447.     virtual void retainAll(const UnicodeSet& c);
  448.  
  449.     /**
  450.      * Removes from this set all of its elements that are contained in the
  451.      * specified set.  This operation effectively modifies this
  452.      * set so that its value is the <i>asymmetric set difference</i> of
  453.      * the two sets.
  454.      *
  455.      * @param c set that defines which elements will be removed from
  456.      *          this set.
  457.      */
  458.     virtual void removeAll(const UnicodeSet& c);
  459.  
  460.     /**
  461.      * Inverts this set.  This operation modifies this set so that
  462.      * its value is its complement.  This is equivalent to the pseudo code:
  463.      * <code>this = new CharSet("[\u0000-\uFFFF]").removeAll(this)</code>.
  464.      */
  465.     virtual void complement();
  466.  
  467.     /**
  468.      * Removes all of the elements from this set.  This set will be
  469.      * empty after this call returns.
  470.      */
  471.     virtual void clear();
  472.  
  473.     //----------------------------------------------------------------
  474.     // Implementation: Pattern parsing
  475.     //----------------------------------------------------------------
  476.  
  477. private:
  478.  
  479.     /**
  480.      * Parses the given pattern, starting at the given position.  The
  481.      * character at pattern.charAt(pos.getIndex()) must be '[', or the
  482.      * parse fails.  Parsing continues until the corresponding closing
  483.      * ']'.  If a syntax error is encountered between the opening and
  484.      * closing brace, the parse fails.  Upon return from a successful
  485.      * parse, the ParsePosition is updated to point to the character
  486.      * following the closing ']', and a StringBuffer containing a
  487.      * pairs list for the parsed pattern is returned.  This method calls
  488.      * itself recursively to parse embedded subpatterns.
  489.      *
  490.      * @param pattern the string containing the pattern to be parsed.
  491.      * The portion of the string from pos.getIndex(), which must be a
  492.      * '[', to the corresponding closing ']', is parsed.
  493.      * @param pos upon entry, the position at which to being parsing.
  494.      * The character at pattern.charAt(pos.getIndex()) must be a '['.
  495.      * Upon return from a successful parse, pos.getIndex() is either
  496.      * the character after the closing ']' of the parsed pattern, or
  497.      * pattern.length() if the closing ']' is the last character of
  498.      * the pattern string.
  499.      * @return a StringBuffer containing a pairs list for the parsed
  500.      * substring of <code>pattern</code>
  501.      * @exception IllegalArgumentException if the parse fails.
  502.      */
  503.     static UnicodeString& parse(UnicodeString& pairsBuf /*result*/,
  504.                                 const UnicodeString& pattern,
  505.                                 ParsePosition& pos,
  506.                                 UErrorCode& status);
  507.  
  508.     //----------------------------------------------------------------
  509.     // Implementation: Efficient in-place union & difference
  510.     //----------------------------------------------------------------
  511.  
  512.     /**
  513.      * Performs a union operation: adds the range 'c'-'d' to the given
  514.      * pairs list.  The pairs list is modified in place.  The result
  515.      * is normalized (in order and as short as possible).  For
  516.      * example, addPair("am", 'l', 'q') => "aq".  addPair("ampz", 'n',
  517.      * 'o') => "az".
  518.      */
  519.     static void addPair(UnicodeString& pairs, UChar c, UChar d);
  520.  
  521.     /**
  522.      * Performs an asymmetric difference: removes the range 'c'-'d'
  523.      * from the pairs list.  The pairs list is modified in place.  The
  524.      * result is normalized (in order and as short as possible).  For
  525.      * example, removePair("am", 'l', 'q') => "ak".
  526.      * removePair("ampz", 'l', 'q') => "akrz".
  527.      */
  528.     static void removePair(UnicodeString& pairs, UChar c, UChar d);
  529.  
  530.     //----------------------------------------------------------------
  531.     // Implementation: Fundamental operators
  532.     //----------------------------------------------------------------
  533.  
  534.     /**
  535.      * Changes the pairs list to represent the complement of the set it
  536.      * currently represents.  The pairs list will be normalized (in
  537.      * order and in shortest possible form) if the original pairs list
  538.      * was normalized.
  539.      */
  540.     static void doComplement(UnicodeString& pairs);
  541.  
  542.     /**
  543.      * Given two pairs lists, changes the first in place to represent
  544.      * the union of the two sets.
  545.      */
  546.     static void doUnion(UnicodeString& pairs, const UnicodeString& c2);
  547.  
  548.     /**
  549.      * Given two pairs lists, changes the first in place to represent
  550.      * the asymmetric difference of the two sets.
  551.      */
  552.     static void doDifference(UnicodeString& pairs, const UnicodeString& pairs2);
  553.  
  554.     /**
  555.      * Given two pairs lists, changes the first in place to represent
  556.      * the intersection of the two sets.
  557.      */
  558.     static void doIntersection(UnicodeString& pairs, const UnicodeString& c2);
  559.  
  560.     //----------------------------------------------------------------
  561.     // Implementation: Generation of pairs for Unicode categories
  562.     //----------------------------------------------------------------
  563.  
  564.     /**
  565.      * Returns a pairs string for the given category, given its name.
  566.      * The category name must be either a two-letter name, such as
  567.      * "Lu", or a one letter name, such as "L".  One-letter names
  568.      * indicate the logical union of all two-letter names that start
  569.      * with that letter.  Case is significant.  If the name starts
  570.      * with the character '^' then the complement of the given
  571.      * character set is returned.
  572.      *
  573.      * Although individual categories such as "Lu" are cached, we do
  574.      * not currently cache single-letter categories such as "L" or
  575.      * complements such as "^Lu" or "^L".  It would be easy to cache
  576.      * these as well in a hashtable should the need arise.
  577.      */
  578.     static UnicodeString& getCategoryPairs(UnicodeString& result,
  579.                                            const UnicodeString& catName,
  580.                                            UErrorCode& status);
  581.  
  582.     /**
  583.      * Returns a pairs string for the given category.  This string is
  584.      * cached and returned again if this method is called again with
  585.      * the same parameter.
  586.      */
  587.     static const UnicodeString& getCategoryPairs(int8_t cat);
  588.  
  589.     //----------------------------------------------------------------
  590.     // Implementation: Utility methods
  591.     //----------------------------------------------------------------
  592.  
  593.     /**
  594.      * Returns the character after the given position, or '\uFFFF' if
  595.      * there is none.
  596.      */
  597.     static UChar charAfter(const UnicodeString& str, int32_t i);
  598.  
  599.     /**
  600.      * TEMPORARY WORKAROUND UNTIL Unicode::digit() exists.
  601.      * Return the digit value of the given UChar, or -1.  The radix
  602.      * value is ignored for now and hardcoded as 16.
  603.      */
  604.     static int8_t digit(UChar c, int8_t radix);
  605. };
  606.  
  607. inline void UnicodeSet::applyPattern(const UnicodeString& pattern,
  608.                                      UErrorCode& status) {
  609.     applyPattern(pattern, FALSE, status);
  610. }
  611.  
  612. inline bool_t UnicodeSet::operator!=(const UnicodeSet& o) const {
  613.     return !operator==(o);
  614. }
  615.  
  616. #endif
  617.