1999-12-28 23:57:50 +00:00
|
|
|
/*
|
2005-03-08 22:49:59 +00:00
|
|
|
***************************************************************************
|
2009-03-12 00:38:53 +00:00
|
|
|
* Copyright (C) 1999-2009, International Business Machines Corporation
|
2005-03-08 22:49:59 +00:00
|
|
|
* and others. All Rights Reserved.
|
|
|
|
***************************************************************************
|
1999-12-28 23:57:50 +00:00
|
|
|
* Date Name Description
|
|
|
|
* 10/20/99 alan Creation.
|
2005-03-08 22:49:59 +00:00
|
|
|
***************************************************************************
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef UNICODESET_H
|
|
|
|
#define UNICODESET_H
|
|
|
|
|
2000-01-18 20:00:56 +00:00
|
|
|
#include "unicode/unifilt.h"
|
1999-12-28 23:57:50 +00:00
|
|
|
#include "unicode/unistr.h"
|
2003-04-07 16:38:45 +00:00
|
|
|
#include "unicode/uset.h"
|
1999-12-28 23:57:50 +00:00
|
|
|
|
2005-06-22 22:39:36 +00:00
|
|
|
/**
|
2007-12-11 21:30:10 +00:00
|
|
|
* \file
|
2005-06-22 22:39:36 +00:00
|
|
|
* \brief C++ API: Unicode Set
|
|
|
|
*/
|
2007-12-11 21:30:10 +00:00
|
|
|
|
2001-10-08 23:26:58 +00:00
|
|
|
U_NAMESPACE_BEGIN
|
|
|
|
|
2007-07-19 04:33:20 +00:00
|
|
|
class BMPSet;
|
1999-12-28 23:57:50 +00:00
|
|
|
class ParsePosition;
|
2000-02-08 02:49:15 +00:00
|
|
|
class SymbolTable;
|
2007-07-19 04:33:20 +00:00
|
|
|
class UnicodeSetStringSpan;
|
2002-04-25 23:39:57 +00:00
|
|
|
class UVector;
|
2003-09-29 23:00:39 +00:00
|
|
|
class RuleCharacterIterator;
|
2004-08-24 17:21:14 +00:00
|
|
|
|
1999-12-28 23:57:50 +00:00
|
|
|
/**
|
2002-04-25 23:39:57 +00:00
|
|
|
* A mutable set of Unicode characters and multicharacter strings. Objects of this class
|
1999-12-28 23:57:50 +00:00
|
|
|
* represent <em>character classes</em> used in regular expressions.
|
2001-11-22 00:05:50 +00:00
|
|
|
* A character specifies a subset of Unicode code points. Legal
|
|
|
|
* code points are U+0000 to U+10FFFF, inclusive.
|
1999-12-28 23:57:50 +00:00
|
|
|
*
|
2002-11-15 01:58:29 +00:00
|
|
|
* <p>The UnicodeSet class is not designed to be subclassed.
|
2002-11-07 02:38:51 +00:00
|
|
|
*
|
2001-11-22 00:05:50 +00:00
|
|
|
* <p><code>UnicodeSet</code> supports two APIs. The first is the
|
|
|
|
* <em>operand</em> API that allows the caller to modify the value of
|
|
|
|
* a <code>UnicodeSet</code> object. It conforms to Java 2's
|
|
|
|
* <code>java.util.Set</code> interface, although
|
|
|
|
* <code>UnicodeSet</code> does not actually implement that
|
|
|
|
* interface. All methods of <code>Set</code> are supported, with the
|
|
|
|
* modification that they take a character range or single character
|
|
|
|
* instead of an <code>Object</code>, and they take a
|
|
|
|
* <code>UnicodeSet</code> instead of a <code>Collection</code>. The
|
|
|
|
* operand API may be thought of in terms of boolean logic: a boolean
|
|
|
|
* OR is implemented by <code>add</code>, a boolean AND is implemented
|
|
|
|
* by <code>retain</code>, a boolean XOR is implemented by
|
|
|
|
* <code>complement</code> taking an argument, and a boolean NOT is
|
|
|
|
* implemented by <code>complement</code> with no argument. In terms
|
|
|
|
* of traditional set theory function names, <code>add</code> is a
|
|
|
|
* union, <code>retain</code> is an intersection, <code>remove</code>
|
|
|
|
* is an asymmetric difference, and <code>complement</code> with no
|
|
|
|
* argument is a set complement with respect to the superset range
|
|
|
|
* <code>MIN_VALUE-MAX_VALUE</code>
|
1999-12-28 23:57:50 +00:00
|
|
|
*
|
|
|
|
* <p>The second API is the
|
|
|
|
* <code>applyPattern()</code>/<code>toPattern()</code> API from the
|
2001-11-22 00:05:50 +00:00
|
|
|
* <code>java.text.Format</code>-derived classes. Unlike the
|
1999-12-28 23:57:50 +00:00
|
|
|
* methods that add characters, add categories, and control the logic
|
|
|
|
* of the set, the method <code>applyPattern()</code> sets all
|
|
|
|
* attributes of a <code>UnicodeSet</code> at once, based on a
|
|
|
|
* string pattern.
|
|
|
|
*
|
|
|
|
* <p><b>Pattern syntax</b></p>
|
|
|
|
*
|
|
|
|
* Patterns are accepted by the constructors and the
|
|
|
|
* <code>applyPattern()</code> methods and returned by the
|
|
|
|
* <code>toPattern()</code> method. These patterns follow a syntax
|
|
|
|
* similar to that employed by version 8 regular expression character
|
2002-11-15 01:58:29 +00:00
|
|
|
* classes. Here are some simple examples:
|
|
|
|
*
|
2004-06-15 22:32:41 +00:00
|
|
|
* \htmlonly<blockquote>\endhtmlonly
|
2002-11-15 01:58:29 +00:00
|
|
|
* <table>
|
|
|
|
* <tr align="top">
|
|
|
|
* <td nowrap valign="top" align="left"><code>[]</code></td>
|
|
|
|
* <td valign="top">No characters</td>
|
|
|
|
* </tr><tr align="top">
|
|
|
|
* <td nowrap valign="top" align="left"><code>[a]</code></td>
|
|
|
|
* <td valign="top">The character 'a'</td>
|
|
|
|
* </tr><tr align="top">
|
|
|
|
* <td nowrap valign="top" align="left"><code>[ae]</code></td>
|
|
|
|
* <td valign="top">The characters 'a' and 'e'</td>
|
|
|
|
* </tr>
|
|
|
|
* <tr>
|
|
|
|
* <td nowrap valign="top" align="left"><code>[a-e]</code></td>
|
2004-08-24 17:21:14 +00:00
|
|
|
* <td valign="top">The characters 'a' through 'e' inclusive, in Unicode code
|
2002-11-15 01:58:29 +00:00
|
|
|
* point order</td>
|
|
|
|
* </tr>
|
|
|
|
* <tr>
|
2004-06-15 20:52:22 +00:00
|
|
|
* <td nowrap valign="top" align="left"><code>[\\u4E01]</code></td>
|
2002-11-15 01:58:29 +00:00
|
|
|
* <td valign="top">The character U+4E01</td>
|
|
|
|
* </tr>
|
|
|
|
* <tr>
|
|
|
|
* <td nowrap valign="top" align="left"><code>[a{ab}{ac}]</code></td>
|
2004-08-24 17:21:14 +00:00
|
|
|
* <td valign="top">The character 'a' and the multicharacter strings "ab" and
|
2002-11-15 01:58:29 +00:00
|
|
|
* "ac"</td>
|
|
|
|
* </tr>
|
|
|
|
* <tr>
|
2004-06-15 20:52:22 +00:00
|
|
|
* <td nowrap valign="top" align="left"><code>[\\p{Lu}]</code></td>
|
2002-11-15 01:58:29 +00:00
|
|
|
* <td valign="top">All characters in the general category Uppercase Letter</td>
|
|
|
|
* </tr>
|
|
|
|
* </table>
|
2004-06-15 22:32:41 +00:00
|
|
|
* \htmlonly</blockquote>\endhtmlonly
|
2004-08-24 17:21:14 +00:00
|
|
|
*
|
2002-11-15 01:58:29 +00:00
|
|
|
* Any character may be preceded by a backslash in order to remove any special
|
|
|
|
* meaning. White space characters, as defined by UCharacter.isWhitespace(), are
|
|
|
|
* ignored, unless they are escaped.
|
|
|
|
*
|
|
|
|
* <p>Property patterns specify a set of characters having a certain
|
|
|
|
* property as defined by the Unicode standard. Both the POSIX-like
|
2004-06-15 20:52:22 +00:00
|
|
|
* "[:Lu:]" and the Perl-like syntax "\\p{Lu}" are recognized. For a
|
2002-11-15 01:58:29 +00:00
|
|
|
* complete list of supported property patterns, see the User's Guide
|
|
|
|
* for UnicodeSet at
|
2007-06-11 19:14:47 +00:00
|
|
|
* <a href="http://icu-project.org/userguide/unicodeSet.html">
|
|
|
|
* http://icu-project.org/userguide/unicodeSet.html</a>.
|
2002-11-15 01:58:29 +00:00
|
|
|
* Actual determination of property data is defined by the underlying
|
|
|
|
* Unicode database as implemented by UCharacter.
|
|
|
|
*
|
|
|
|
* <p>Patterns specify individual characters, ranges of characters, and
|
|
|
|
* Unicode property sets. When elements are concatenated, they
|
|
|
|
* specify their union. To complement a set, place a '^' immediately
|
|
|
|
* after the opening '['. Property patterns are inverted by modifying
|
2004-06-15 20:52:22 +00:00
|
|
|
* their delimiters; "[:^foo]" and "\\P{foo}". In any other location,
|
2002-11-15 01:58:29 +00:00
|
|
|
* '^' has no special meaning.
|
|
|
|
*
|
|
|
|
* <p>Ranges are indicated by placing two a '-' between two
|
|
|
|
* characters, as in "a-z". This specifies the range of all
|
|
|
|
* characters from the left to the right, in Unicode order. If the
|
|
|
|
* left character is greater than or equal to the
|
|
|
|
* right character it is a syntax error. If a '-' occurs as the first
|
|
|
|
* character after the opening '[' or '[^', or if it occurs as the
|
|
|
|
* last character before the closing ']', then it is taken as a
|
2004-04-30 22:23:11 +00:00
|
|
|
* literal. Thus "[a\-b]", "[-ab]", and "[ab-]" all indicate the same
|
2002-11-15 01:58:29 +00:00
|
|
|
* set of three characters, 'a', 'b', and '-'.
|
|
|
|
*
|
|
|
|
* <p>Sets may be intersected using the '&' operator or the asymmetric
|
|
|
|
* set difference may be taken using the '-' operator, for example,
|
2004-06-15 20:52:22 +00:00
|
|
|
* "[[:L:]&[\\u0000-\\u0FFF]]" indicates the set of all Unicode letters
|
2002-11-15 01:58:29 +00:00
|
|
|
* with values less than 4096. Operators ('&' and '|') have equal
|
|
|
|
* precedence and bind left-to-right. Thus
|
2004-06-15 20:52:22 +00:00
|
|
|
* "[[:L:]-[a-z]-[\\u0100-\\u01FF]]" is equivalent to
|
|
|
|
* "[[[:L:]-[a-z]]-[\\u0100-\\u01FF]]". This only really matters for
|
2002-11-15 01:58:29 +00:00
|
|
|
* difference; intersection is commutative.
|
|
|
|
*
|
|
|
|
* <table>
|
|
|
|
* <tr valign=top><td nowrap><code>[a]</code><td>The set containing 'a'
|
|
|
|
* <tr valign=top><td nowrap><code>[a-z]</code><td>The set containing 'a'
|
|
|
|
* through 'z' and all letters in between, in Unicode order
|
|
|
|
* <tr valign=top><td nowrap><code>[^a-z]</code><td>The set containing
|
|
|
|
* all characters but 'a' through 'z',
|
|
|
|
* that is, U+0000 through 'a'-1 and 'z'+1 through U+10FFFF
|
|
|
|
* <tr valign=top><td nowrap><code>[[<em>pat1</em>][<em>pat2</em>]]</code>
|
|
|
|
* <td>The union of sets specified by <em>pat1</em> and <em>pat2</em>
|
|
|
|
* <tr valign=top><td nowrap><code>[[<em>pat1</em>]&[<em>pat2</em>]]</code>
|
|
|
|
* <td>The intersection of sets specified by <em>pat1</em> and <em>pat2</em>
|
|
|
|
* <tr valign=top><td nowrap><code>[[<em>pat1</em>]-[<em>pat2</em>]]</code>
|
|
|
|
* <td>The asymmetric difference of sets specified by <em>pat1</em> and
|
|
|
|
* <em>pat2</em>
|
2004-06-15 20:52:22 +00:00
|
|
|
* <tr valign=top><td nowrap><code>[:Lu:] or \\p{Lu}</code>
|
2002-11-15 01:58:29 +00:00
|
|
|
* <td>The set of characters having the specified
|
|
|
|
* Unicode property; in
|
|
|
|
* this case, Unicode uppercase letters
|
2004-06-15 20:52:22 +00:00
|
|
|
* <tr valign=top><td nowrap><code>[:^Lu:] or \\P{Lu}</code>
|
2002-11-15 01:58:29 +00:00
|
|
|
* <td>The set of characters <em>not</em> having the given
|
|
|
|
* Unicode property
|
|
|
|
* </table>
|
|
|
|
*
|
|
|
|
* <p><b>Warning</b>: you cannot add an empty string ("") to a UnicodeSet.</p>
|
|
|
|
*
|
|
|
|
* <p><b>Formal syntax</b></p>
|
1999-12-28 23:57:50 +00:00
|
|
|
*
|
2004-06-15 22:32:41 +00:00
|
|
|
* \htmlonly<blockquote>\endhtmlonly
|
2000-01-13 07:28:31 +00:00
|
|
|
* <table>
|
|
|
|
* <tr align="top">
|
|
|
|
* <td nowrap valign="top" align="right"><code>pattern := </code></td>
|
|
|
|
* <td valign="top"><code>('[' '^'? item* ']') |
|
2001-11-22 00:05:50 +00:00
|
|
|
* property</code></td>
|
2000-01-13 07:28:31 +00:00
|
|
|
* </tr>
|
|
|
|
* <tr align="top">
|
|
|
|
* <td nowrap valign="top" align="right"><code>item := </code></td>
|
|
|
|
* <td valign="top"><code>char | (char '-' char) | pattern-expr<br>
|
|
|
|
* </code></td>
|
|
|
|
* </tr>
|
|
|
|
* <tr align="top">
|
|
|
|
* <td nowrap valign="top" align="right"><code>pattern-expr := </code></td>
|
|
|
|
* <td valign="top"><code>pattern | pattern-expr pattern |
|
|
|
|
* pattern-expr op pattern<br>
|
|
|
|
* </code></td>
|
|
|
|
* </tr>
|
|
|
|
* <tr align="top">
|
|
|
|
* <td nowrap valign="top" align="right"><code>op := </code></td>
|
|
|
|
* <td valign="top"><code>'&' | '-'<br>
|
|
|
|
* </code></td>
|
|
|
|
* </tr>
|
|
|
|
* <tr align="top">
|
|
|
|
* <td nowrap valign="top" align="right"><code>special := </code></td>
|
|
|
|
* <td valign="top"><code>'[' | ']' | '-'<br>
|
|
|
|
* </code></td>
|
|
|
|
* </tr>
|
|
|
|
* <tr align="top">
|
|
|
|
* <td nowrap valign="top" align="right"><code>char := </code></td>
|
|
|
|
* <td valign="top"><em>any character that is not</em><code> special<br>
|
2002-11-15 01:58:29 +00:00
|
|
|
* | ('\' </code><em>any character</em><code>)<br>
|
2004-06-15 20:52:22 +00:00
|
|
|
* | ('\\u' hex hex hex hex)<br>
|
2000-01-13 07:28:31 +00:00
|
|
|
* </code></td>
|
|
|
|
* </tr>
|
|
|
|
* <tr align="top">
|
|
|
|
* <td nowrap valign="top" align="right"><code>hex := </code></td>
|
|
|
|
* <td valign="top"><em>any character for which
|
2001-11-22 00:05:50 +00:00
|
|
|
* </em><code>Character.digit(c, 16)</code><em>
|
2000-01-13 07:28:31 +00:00
|
|
|
* returns a non-negative result</em></td>
|
|
|
|
* </tr>
|
|
|
|
* <tr>
|
2001-11-22 00:05:50 +00:00
|
|
|
* <td nowrap valign="top" align="right"><code>property := </code></td>
|
2003-02-03 22:20:00 +00:00
|
|
|
* <td valign="top"><em>a Unicode property set pattern</em></td>
|
2000-01-13 07:28:31 +00:00
|
|
|
* </tr>
|
|
|
|
* </table>
|
|
|
|
* <br>
|
|
|
|
* <table border="1">
|
|
|
|
* <tr>
|
|
|
|
* <td>Legend: <table>
|
|
|
|
* <tr>
|
|
|
|
* <td nowrap valign="top"><code>a := b</code></td>
|
|
|
|
* <td width="20" valign="top"> </td>
|
|
|
|
* <td valign="top"><code>a</code> may be replaced by <code>b</code> </td>
|
|
|
|
* </tr>
|
|
|
|
* <tr>
|
|
|
|
* <td nowrap valign="top"><code>a?</code></td>
|
|
|
|
* <td valign="top"></td>
|
|
|
|
* <td valign="top">zero or one instance of <code>a</code><br>
|
|
|
|
* </td>
|
|
|
|
* </tr>
|
|
|
|
* <tr>
|
|
|
|
* <td nowrap valign="top"><code>a*</code></td>
|
|
|
|
* <td valign="top"></td>
|
|
|
|
* <td valign="top">one or more instances of <code>a</code><br>
|
|
|
|
* </td>
|
|
|
|
* </tr>
|
|
|
|
* <tr>
|
|
|
|
* <td nowrap valign="top"><code>a | b</code></td>
|
|
|
|
* <td valign="top"></td>
|
|
|
|
* <td valign="top">either <code>a</code> or <code>b</code><br>
|
|
|
|
* </td>
|
|
|
|
* </tr>
|
|
|
|
* <tr>
|
|
|
|
* <td nowrap valign="top"><code>'a'</code></td>
|
|
|
|
* <td valign="top"></td>
|
|
|
|
* <td valign="top">the literal string between the quotes </td>
|
|
|
|
* </tr>
|
|
|
|
* </table>
|
|
|
|
* </td>
|
|
|
|
* </tr>
|
|
|
|
* </table>
|
2004-06-15 22:32:41 +00:00
|
|
|
* \htmlonly</blockquote>\endhtmlonly
|
2008-01-22 17:46:22 +00:00
|
|
|
*
|
|
|
|
* <p>Note:
|
|
|
|
* - Most UnicodeSet methods do not take a UErrorCode parameter because
|
|
|
|
* there are usually very few opportunities for failure other than a shortage
|
|
|
|
* of memory, error codes in low-level C++ string methods would be inconvenient,
|
|
|
|
* and the error code as the last parameter (ICU convention) would prevent
|
|
|
|
* the use of default parameter values.
|
|
|
|
* Instead, such methods set the UnicodeSet into a "bogus" state
|
|
|
|
* (see isBogus()) if an error occurs.
|
1999-12-28 23:57:50 +00:00
|
|
|
*
|
|
|
|
* @author Alan Liu
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
2002-05-29 18:36:09 +00:00
|
|
|
class U_COMMON_API UnicodeSet : public UnicodeFilter {
|
1999-12-28 23:57:50 +00:00
|
|
|
|
2000-05-25 19:27:14 +00:00
|
|
|
int32_t len; // length of list used; 0 <= len <= capacity
|
|
|
|
int32_t capacity; // capacity of list
|
|
|
|
UChar32* list; // MUST be terminated with HIGH
|
2007-07-19 04:33:20 +00:00
|
|
|
BMPSet *bmpSet; // The set is frozen iff either bmpSet or stringSpan is not NULL.
|
2000-05-25 19:27:14 +00:00
|
|
|
UChar32* buffer; // internal buffer, may be NULL
|
2006-10-03 17:41:23 +00:00
|
|
|
int32_t bufferCapacity; // capacity of buffer
|
|
|
|
int32_t patLen;
|
2002-04-25 23:39:57 +00:00
|
|
|
|
2001-06-12 17:34:16 +00:00
|
|
|
/**
|
|
|
|
* The pattern representation of this set. This may not be the
|
|
|
|
* most economical pattern. It is the pattern supplied to
|
|
|
|
* applyPattern(), with variables substituted and whitespace
|
|
|
|
* removed. For sets constructed without applyPattern(), or
|
|
|
|
* modified using the non-pattern API, this string will be empty,
|
|
|
|
* indicating that toPattern() must generate a pattern
|
|
|
|
* representation from the inversion list.
|
|
|
|
*/
|
2006-10-03 17:41:23 +00:00
|
|
|
UChar *pat;
|
|
|
|
UVector* strings; // maintained in sorted order
|
2007-07-19 04:33:20 +00:00
|
|
|
UnicodeSetStringSpan *stringSpan;
|
2001-06-12 17:34:16 +00:00
|
|
|
|
2008-01-22 17:46:22 +00:00
|
|
|
private:
|
|
|
|
enum { // constants
|
|
|
|
kIsBogus = 1 // This set is bogus (i.e. not valid)
|
|
|
|
};
|
|
|
|
uint8_t fFlags; // Bit flag (see constants above)
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Determine if this object contains a valid set.
|
|
|
|
* A bogus set has no value. It is different from an empty set.
|
|
|
|
* It can be used to indicate that no set value is available.
|
|
|
|
*
|
|
|
|
* @return TRUE if the set is valid, FALSE otherwise
|
|
|
|
* @see setToBogus()
|
2009-03-19 04:03:31 +00:00
|
|
|
* @stable ICU 4.0
|
2008-01-22 17:46:22 +00:00
|
|
|
*/
|
|
|
|
inline UBool isBogus(void) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Make this UnicodeSet object invalid.
|
|
|
|
* The string will test TRUE with isBogus().
|
|
|
|
*
|
|
|
|
* A bogus set has no value. It is different from an empty set.
|
|
|
|
* It can be used to indicate that no set value is available.
|
|
|
|
*
|
|
|
|
* This utility function is used throughout the UnicodeSet
|
|
|
|
* implementation to indicate that a UnicodeSet operation failed,
|
|
|
|
* and may be used in other functions,
|
|
|
|
* especially but not exclusively when such functions do not
|
|
|
|
* take a UErrorCode for simplicity.
|
|
|
|
*
|
|
|
|
* @see isBogus()
|
2009-03-19 04:03:31 +00:00
|
|
|
* @stable ICU 4.0
|
2008-01-22 17:46:22 +00:00
|
|
|
*/
|
|
|
|
void setToBogus();
|
|
|
|
|
1999-12-28 23:57:50 +00:00
|
|
|
public:
|
|
|
|
|
2005-03-08 23:05:38 +00:00
|
|
|
enum {
|
|
|
|
/**
|
|
|
|
* Minimum value that can be stored in a UnicodeSet.
|
|
|
|
* @stable ICU 2.4
|
|
|
|
*/
|
|
|
|
MIN_VALUE = 0,
|
2000-05-25 19:27:14 +00:00
|
|
|
|
2005-03-08 23:05:38 +00:00
|
|
|
/**
|
|
|
|
* Maximum value that can be stored in a UnicodeSet.
|
|
|
|
* @stable ICU 2.4
|
|
|
|
*/
|
|
|
|
MAX_VALUE = 0x10ffff
|
|
|
|
};
|
1999-12-28 23:57:50 +00:00
|
|
|
|
|
|
|
//----------------------------------------------------------------
|
|
|
|
// Constructors &c
|
|
|
|
//----------------------------------------------------------------
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructs an empty set.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
|
|
|
UnicodeSet();
|
|
|
|
|
2000-05-25 19:27:14 +00:00
|
|
|
/**
|
|
|
|
* Constructs a set containing the given range. If <code>end >
|
|
|
|
* start</code> then an empty set is created.
|
|
|
|
*
|
|
|
|
* @param start first character, inclusive, of range
|
|
|
|
* @param end last character, inclusive, of range
|
2004-03-26 19:42:04 +00:00
|
|
|
* @stable ICU 2.4
|
2000-05-25 19:27:14 +00:00
|
|
|
*/
|
|
|
|
UnicodeSet(UChar32 start, UChar32 end);
|
|
|
|
|
1999-12-28 23:57:50 +00:00
|
|
|
/**
|
|
|
|
* 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
|
2003-06-11 00:04:00 +00:00
|
|
|
* @param status returns <code>U_ILLEGAL_ARGUMENT_ERROR</code> if the pattern
|
1999-12-28 23:57:50 +00:00
|
|
|
* contains a syntax error.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
|
|
|
UnicodeSet(const UnicodeString& pattern,
|
|
|
|
UErrorCode& status);
|
|
|
|
|
2003-02-14 21:22:20 +00:00
|
|
|
/**
|
|
|
|
* 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 options bitmask for options to apply to the pattern.
|
|
|
|
* Valid options are USET_IGNORE_SPACE and USET_CASE_INSENSITIVE.
|
2003-11-24 19:59:15 +00:00
|
|
|
* @param symbols a symbol table mapping variable names to values
|
|
|
|
* and stand-in characters to UnicodeSets; may be NULL
|
2003-06-11 00:04:00 +00:00
|
|
|
* @param status returns <code>U_ILLEGAL_ARGUMENT_ERROR</code> if the pattern
|
2003-04-26 00:22:06 +00:00
|
|
|
* contains a syntax error.
|
2003-02-14 21:22:20 +00:00
|
|
|
* @internal
|
|
|
|
*/
|
|
|
|
UnicodeSet(const UnicodeString& pattern,
|
|
|
|
uint32_t options,
|
2003-10-14 21:47:59 +00:00
|
|
|
const SymbolTable* symbols,
|
|
|
|
UErrorCode& status);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
2005-06-22 23:38:06 +00:00
|
|
|
* @stable ICU 2.8
|
2003-10-14 21:47:59 +00:00
|
|
|
*/
|
|
|
|
UnicodeSet(const UnicodeString& pattern, ParsePosition& pos,
|
|
|
|
uint32_t options,
|
|
|
|
const SymbolTable* symbols,
|
2003-02-14 21:22:20 +00:00
|
|
|
UErrorCode& status);
|
|
|
|
|
1999-12-28 23:57:50 +00:00
|
|
|
/**
|
|
|
|
* Constructs a set that is identical to the given UnicodeSet.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
|
|
|
UnicodeSet(const UnicodeSet& o);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Destructs the set.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
|
|
|
virtual ~UnicodeSet();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Assigns this object to be a copy of another.
|
2007-07-19 04:33:20 +00:00
|
|
|
* A frozen set will not be modified.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
|
|
|
UnicodeSet& operator=(const UnicodeSet& o);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Compares the specified object with this set for equality. Returns
|
|
|
|
* <tt>true</tt> if the two sets
|
|
|
|
* have the same size, and every member of the specified set is
|
|
|
|
* contained in this set (or equivalently, every member of this set is
|
|
|
|
* contained in the specified set).
|
|
|
|
*
|
|
|
|
* @param o set to be compared for equality with this set.
|
|
|
|
* @return <tt>true</tt> if the specified set is equal to this set.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
2000-05-18 22:08:39 +00:00
|
|
|
virtual UBool operator==(const UnicodeSet& o) const;
|
1999-12-28 23:57:50 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Compares the specified object with this set for equality. Returns
|
|
|
|
* <tt>true</tt> if the specified set is not equal to this set.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
2000-05-18 22:08:39 +00:00
|
|
|
UBool operator!=(const UnicodeSet& o) const;
|
1999-12-28 23:57:50 +00:00
|
|
|
|
2000-01-18 20:00:56 +00:00
|
|
|
/**
|
2002-02-07 01:07:55 +00:00
|
|
|
* Returns a copy of this object. All UnicodeFunctor objects have
|
2000-01-18 20:00:56 +00:00
|
|
|
* to support cloning in order to allow classes using
|
2002-02-07 01:07:55 +00:00
|
|
|
* UnicodeFunctors, such as Transliterator, to implement cloning.
|
2007-07-19 04:33:20 +00:00
|
|
|
* If this set is frozen, then the clone will be frozen as well.
|
|
|
|
* Use cloneAsThawed() for a mutable clone of a frozen set.
|
|
|
|
* @see cloneAsThawed
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2000-01-18 20:00:56 +00:00
|
|
|
*/
|
2002-02-07 01:07:55 +00:00
|
|
|
virtual UnicodeFunctor* clone() const;
|
2000-01-18 20:00:56 +00:00
|
|
|
|
1999-12-28 23:57:50 +00:00
|
|
|
/**
|
|
|
|
* Returns the hash code value for this set.
|
|
|
|
*
|
|
|
|
* @return the hash code value for this set.
|
|
|
|
* @see Object#hashCode()
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
|
|
|
virtual int32_t hashCode(void) const;
|
|
|
|
|
2009-03-12 00:38:53 +00:00
|
|
|
/**
|
|
|
|
* Get a UnicodeSet pointer from a USet
|
|
|
|
*
|
|
|
|
* @param uset a USet (the ICU plain C type for UnicodeSet)
|
|
|
|
* @return the corresponding UnicodeSet pointer.
|
|
|
|
*
|
|
|
|
* @draft ICU 4.2
|
|
|
|
*/
|
|
|
|
inline static UnicodeSet *fromUSet(USet *uset);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get a UnicodeSet pointer from a const USet
|
|
|
|
*
|
|
|
|
* @param uset a const USet (the ICU plain C type for UnicodeSet)
|
|
|
|
* @return the corresponding UnicodeSet pointer.
|
|
|
|
*
|
|
|
|
* @draft ICU 4.2
|
|
|
|
*/
|
|
|
|
inline static const UnicodeSet *fromUSet(const USet *uset);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Produce a USet * pointer for this UnicodeSet.
|
|
|
|
* USet is the plain C type for UnicodeSet
|
|
|
|
*
|
|
|
|
* @return a USet pointer for this UnicodeSet
|
2009-03-12 16:36:34 +00:00
|
|
|
* @draft ICU 4.2
|
2009-03-12 00:38:53 +00:00
|
|
|
*/
|
|
|
|
inline USet *toUSet();
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Produce a const USet * pointer for this UnicodeSet.
|
|
|
|
* USet is the plain C type for UnicodeSet
|
|
|
|
*
|
|
|
|
* @return a const USet pointer for this UnicodeSet
|
2009-03-12 16:36:34 +00:00
|
|
|
* @draft ICU 4.2
|
2009-03-12 00:38:53 +00:00
|
|
|
*/
|
|
|
|
inline const USet * toUSet() const;
|
|
|
|
|
|
|
|
|
2007-07-19 04:33:20 +00:00
|
|
|
//----------------------------------------------------------------
|
|
|
|
// Freezable API
|
|
|
|
//----------------------------------------------------------------
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Determines whether the set has been frozen (made immutable) or not.
|
|
|
|
* See the ICU4J Freezable interface for details.
|
|
|
|
* @return TRUE/FALSE for whether the set has been frozen
|
|
|
|
* @see freeze
|
|
|
|
* @see cloneAsThawed
|
2008-07-21 18:57:26 +00:00
|
|
|
* @stable ICU 3.8
|
2007-07-19 04:33:20 +00:00
|
|
|
*/
|
|
|
|
inline UBool isFrozen() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Freeze the set (make it immutable).
|
|
|
|
* Once frozen, it cannot be unfrozen and is therefore thread-safe
|
|
|
|
* until it is deleted.
|
|
|
|
* See the ICU4J Freezable interface for details.
|
|
|
|
* Freezing the set may also make some operations faster, for example
|
|
|
|
* contains() and span().
|
|
|
|
* A frozen set will not be modified. (It remains frozen.)
|
|
|
|
* @return this set.
|
|
|
|
* @see isFrozen
|
|
|
|
* @see cloneAsThawed
|
2008-07-21 18:57:26 +00:00
|
|
|
* @stable ICU 3.8
|
2007-07-19 04:33:20 +00:00
|
|
|
*/
|
|
|
|
UnicodeFunctor *freeze();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Clone the set and make the clone mutable.
|
|
|
|
* See the ICU4J Freezable interface for details.
|
|
|
|
* @return the mutable clone
|
|
|
|
* @see freeze
|
|
|
|
* @see isFrozen
|
2008-07-21 18:57:26 +00:00
|
|
|
* @stable ICU 3.8
|
2007-07-19 04:33:20 +00:00
|
|
|
*/
|
|
|
|
UnicodeFunctor *cloneAsThawed() const;
|
|
|
|
|
1999-12-28 23:57:50 +00:00
|
|
|
//----------------------------------------------------------------
|
|
|
|
// Public API
|
|
|
|
//----------------------------------------------------------------
|
|
|
|
|
2000-05-25 19:27:14 +00:00
|
|
|
/**
|
|
|
|
* Make this object represent the range <code>start - end</code>.
|
|
|
|
* If <code>end > start</code> then this object is set to an
|
|
|
|
* an empty range.
|
2007-07-19 04:33:20 +00:00
|
|
|
* A frozen set will not be modified.
|
2000-05-25 19:27:14 +00:00
|
|
|
*
|
|
|
|
* @param start first character in the set, inclusive
|
2002-12-19 00:25:31 +00:00
|
|
|
* @param end last character in the set, inclusive
|
2004-03-26 19:42:04 +00:00
|
|
|
* @stable ICU 2.4
|
2000-05-25 19:27:14 +00:00
|
|
|
*/
|
2002-04-25 23:39:57 +00:00
|
|
|
UnicodeSet& set(UChar32 start, UChar32 end);
|
2000-05-25 19:27:14 +00:00
|
|
|
|
2001-10-18 04:06:14 +00:00
|
|
|
/**
|
|
|
|
* Return true if the given position, in the given pattern, appears
|
|
|
|
* to be the start of a UnicodeSet pattern.
|
2004-03-26 19:42:04 +00:00
|
|
|
* @stable ICU 2.4
|
2001-10-18 04:06:14 +00:00
|
|
|
*/
|
|
|
|
static UBool resemblesPattern(const UnicodeString& pattern,
|
|
|
|
int32_t pos);
|
|
|
|
|
1999-12-28 23:57:50 +00:00
|
|
|
/**
|
|
|
|
* Modifies this set to represent the set specified by the given
|
|
|
|
* pattern, optionally ignoring white space. See the class
|
|
|
|
* description for the syntax of the pattern language.
|
2007-07-19 04:33:20 +00:00
|
|
|
* A frozen set will not be modified.
|
1999-12-28 23:57:50 +00:00
|
|
|
* @param pattern a string specifying what characters are in the set
|
2003-06-11 00:04:00 +00:00
|
|
|
* @param status returns <code>U_ILLEGAL_ARGUMENT_ERROR</code> if the pattern
|
1999-12-28 23:57:50 +00:00
|
|
|
* contains a syntax error.
|
2004-06-08 21:05:45 +00:00
|
|
|
* <em> Empties the set passed before applying the pattern.</em>
|
2003-10-14 21:47:59 +00:00
|
|
|
* @return a reference to this
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
2004-08-26 22:51:40 +00:00
|
|
|
UnicodeSet& applyPattern(const UnicodeString& pattern,
|
|
|
|
UErrorCode& status);
|
1999-12-28 23:57:50 +00:00
|
|
|
|
2003-02-14 21:22:20 +00:00
|
|
|
/**
|
|
|
|
* Modifies this set to represent the set specified by the given
|
|
|
|
* pattern, optionally ignoring white space. See the class
|
|
|
|
* description for the syntax of the pattern language.
|
2007-07-19 04:33:20 +00:00
|
|
|
* A frozen set will not be modified.
|
2003-02-14 21:22:20 +00:00
|
|
|
* @param pattern a string specifying what characters are in the set
|
|
|
|
* @param options bitmask for options to apply to the pattern.
|
|
|
|
* Valid options are USET_IGNORE_SPACE and USET_CASE_INSENSITIVE.
|
2003-10-14 21:47:59 +00:00
|
|
|
* @param symbols a symbol table mapping variable names to
|
|
|
|
* values and stand-ins to UnicodeSets; may be NULL
|
2003-06-11 00:04:00 +00:00
|
|
|
* @param status returns <code>U_ILLEGAL_ARGUMENT_ERROR</code> if the pattern
|
2003-04-26 00:22:06 +00:00
|
|
|
* contains a syntax error.
|
2004-06-08 21:05:45 +00:00
|
|
|
*<em> Empties the set passed before applying the pattern.</em>
|
2003-10-14 21:47:59 +00:00
|
|
|
* @return a reference to this
|
2003-02-14 21:22:20 +00:00
|
|
|
* @internal
|
|
|
|
*/
|
|
|
|
UnicodeSet& applyPattern(const UnicodeString& pattern,
|
|
|
|
uint32_t options,
|
2003-10-14 21:47:59 +00:00
|
|
|
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.
|
2004-06-08 21:05:45 +00:00
|
|
|
*<em> Empties the set passed before applying the pattern.</em>
|
2007-07-19 04:33:20 +00:00
|
|
|
* A frozen set will not be modified.
|
2003-10-14 21:47:59 +00:00
|
|
|
*
|
|
|
|
* @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
|
2003-11-24 19:59:15 +00:00
|
|
|
* @param status returns <code>U_ILLEGAL_ARGUMENT_ERROR</code> if the pattern
|
|
|
|
* contains a syntax error.
|
2003-10-14 21:47:59 +00:00
|
|
|
* @return a reference to this
|
2005-06-22 23:38:06 +00:00
|
|
|
* @stable ICU 2.8
|
2003-10-14 21:47:59 +00:00
|
|
|
*/
|
|
|
|
UnicodeSet& applyPattern(const UnicodeString& pattern,
|
|
|
|
ParsePosition& pos,
|
|
|
|
uint32_t options,
|
|
|
|
const SymbolTable* symbols,
|
2003-02-14 21:22:20 +00:00
|
|
|
UErrorCode& status);
|
|
|
|
|
1999-12-28 23:57:50 +00:00
|
|
|
/**
|
|
|
|
* Returns a string representation of this set. If the result of
|
|
|
|
* calling this function is passed to a UnicodeSet constructor, it
|
|
|
|
* will produce another set that is equal to this one.
|
2007-07-19 04:33:20 +00:00
|
|
|
* A frozen set will not be modified.
|
2001-06-12 17:34:16 +00:00
|
|
|
* @param result the string to receive the rules. Previous
|
|
|
|
* contents will be deleted.
|
|
|
|
* @param escapeUnprintable if TRUE then convert unprintable
|
2004-06-15 20:52:22 +00:00
|
|
|
* character to their hex escape representations, \\uxxxx or
|
|
|
|
* \\Uxxxxxxxx. Unprintable characters are those other than
|
2001-06-12 17:34:16 +00:00
|
|
|
* U+000A, U+0020..U+007E.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
2004-10-15 22:56:26 +00:00
|
|
|
virtual UnicodeString& toPattern(UnicodeString& result,
|
2004-08-26 22:51:40 +00:00
|
|
|
UBool escapeUnprintable = FALSE) const;
|
1999-12-28 23:57:50 +00:00
|
|
|
|
2002-10-30 18:24:00 +00:00
|
|
|
/**
|
|
|
|
* Modifies this set to contain those code points which have the given value
|
|
|
|
* for the given binary or enumerated property, as returned by
|
|
|
|
* u_getIntPropertyValue. Prior contents of this set are lost.
|
2007-07-19 04:33:20 +00:00
|
|
|
* A frozen set will not be modified.
|
2002-10-30 18:24:00 +00:00
|
|
|
*
|
|
|
|
* @param prop a property in the range UCHAR_BIN_START..UCHAR_BIN_LIMIT-1
|
2002-12-11 19:36:51 +00:00
|
|
|
* or UCHAR_INT_START..UCHAR_INT_LIMIT-1
|
|
|
|
* or UCHAR_MASK_START..UCHAR_MASK_LIMIT-1.
|
2002-10-30 18:24:00 +00:00
|
|
|
*
|
|
|
|
* @param value a value in the range u_getIntPropertyMinValue(prop)..
|
|
|
|
* u_getIntPropertyMaxValue(prop), with one exception. If prop is
|
2002-12-11 19:36:51 +00:00
|
|
|
* UCHAR_GENERAL_CATEGORY_MASK, then value should not be a UCharCategory, but
|
2002-10-30 18:24:00 +00:00
|
|
|
* rather a mask value produced by U_GET_GC_MASK(). This allows grouped
|
2002-12-11 19:36:51 +00:00
|
|
|
* categories such as [:L:] to be represented.
|
2002-10-30 18:24:00 +00:00
|
|
|
*
|
|
|
|
* @param ec error code input/output parameter
|
|
|
|
*
|
|
|
|
* @return a reference to this set
|
|
|
|
*
|
2004-03-26 19:42:04 +00:00
|
|
|
* @stable ICU 2.4
|
2002-10-30 18:24:00 +00:00
|
|
|
*/
|
|
|
|
UnicodeSet& applyIntPropertyValue(UProperty prop,
|
|
|
|
int32_t value,
|
|
|
|
UErrorCode& ec);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Modifies this set to contain those code points which have the
|
|
|
|
* given value for the given property. Prior contents of this
|
|
|
|
* set are lost.
|
2007-07-19 04:33:20 +00:00
|
|
|
* A frozen set will not be modified.
|
2002-10-30 18:24:00 +00:00
|
|
|
*
|
|
|
|
* @param prop a property alias, either short or long. The name is matched
|
|
|
|
* loosely. See PropertyAliases.txt for names and a description of loose
|
|
|
|
* matching. If the value string is empty, then this string is interpreted
|
|
|
|
* as either a General_Category value alias, a Script value alias, a binary
|
|
|
|
* property alias, or a special ID. Special IDs are matched loosely and
|
|
|
|
* correspond to the following sets:
|
|
|
|
*
|
2004-06-15 20:52:22 +00:00
|
|
|
* "ANY" = [\\u0000-\\U0010FFFF],
|
2005-05-28 22:54:36 +00:00
|
|
|
* "ASCII" = [\\u0000-\\u007F],
|
|
|
|
* "Assigned" = [:^Cn:].
|
2002-10-30 18:24:00 +00:00
|
|
|
*
|
|
|
|
* @param value a value alias, either short or long. The name is matched
|
|
|
|
* loosely. See PropertyValueAliases.txt for names and a description of
|
|
|
|
* loose matching. In addition to aliases listed, numeric values and
|
|
|
|
* canonical combining classes may be expressed numerically, e.g., ("nv",
|
|
|
|
* "0.5") or ("ccc", "220"). The value string may also be empty.
|
|
|
|
*
|
|
|
|
* @param ec error code input/output parameter
|
|
|
|
*
|
|
|
|
* @return a reference to this set
|
|
|
|
*
|
2004-03-26 19:42:04 +00:00
|
|
|
* @stable ICU 2.4
|
2002-10-30 18:24:00 +00:00
|
|
|
*/
|
|
|
|
UnicodeSet& applyPropertyAlias(const UnicodeString& prop,
|
|
|
|
const UnicodeString& value,
|
|
|
|
UErrorCode& ec);
|
|
|
|
|
1999-12-28 23:57:50 +00:00
|
|
|
/**
|
2004-11-04 22:05:00 +00:00
|
|
|
* Returns the number of elements in this set (its cardinality).
|
|
|
|
* Note than the elements of a set may include both individual
|
|
|
|
* codepoints and strings.
|
1999-12-28 23:57:50 +00:00
|
|
|
*
|
|
|
|
* @return the number of elements in this set (its cardinality).
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
|
|
|
virtual int32_t size(void) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns <tt>true</tt> if this set contains no elements.
|
|
|
|
*
|
|
|
|
* @return <tt>true</tt> if this set contains no elements.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
2000-05-18 22:08:39 +00:00
|
|
|
virtual UBool isEmpty(void) const;
|
1999-12-28 23:57:50 +00:00
|
|
|
|
|
|
|
/**
|
2002-04-25 23:39:57 +00:00
|
|
|
* Returns true if this set contains the given character.
|
2007-07-19 04:33:20 +00:00
|
|
|
* This function works faster with a frozen set.
|
2002-04-25 23:39:57 +00:00
|
|
|
* @param c character to be checked for containment
|
|
|
|
* @return true if the test condition is met
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2002-04-25 23:39:57 +00:00
|
|
|
*/
|
|
|
|
virtual UBool contains(UChar32 c) const;
|
2004-08-24 17:21:14 +00:00
|
|
|
|
2002-04-25 23:39:57 +00:00
|
|
|
/**
|
|
|
|
* Returns true if this set contains every character
|
|
|
|
* of the given range.
|
|
|
|
* @param start first character, inclusive, of the range
|
|
|
|
* @param end last character, inclusive, of the range
|
|
|
|
* @return true if the test condition is met
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
2000-05-25 19:27:14 +00:00
|
|
|
virtual UBool contains(UChar32 start, UChar32 end) const;
|
|
|
|
|
|
|
|
/**
|
2002-04-25 23:39:57 +00:00
|
|
|
* Returns <tt>true</tt> if this set contains the given
|
|
|
|
* multicharacter string.
|
|
|
|
* @param s string to be checked for containment
|
|
|
|
* @return <tt>true</tt> if this set contains the specified string
|
2004-03-26 19:42:04 +00:00
|
|
|
* @stable ICU 2.4
|
2000-05-25 19:27:14 +00:00
|
|
|
*/
|
2002-04-25 23:39:57 +00:00
|
|
|
UBool contains(const UnicodeString& s) const;
|
2004-08-24 17:21:14 +00:00
|
|
|
|
2002-04-25 23:39:57 +00:00
|
|
|
/**
|
|
|
|
* Returns true if this set contains all the characters and strings
|
|
|
|
* of the given set.
|
|
|
|
* @param c set to be checked for containment
|
|
|
|
* @return true if the test condition is met
|
2004-03-26 19:42:04 +00:00
|
|
|
* @stable ICU 2.4
|
2002-04-25 23:39:57 +00:00
|
|
|
*/
|
|
|
|
virtual UBool containsAll(const UnicodeSet& c) const;
|
2004-08-24 17:21:14 +00:00
|
|
|
|
2002-04-25 23:39:57 +00:00
|
|
|
/**
|
|
|
|
* Returns true if this set contains all the characters
|
|
|
|
* of the given string.
|
|
|
|
* @param s string containing characters to be checked for containment
|
|
|
|
* @return true if the test condition is met
|
2004-03-26 19:42:04 +00:00
|
|
|
* @stable ICU 2.4
|
2002-04-25 23:39:57 +00:00
|
|
|
*/
|
|
|
|
UBool containsAll(const UnicodeString& s) const;
|
2004-08-24 17:21:14 +00:00
|
|
|
|
2002-04-25 23:39:57 +00:00
|
|
|
/**
|
|
|
|
* Returns true if this set contains none of the characters
|
|
|
|
* of the given range.
|
|
|
|
* @param start first character, inclusive, of the range
|
|
|
|
* @param end last character, inclusive, of the range
|
|
|
|
* @return true if the test condition is met
|
2004-03-26 19:42:04 +00:00
|
|
|
* @stable ICU 2.4
|
2002-04-25 23:39:57 +00:00
|
|
|
*/
|
|
|
|
UBool containsNone(UChar32 start, UChar32 end) const;
|
1999-12-28 23:57:50 +00:00
|
|
|
|
2002-04-25 23:39:57 +00:00
|
|
|
/**
|
|
|
|
* Returns true if this set contains none of the characters and strings
|
|
|
|
* of the given set.
|
|
|
|
* @param c set to be checked for containment
|
|
|
|
* @return true if the test condition is met
|
2004-03-26 19:42:04 +00:00
|
|
|
* @stable ICU 2.4
|
2002-04-25 23:39:57 +00:00
|
|
|
*/
|
|
|
|
UBool containsNone(const UnicodeSet& c) const;
|
2004-08-24 17:21:14 +00:00
|
|
|
|
2002-04-25 23:39:57 +00:00
|
|
|
/**
|
|
|
|
* Returns true if this set contains none of the characters
|
|
|
|
* of the given string.
|
|
|
|
* @param s string containing characters to be checked for containment
|
|
|
|
* @return true if the test condition is met
|
2004-03-26 19:42:04 +00:00
|
|
|
* @stable ICU 2.4
|
2002-04-25 23:39:57 +00:00
|
|
|
*/
|
|
|
|
UBool containsNone(const UnicodeString& s) const;
|
2004-08-24 17:21:14 +00:00
|
|
|
|
2002-04-25 23:39:57 +00:00
|
|
|
/**
|
|
|
|
* Returns true if this set contains one or more of the characters
|
|
|
|
* in the given range.
|
|
|
|
* @param start first character, inclusive, of the range
|
|
|
|
* @param end last character, inclusive, of the range
|
|
|
|
* @return true if the condition is met
|
2004-03-26 19:42:04 +00:00
|
|
|
* @stable ICU 2.4
|
2002-04-25 23:39:57 +00:00
|
|
|
*/
|
|
|
|
inline UBool containsSome(UChar32 start, UChar32 end) const;
|
2004-08-24 17:21:14 +00:00
|
|
|
|
2002-04-25 23:39:57 +00:00
|
|
|
/**
|
|
|
|
* Returns true if this set contains one or more of the characters
|
|
|
|
* and strings of the given set.
|
2003-04-26 00:22:06 +00:00
|
|
|
* @param s The set to be checked for containment
|
2002-04-25 23:39:57 +00:00
|
|
|
* @return true if the condition is met
|
2004-03-26 19:42:04 +00:00
|
|
|
* @stable ICU 2.4
|
2002-04-25 23:39:57 +00:00
|
|
|
*/
|
|
|
|
inline UBool containsSome(const UnicodeSet& s) const;
|
2004-08-24 17:21:14 +00:00
|
|
|
|
2002-04-25 23:39:57 +00:00
|
|
|
/**
|
|
|
|
* Returns true if this set contains one or more of the characters
|
|
|
|
* of the given string.
|
|
|
|
* @param s string containing characters to be checked for containment
|
|
|
|
* @return true if the condition is met
|
2004-03-26 19:42:04 +00:00
|
|
|
* @stable ICU 2.4
|
2002-04-25 23:39:57 +00:00
|
|
|
*/
|
|
|
|
inline UBool containsSome(const UnicodeString& s) const;
|
2004-08-24 17:21:14 +00:00
|
|
|
|
2007-07-19 04:33:20 +00:00
|
|
|
/**
|
|
|
|
* Returns the length of the initial substring of the input string which
|
|
|
|
* consists only of characters and strings that are contained in this set
|
|
|
|
* (USET_SPAN_CONTAINED, USET_SPAN_SIMPLE),
|
|
|
|
* or only of characters and strings that are not contained
|
|
|
|
* in this set (USET_SPAN_NOT_CONTAINED).
|
|
|
|
* See USetSpanCondition for details.
|
|
|
|
* Similar to the strspn() C library function.
|
|
|
|
* Unpaired surrogates are treated according to contains() of their surrogate code points.
|
|
|
|
* This function works faster with a frozen set and with a non-negative string length argument.
|
|
|
|
* @param s start of the string
|
|
|
|
* @param length of the string; can be -1 for NUL-terminated
|
2007-08-03 23:52:19 +00:00
|
|
|
* @param spanCondition specifies the containment condition
|
2007-07-19 04:33:20 +00:00
|
|
|
* @return the length of the initial substring according to the spanCondition;
|
|
|
|
* 0 if the start of the string does not fit the spanCondition
|
2008-07-21 18:57:26 +00:00
|
|
|
* @stable ICU 3.8
|
2007-07-19 04:33:20 +00:00
|
|
|
* @see USetSpanCondition
|
|
|
|
*/
|
|
|
|
int32_t span(const UChar *s, int32_t length, USetSpanCondition spanCondition) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the start of the trailing substring of the input string which
|
|
|
|
* consists only of characters and strings that are contained in this set
|
|
|
|
* (USET_SPAN_CONTAINED, USET_SPAN_SIMPLE),
|
|
|
|
* or only of characters and strings that are not contained
|
|
|
|
* in this set (USET_SPAN_NOT_CONTAINED).
|
|
|
|
* See USetSpanCondition for details.
|
|
|
|
* Unpaired surrogates are treated according to contains() of their surrogate code points.
|
|
|
|
* This function works faster with a frozen set and with a non-negative string length argument.
|
|
|
|
* @param s start of the string
|
|
|
|
* @param length of the string; can be -1 for NUL-terminated
|
2007-08-03 23:52:19 +00:00
|
|
|
* @param spanCondition specifies the containment condition
|
2007-07-19 04:33:20 +00:00
|
|
|
* @return the start of the trailing substring according to the spanCondition;
|
|
|
|
* the string length if the end of the string does not fit the spanCondition
|
2008-07-21 18:57:26 +00:00
|
|
|
* @stable ICU 3.8
|
2007-07-19 04:33:20 +00:00
|
|
|
* @see USetSpanCondition
|
|
|
|
*/
|
|
|
|
int32_t spanBack(const UChar *s, int32_t length, USetSpanCondition spanCondition) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the length of the initial substring of the input string which
|
|
|
|
* consists only of characters and strings that are contained in this set
|
|
|
|
* (USET_SPAN_CONTAINED, USET_SPAN_SIMPLE),
|
|
|
|
* or only of characters and strings that are not contained
|
|
|
|
* in this set (USET_SPAN_NOT_CONTAINED).
|
|
|
|
* See USetSpanCondition for details.
|
|
|
|
* Similar to the strspn() C library function.
|
|
|
|
* Malformed byte sequences are treated according to contains(0xfffd).
|
|
|
|
* This function works faster with a frozen set and with a non-negative string length argument.
|
|
|
|
* @param s start of the string (UTF-8)
|
|
|
|
* @param length of the string; can be -1 for NUL-terminated
|
2007-08-03 23:52:19 +00:00
|
|
|
* @param spanCondition specifies the containment condition
|
2007-07-19 04:33:20 +00:00
|
|
|
* @return the length of the initial substring according to the spanCondition;
|
|
|
|
* 0 if the start of the string does not fit the spanCondition
|
2008-07-21 18:57:26 +00:00
|
|
|
* @stable ICU 3.8
|
2007-07-19 04:33:20 +00:00
|
|
|
* @see USetSpanCondition
|
|
|
|
*/
|
|
|
|
int32_t spanUTF8(const char *s, int32_t length, USetSpanCondition spanCondition) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the start of the trailing substring of the input string which
|
|
|
|
* consists only of characters and strings that are contained in this set
|
|
|
|
* (USET_SPAN_CONTAINED, USET_SPAN_SIMPLE),
|
|
|
|
* or only of characters and strings that are not contained
|
|
|
|
* in this set (USET_SPAN_NOT_CONTAINED).
|
|
|
|
* See USetSpanCondition for details.
|
|
|
|
* Malformed byte sequences are treated according to contains(0xfffd).
|
|
|
|
* This function works faster with a frozen set and with a non-negative string length argument.
|
|
|
|
* @param s start of the string (UTF-8)
|
|
|
|
* @param length of the string; can be -1 for NUL-terminated
|
2007-08-03 23:52:19 +00:00
|
|
|
* @param spanCondition specifies the containment condition
|
2007-07-19 04:33:20 +00:00
|
|
|
* @return the start of the trailing substring according to the spanCondition;
|
|
|
|
* the string length if the end of the string does not fit the spanCondition
|
2008-07-21 18:57:26 +00:00
|
|
|
* @stable ICU 3.8
|
2007-07-19 04:33:20 +00:00
|
|
|
* @see USetSpanCondition
|
|
|
|
*/
|
|
|
|
int32_t spanBackUTF8(const char *s, int32_t length, USetSpanCondition spanCondition) const;
|
|
|
|
|
1999-12-28 23:57:50 +00:00
|
|
|
/**
|
2001-07-25 18:50:09 +00:00
|
|
|
* Implement UnicodeMatcher::matches()
|
2004-03-26 19:42:04 +00:00
|
|
|
* @stable ICU 2.4
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
2004-08-27 16:45:16 +00:00
|
|
|
virtual UMatchDegree matches(const Replaceable& text,
|
2001-07-25 18:50:09 +00:00
|
|
|
int32_t& offset,
|
|
|
|
int32_t limit,
|
2001-10-30 23:55:09 +00:00
|
|
|
UBool incremental);
|
2002-04-25 23:39:57 +00:00
|
|
|
|
2004-08-27 16:45:16 +00:00
|
|
|
private:
|
2002-04-25 23:39:57 +00:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
* @param text the text to match
|
|
|
|
* @param 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).
|
|
|
|
* @param 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.
|
|
|
|
* @return 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
|
|
|
|
*/
|
|
|
|
static int32_t matchRest(const Replaceable& text,
|
|
|
|
int32_t start, int32_t limit,
|
|
|
|
const UnicodeString& s);
|
2004-08-24 17:21:14 +00:00
|
|
|
|
2002-07-29 20:41:49 +00:00
|
|
|
/**
|
|
|
|
* Returns the smallest value i such that c < list[i]. Caller
|
|
|
|
* must ensure that c is a legal value or this method will enter
|
|
|
|
* an infinite loop. This method performs a binary search.
|
|
|
|
* @param c a character in the range MIN_VALUE..MAX_VALUE
|
|
|
|
* inclusive
|
|
|
|
* @return the smallest integer i in the range 0..len-1,
|
|
|
|
* inclusive, such that c < list[i]
|
|
|
|
*/
|
2002-07-30 01:22:08 +00:00
|
|
|
int32_t findCodePoint(UChar32 c) const;
|
2002-07-29 20:41:49 +00:00
|
|
|
|
2004-08-27 16:45:16 +00:00
|
|
|
public:
|
2002-06-28 21:13:54 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Implementation of UnicodeMatcher API. Union the set of all
|
|
|
|
* characters that may be matched by this object into the given
|
|
|
|
* set.
|
|
|
|
* @param toUnionTo the set into which to union the source characters
|
2004-03-26 19:42:04 +00:00
|
|
|
* @stable ICU 2.4
|
2002-06-28 21:13:54 +00:00
|
|
|
*/
|
2004-08-27 16:45:16 +00:00
|
|
|
virtual void addMatchSetTo(UnicodeSet& toUnionTo) const;
|
2002-06-28 21:13:54 +00:00
|
|
|
|
2001-12-11 01:13:33 +00:00
|
|
|
/**
|
|
|
|
* Returns the index of the given character within this set, where
|
|
|
|
* the set is ordered by ascending code point. If the character
|
|
|
|
* is not in this set, return -1. The inverse of this method is
|
|
|
|
* <code>charAt()</code>.
|
|
|
|
* @return an index from 0..size()-1, or -1
|
2004-03-26 19:42:04 +00:00
|
|
|
* @stable ICU 2.4
|
2001-12-11 01:13:33 +00:00
|
|
|
*/
|
|
|
|
int32_t indexOf(UChar32 c) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the character at the given index within this set, where
|
|
|
|
* the set is ordered by ascending code point. If the index is
|
|
|
|
* out of range, return (UChar32)-1. The inverse of this method is
|
|
|
|
* <code>indexOf()</code>.
|
|
|
|
* @param index an index from 0..size()-1
|
|
|
|
* @return the character at the given index, or (UChar32)-1.
|
2004-03-26 19:42:04 +00:00
|
|
|
* @stable ICU 2.4
|
2001-12-11 01:13:33 +00:00
|
|
|
*/
|
|
|
|
UChar32 charAt(int32_t index) const;
|
|
|
|
|
1999-12-28 23:57:50 +00:00
|
|
|
/**
|
|
|
|
* Adds the specified range to this set if it is not already
|
|
|
|
* present. If this set already contains the specified range,
|
2000-05-25 19:27:14 +00:00
|
|
|
* the call leaves this set unchanged. If <code>end > start</code>
|
1999-12-28 23:57:50 +00:00
|
|
|
* then an empty range is added, leaving the set unchanged.
|
2000-05-26 18:32:15 +00:00
|
|
|
* This is equivalent to a boolean logic OR, or a set UNION.
|
2007-07-19 04:33:20 +00:00
|
|
|
* A frozen set will not be modified.
|
1999-12-28 23:57:50 +00:00
|
|
|
*
|
2000-05-25 19:27:14 +00:00
|
|
|
* @param start first character, inclusive, of range to be added
|
1999-12-28 23:57:50 +00:00
|
|
|
* to this set.
|
2000-05-25 19:27:14 +00:00
|
|
|
* @param end last character, inclusive, of range to be added
|
1999-12-28 23:57:50 +00:00
|
|
|
* to this set.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
2002-04-25 23:39:57 +00:00
|
|
|
virtual UnicodeSet& add(UChar32 start, UChar32 end);
|
1999-12-28 23:57:50 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds the specified character to this set if it is not already
|
|
|
|
* present. If this set already contains the specified character,
|
|
|
|
* the call leaves this set unchanged.
|
2007-07-19 04:33:20 +00:00
|
|
|
* A frozen set will not be modified.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
2002-04-25 23:39:57 +00:00
|
|
|
UnicodeSet& add(UChar32 c);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds the specified multicharacter to this set if it is not already
|
|
|
|
* present. If this set already contains the multicharacter,
|
|
|
|
* the call leaves this set unchanged.
|
|
|
|
* Thus "ch" => {"ch"}
|
2002-07-03 12:05:56 +00:00
|
|
|
* <br><b>Warning: you cannot add an empty string ("") to a UnicodeSet.</b>
|
2007-07-19 04:33:20 +00:00
|
|
|
* A frozen set will not be modified.
|
2002-04-25 23:39:57 +00:00
|
|
|
* @param s the source string
|
|
|
|
* @return this object, for chaining
|
2004-03-26 19:42:04 +00:00
|
|
|
* @stable ICU 2.4
|
2002-04-25 23:39:57 +00:00
|
|
|
*/
|
|
|
|
UnicodeSet& add(const UnicodeString& s);
|
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
private:
|
2002-04-25 23:39:57 +00:00
|
|
|
/**
|
|
|
|
* @return a code point IF the string consists of a single one.
|
|
|
|
* otherwise returns -1.
|
2009-03-19 02:01:37 +00:00
|
|
|
* @param s string to test
|
2002-04-25 23:39:57 +00:00
|
|
|
*/
|
|
|
|
static int32_t getSingleCP(const UnicodeString& s);
|
|
|
|
|
|
|
|
void _add(const UnicodeString& s);
|
2004-08-24 17:21:14 +00:00
|
|
|
|
2002-04-25 23:39:57 +00:00
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Adds each of the characters in this string to the set. Thus "ch" => {"c", "h"}
|
|
|
|
* If this set already any particular character, it has no effect on that character.
|
2007-07-19 04:33:20 +00:00
|
|
|
* A frozen set will not be modified.
|
2002-04-25 23:39:57 +00:00
|
|
|
* @param s the source string
|
|
|
|
* @return this object, for chaining
|
2004-03-26 19:42:04 +00:00
|
|
|
* @stable ICU 2.4
|
2002-04-25 23:39:57 +00:00
|
|
|
*/
|
|
|
|
UnicodeSet& addAll(const UnicodeString& s);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Retains EACH of the characters in this string. Note: "ch" == {"c", "h"}
|
|
|
|
* If this set already any particular character, it has no effect on that character.
|
2007-07-19 04:33:20 +00:00
|
|
|
* A frozen set will not be modified.
|
2002-04-25 23:39:57 +00:00
|
|
|
* @param s the source string
|
|
|
|
* @return this object, for chaining
|
2004-03-26 19:42:04 +00:00
|
|
|
* @stable ICU 2.4
|
2002-04-25 23:39:57 +00:00
|
|
|
*/
|
|
|
|
UnicodeSet& retainAll(const UnicodeString& s);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Complement EACH of the characters in this string. Note: "ch" == {"c", "h"}
|
|
|
|
* If this set already any particular character, it has no effect on that character.
|
2007-07-19 04:33:20 +00:00
|
|
|
* A frozen set will not be modified.
|
2002-04-25 23:39:57 +00:00
|
|
|
* @param s the source string
|
|
|
|
* @return this object, for chaining
|
2004-03-26 19:42:04 +00:00
|
|
|
* @stable ICU 2.4
|
2002-04-25 23:39:57 +00:00
|
|
|
*/
|
|
|
|
UnicodeSet& complementAll(const UnicodeString& s);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove EACH of the characters in this string. Note: "ch" == {"c", "h"}
|
|
|
|
* If this set already any particular character, it has no effect on that character.
|
2007-07-19 04:33:20 +00:00
|
|
|
* A frozen set will not be modified.
|
2002-04-25 23:39:57 +00:00
|
|
|
* @param s the source string
|
|
|
|
* @return this object, for chaining
|
2004-03-26 19:42:04 +00:00
|
|
|
* @stable ICU 2.4
|
2002-04-25 23:39:57 +00:00
|
|
|
*/
|
|
|
|
UnicodeSet& removeAll(const UnicodeString& s);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Makes a set from a multicharacter string. Thus "ch" => {"ch"}
|
2002-07-03 12:05:56 +00:00
|
|
|
* <br><b>Warning: you cannot add an empty string ("") to a UnicodeSet.</b>
|
2002-04-25 23:39:57 +00:00
|
|
|
* @param s the source string
|
|
|
|
* @return a newly created set containing the given string.
|
|
|
|
* The caller owns the return object and is responsible for deleting it.
|
2004-03-26 19:42:04 +00:00
|
|
|
* @stable ICU 2.4
|
2002-04-25 23:39:57 +00:00
|
|
|
*/
|
2004-08-24 17:21:14 +00:00
|
|
|
static UnicodeSet* U_EXPORT2 createFrom(const UnicodeString& s);
|
|
|
|
|
2002-04-25 23:39:57 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Makes a set from each of the characters in the string. Thus "ch" => {"c", "h"}
|
|
|
|
* @param s the source string
|
|
|
|
* @return a newly created set containing the given characters
|
|
|
|
* The caller owns the return object and is responsible for deleting it.
|
2004-03-26 19:42:04 +00:00
|
|
|
* @stable ICU 2.4
|
2002-04-25 23:39:57 +00:00
|
|
|
*/
|
2004-08-24 17:21:14 +00:00
|
|
|
static UnicodeSet* U_EXPORT2 createFromAll(const UnicodeString& s);
|
2000-05-25 19:27:14 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Retain only the elements in this set that are contained in the
|
|
|
|
* specified range. If <code>end > start</code> then an empty range is
|
2000-05-26 18:32:15 +00:00
|
|
|
* retained, leaving the set empty. This is equivalent to
|
|
|
|
* a boolean logic AND, or a set INTERSECTION.
|
2007-07-19 04:33:20 +00:00
|
|
|
* A frozen set will not be modified.
|
2000-05-25 19:27:14 +00:00
|
|
|
*
|
|
|
|
* @param start first character, inclusive, of range to be retained
|
|
|
|
* to this set.
|
|
|
|
* @param end last character, inclusive, of range to be retained
|
|
|
|
* to this set.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2000-05-25 19:27:14 +00:00
|
|
|
*/
|
2002-04-25 23:39:57 +00:00
|
|
|
virtual UnicodeSet& retain(UChar32 start, UChar32 end);
|
2000-05-25 19:27:14 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Retain the specified character from this set if it is present.
|
2007-07-19 04:33:20 +00:00
|
|
|
* A frozen set will not be modified.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2000-05-25 19:27:14 +00:00
|
|
|
*/
|
2002-04-25 23:39:57 +00:00
|
|
|
UnicodeSet& retain(UChar32 c);
|
1999-12-28 23:57:50 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes the specified range from this set if it is present.
|
|
|
|
* The set will not contain the specified range once the call
|
2000-05-25 19:27:14 +00:00
|
|
|
* returns. If <code>end > start</code> then an empty range is
|
1999-12-28 23:57:50 +00:00
|
|
|
* removed, leaving the set unchanged.
|
2007-07-19 04:33:20 +00:00
|
|
|
* A frozen set will not be modified.
|
2001-03-22 00:09:10 +00:00
|
|
|
*
|
2000-05-25 19:27:14 +00:00
|
|
|
* @param start first character, inclusive, of range to be removed
|
1999-12-28 23:57:50 +00:00
|
|
|
* from this set.
|
2000-05-25 19:27:14 +00:00
|
|
|
* @param end last character, inclusive, of range to be removed
|
1999-12-28 23:57:50 +00:00
|
|
|
* from this set.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
2002-04-25 23:39:57 +00:00
|
|
|
virtual UnicodeSet& remove(UChar32 start, UChar32 end);
|
1999-12-28 23:57:50 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes the specified character from this set if it is present.
|
|
|
|
* The set will not contain the specified range once the call
|
|
|
|
* returns.
|
2007-07-19 04:33:20 +00:00
|
|
|
* A frozen set will not be modified.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
2002-04-25 23:39:57 +00:00
|
|
|
UnicodeSet& remove(UChar32 c);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes the specified string from this set if it is present.
|
|
|
|
* The set will not contain the specified character once the call
|
|
|
|
* returns.
|
2007-07-19 04:33:20 +00:00
|
|
|
* A frozen set will not be modified.
|
2002-04-25 23:39:57 +00:00
|
|
|
* @param s the source string
|
|
|
|
* @return this object, for chaining
|
2004-03-26 19:42:04 +00:00
|
|
|
* @stable ICU 2.4
|
2002-04-25 23:39:57 +00:00
|
|
|
*/
|
|
|
|
UnicodeSet& remove(const UnicodeString& s);
|
2000-05-25 19:27:14 +00:00
|
|
|
|
2000-05-26 18:32:15 +00:00
|
|
|
/**
|
|
|
|
* Inverts this set. This operation modifies this set so that
|
|
|
|
* its value is its complement. This is equivalent to
|
|
|
|
* <code>complement(MIN_VALUE, MAX_VALUE)</code>.
|
2007-07-19 04:33:20 +00:00
|
|
|
* A frozen set will not be modified.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2000-05-26 18:32:15 +00:00
|
|
|
*/
|
2002-04-25 23:39:57 +00:00
|
|
|
virtual UnicodeSet& complement(void);
|
2000-05-26 18:32:15 +00:00
|
|
|
|
2000-05-25 19:27:14 +00:00
|
|
|
/**
|
|
|
|
* Complements the specified range in this set. Any character in
|
|
|
|
* the range will be removed if it is in this set, or will be
|
|
|
|
* added if it is not in this set. If <code>end > start</code>
|
2000-05-26 18:32:15 +00:00
|
|
|
* then an empty range is complemented, leaving the set unchanged.
|
|
|
|
* This is equivalent to a boolean logic XOR.
|
2007-07-19 04:33:20 +00:00
|
|
|
* A frozen set will not be modified.
|
2000-05-25 19:27:14 +00:00
|
|
|
*
|
|
|
|
* @param start first character, inclusive, of range to be removed
|
|
|
|
* from this set.
|
|
|
|
* @param end last character, inclusive, of range to be removed
|
|
|
|
* from this set.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2000-05-25 19:27:14 +00:00
|
|
|
*/
|
2002-04-25 23:39:57 +00:00
|
|
|
virtual UnicodeSet& complement(UChar32 start, UChar32 end);
|
2000-05-25 19:27:14 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Complements the specified character in this set. The character
|
|
|
|
* will be removed if it is in this set, or will be added if it is
|
|
|
|
* not in this set.
|
2007-07-19 04:33:20 +00:00
|
|
|
* A frozen set will not be modified.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2000-05-25 19:27:14 +00:00
|
|
|
*/
|
2002-04-25 23:39:57 +00:00
|
|
|
UnicodeSet& complement(UChar32 c);
|
1999-12-28 23:57:50 +00:00
|
|
|
|
|
|
|
/**
|
2002-04-25 23:39:57 +00:00
|
|
|
* Complement the specified string in this set.
|
|
|
|
* The set will not contain the specified string once the call
|
|
|
|
* returns.
|
|
|
|
* <br><b>Warning: you cannot add an empty string ("") to a UnicodeSet.</b>
|
2007-07-19 04:33:20 +00:00
|
|
|
* A frozen set will not be modified.
|
2002-04-25 23:39:57 +00:00
|
|
|
* @param s the string to complement
|
|
|
|
* @return this object, for chaining
|
2004-03-26 19:42:04 +00:00
|
|
|
* @stable ICU 2.4
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
2002-04-25 23:39:57 +00:00
|
|
|
UnicodeSet& complement(const UnicodeString& s);
|
2001-12-03 20:50:50 +00:00
|
|
|
|
1999-12-28 23:57:50 +00:00
|
|
|
/**
|
|
|
|
* Adds all of the elements in the specified set to this set if
|
|
|
|
* they're not already present. This operation effectively
|
|
|
|
* modifies this set so that its value is the <i>union</i> of the two
|
|
|
|
* sets. The behavior of this operation is unspecified if the specified
|
|
|
|
* collection is modified while the operation is in progress.
|
2007-07-19 04:33:20 +00:00
|
|
|
* A frozen set will not be modified.
|
1999-12-28 23:57:50 +00:00
|
|
|
*
|
|
|
|
* @param c set whose elements are to be added to this set.
|
2007-08-03 23:52:19 +00:00
|
|
|
* @see #add(UChar32, UChar32)
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
2002-04-25 23:39:57 +00:00
|
|
|
virtual UnicodeSet& addAll(const UnicodeSet& c);
|
1999-12-28 23:57:50 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Retains only the elements in this set that are contained in the
|
|
|
|
* specified set. In other words, removes from this set all of
|
|
|
|
* its elements that are not contained in the specified set. This
|
|
|
|
* operation effectively modifies this set so that its value is
|
|
|
|
* the <i>intersection</i> of the two sets.
|
2007-07-19 04:33:20 +00:00
|
|
|
* A frozen set will not be modified.
|
1999-12-28 23:57:50 +00:00
|
|
|
*
|
|
|
|
* @param c set that defines which elements this set will retain.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
2002-04-25 23:39:57 +00:00
|
|
|
virtual UnicodeSet& retainAll(const UnicodeSet& c);
|
1999-12-28 23:57:50 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes from this set all of its elements that are contained in the
|
|
|
|
* specified set. This operation effectively modifies this
|
|
|
|
* set so that its value is the <i>asymmetric set difference</i> of
|
|
|
|
* the two sets.
|
2007-07-19 04:33:20 +00:00
|
|
|
* A frozen set will not be modified.
|
1999-12-28 23:57:50 +00:00
|
|
|
*
|
|
|
|
* @param c set that defines which elements will be removed from
|
|
|
|
* this set.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
2002-04-25 23:39:57 +00:00
|
|
|
virtual UnicodeSet& removeAll(const UnicodeSet& c);
|
1999-12-28 23:57:50 +00:00
|
|
|
|
2000-05-25 19:27:14 +00:00
|
|
|
/**
|
|
|
|
* Complements in this set all elements contained in the specified
|
|
|
|
* set. Any character in the other set will be removed if it is
|
|
|
|
* in this set, or will be added if it is not in this set.
|
2007-07-19 04:33:20 +00:00
|
|
|
* A frozen set will not be modified.
|
2000-05-25 19:27:14 +00:00
|
|
|
*
|
|
|
|
* @param c set that defines which elements will be xor'ed from
|
|
|
|
* this set.
|
2004-03-26 19:42:04 +00:00
|
|
|
* @stable ICU 2.4
|
2000-05-25 19:27:14 +00:00
|
|
|
*/
|
2002-04-25 23:39:57 +00:00
|
|
|
virtual UnicodeSet& complementAll(const UnicodeSet& c);
|
1999-12-28 23:57:50 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes all of the elements from this set. This set will be
|
|
|
|
* empty after this call returns.
|
2007-07-19 04:33:20 +00:00
|
|
|
* A frozen set will not be modified.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
2002-04-25 23:39:57 +00:00
|
|
|
virtual UnicodeSet& clear(void);
|
1999-12-28 23:57:50 +00:00
|
|
|
|
2003-02-11 22:46:20 +00:00
|
|
|
/**
|
|
|
|
* Close this set over the given attribute. For the attribute
|
|
|
|
* USET_CASE, the result is to modify this set so that:
|
|
|
|
*
|
|
|
|
* 1. For each character or string 'a' in this set, all strings or
|
|
|
|
* characters 'b' such that foldCase(a) == foldCase(b) are added
|
|
|
|
* to this set.
|
|
|
|
*
|
|
|
|
* 2. For each string 'e' in the resulting set, if e !=
|
|
|
|
* foldCase(e), 'e' will be removed.
|
|
|
|
*
|
2004-06-15 20:52:22 +00:00
|
|
|
* Example: [aq\\u00DF{Bc}{bC}{Fi}] => [aAqQ\\u00DF\\uFB01{ss}{bc}{fi}]
|
2003-02-11 22:46:20 +00:00
|
|
|
*
|
|
|
|
* (Here foldCase(x) refers to the operation u_strFoldCase, and a
|
|
|
|
* == b denotes that the contents are the same, not pointer
|
|
|
|
* comparison.)
|
|
|
|
*
|
2007-07-19 04:33:20 +00:00
|
|
|
* A frozen set will not be modified.
|
|
|
|
*
|
2003-02-11 22:46:20 +00:00
|
|
|
* @param attribute bitmask for attributes to close over.
|
|
|
|
* Currently only the USET_CASE bit is supported. Any undefined bits
|
|
|
|
* are ignored.
|
|
|
|
* @return a reference to this set.
|
2009-03-12 17:08:12 +00:00
|
|
|
* @draft ICU 4.2
|
2003-02-11 22:46:20 +00:00
|
|
|
*/
|
|
|
|
UnicodeSet& closeOver(int32_t attribute);
|
|
|
|
|
2007-12-11 21:30:10 +00:00
|
|
|
/**
|
|
|
|
* Remove all strings from this set.
|
|
|
|
*
|
|
|
|
* @return a reference to this set.
|
2009-03-12 01:14:10 +00:00
|
|
|
* @draft ICU 4.2
|
2007-12-11 21:30:10 +00:00
|
|
|
*/
|
|
|
|
virtual UnicodeSet &removeAllStrings();
|
|
|
|
|
2000-05-25 19:27:14 +00:00
|
|
|
/**
|
|
|
|
* Iteration method that returns the number of ranges contained in
|
|
|
|
* this set.
|
|
|
|
* @see #getRangeStart
|
|
|
|
* @see #getRangeEnd
|
2004-03-26 19:42:04 +00:00
|
|
|
* @stable ICU 2.4
|
2000-05-25 19:27:14 +00:00
|
|
|
*/
|
|
|
|
virtual int32_t getRangeCount(void) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Iteration method that returns the first character in the
|
|
|
|
* specified range of this set.
|
|
|
|
* @see #getRangeCount
|
|
|
|
* @see #getRangeEnd
|
2004-03-26 19:42:04 +00:00
|
|
|
* @stable ICU 2.4
|
2000-05-25 19:27:14 +00:00
|
|
|
*/
|
|
|
|
virtual UChar32 getRangeStart(int32_t index) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Iteration method that returns the last character in the
|
|
|
|
* specified range of this set.
|
|
|
|
* @see #getRangeStart
|
|
|
|
* @see #getRangeEnd
|
2004-03-26 19:42:04 +00:00
|
|
|
* @stable ICU 2.4
|
2000-05-25 19:27:14 +00:00
|
|
|
*/
|
|
|
|
virtual UChar32 getRangeEnd(int32_t index) const;
|
|
|
|
|
2002-05-29 18:36:09 +00:00
|
|
|
/**
|
2002-06-04 23:37:20 +00:00
|
|
|
* Serializes this set into an array of 16-bit integers. Serialization
|
|
|
|
* (currently) only records the characters in the set; multicharacter
|
|
|
|
* strings are ignored.
|
|
|
|
*
|
|
|
|
* The array has following format (each line is one 16-bit
|
|
|
|
* integer):
|
2002-05-29 18:36:09 +00:00
|
|
|
*
|
|
|
|
* length = (n+2*m) | (m!=0?0x8000:0)
|
|
|
|
* bmpLength = n; present if m!=0
|
|
|
|
* bmp[0]
|
|
|
|
* bmp[1]
|
|
|
|
* ...
|
|
|
|
* bmp[n-1]
|
|
|
|
* supp-high[0]
|
|
|
|
* supp-low[0]
|
|
|
|
* supp-high[1]
|
|
|
|
* supp-low[1]
|
|
|
|
* ...
|
|
|
|
* supp-high[m-1]
|
|
|
|
* supp-low[m-1]
|
|
|
|
*
|
|
|
|
* The array starts with a header. After the header are n bmp
|
|
|
|
* code points, then m supplementary code points. Either n or m
|
|
|
|
* or both may be zero. n+2*m is always <= 0x7FFF.
|
|
|
|
*
|
|
|
|
* If there are no supplementary characters (if m==0) then the
|
|
|
|
* header is one 16-bit integer, 'length', with value n.
|
|
|
|
*
|
|
|
|
* If there are supplementary characters (if m!=0) then the header
|
|
|
|
* is two 16-bit integers. The first, 'length', has value
|
|
|
|
* (n+2*m)|0x8000. The second, 'bmpLength', has value n.
|
|
|
|
*
|
|
|
|
* After the header the code points are stored in ascending order.
|
|
|
|
* Supplementary code points are stored as most significant 16
|
|
|
|
* bits followed by least significant 16 bits.
|
|
|
|
*
|
|
|
|
* @param dest pointer to buffer of destCapacity 16-bit integers.
|
|
|
|
* May be NULL only if destCapacity is zero.
|
|
|
|
* @param destCapacity size of dest, or zero. Must not be negative.
|
|
|
|
* @param ec error code. Will be set to U_INDEX_OUTOFBOUNDS_ERROR
|
|
|
|
* if n+2*m > 0x7FFF. Will be set to U_BUFFER_OVERFLOW_ERROR if
|
|
|
|
* n+2*m+(m!=0?2:1) > destCapacity.
|
|
|
|
* @return the total length of the serialized format, including
|
|
|
|
* the header, that is, n+2*m+(m!=0?2:1), or 0 on error other
|
|
|
|
* than U_BUFFER_OVERFLOW_ERROR.
|
2004-03-26 19:42:04 +00:00
|
|
|
* @stable ICU 2.4
|
2002-05-29 18:36:09 +00:00
|
|
|
*/
|
|
|
|
int32_t serialize(uint16_t *dest, int32_t destCapacity, UErrorCode& ec) const;
|
|
|
|
|
2000-05-25 19:27:14 +00:00
|
|
|
/**
|
|
|
|
* Reallocate this objects internal structures to take up the least
|
|
|
|
* possible space, without changing this object's value.
|
2007-07-19 04:33:20 +00:00
|
|
|
* A frozen set will not be modified.
|
2004-03-26 19:42:04 +00:00
|
|
|
* @stable ICU 2.4
|
2000-05-25 19:27:14 +00:00
|
|
|
*/
|
2002-04-25 23:39:57 +00:00
|
|
|
virtual UnicodeSet& compact();
|
2000-05-25 19:27:14 +00:00
|
|
|
|
2001-11-09 01:22:59 +00:00
|
|
|
/**
|
|
|
|
* Return the class ID for this class. This is useful only for
|
|
|
|
* comparing to a return value from getDynamicClassID(). For example:
|
|
|
|
* <pre>
|
|
|
|
* . Base* polymorphic_pointer = createPolymorphicObject();
|
|
|
|
* . if (polymorphic_pointer->getDynamicClassID() ==
|
|
|
|
* . Derived::getStaticClassID()) ...
|
|
|
|
* </pre>
|
|
|
|
* @return The class ID for all objects of this class.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2001-11-09 01:22:59 +00:00
|
|
|
*/
|
2004-08-24 17:21:14 +00:00
|
|
|
static UClassID U_EXPORT2 getStaticClassID(void);
|
2001-11-09 01:22:59 +00:00
|
|
|
|
|
|
|
/**
|
2002-02-07 01:07:55 +00:00
|
|
|
* Implement UnicodeFunctor API.
|
2001-11-09 01:22:59 +00:00
|
|
|
*
|
|
|
|
* @return The class ID for this object. All objects of a given
|
|
|
|
* class have the same class ID. Objects of other classes have
|
|
|
|
* different class IDs.
|
2004-03-26 19:42:04 +00:00
|
|
|
* @stable ICU 2.4
|
2001-11-09 01:22:59 +00:00
|
|
|
*/
|
2003-02-06 22:57:35 +00:00
|
|
|
virtual UClassID getDynamicClassID(void) const;
|
2001-11-09 01:22:59 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
2002-06-04 23:37:20 +00:00
|
|
|
// Private API for the USet API
|
|
|
|
|
|
|
|
friend class USetAccess;
|
|
|
|
|
|
|
|
int32_t getStringCount() const;
|
|
|
|
|
|
|
|
const UnicodeString* getString(int32_t index) const;
|
2001-11-09 01:22:59 +00:00
|
|
|
|
1999-12-28 23:57:50 +00:00
|
|
|
//----------------------------------------------------------------
|
2000-01-13 07:28:31 +00:00
|
|
|
// RuleBasedTransliterator support
|
1999-12-28 23:57:50 +00:00
|
|
|
//----------------------------------------------------------------
|
|
|
|
|
2003-09-29 23:00:39 +00:00
|
|
|
private:
|
|
|
|
|
2000-01-13 07:28:31 +00:00
|
|
|
/**
|
|
|
|
* Returns <tt>true</tt> if this set contains any character whose low byte
|
|
|
|
* is the given value. This is used by <tt>RuleBasedTransliterator</tt> for
|
|
|
|
* indexing.
|
|
|
|
*/
|
2001-07-27 00:18:53 +00:00
|
|
|
virtual UBool matchesIndexValue(uint8_t v) const;
|
2000-01-13 07:28:31 +00:00
|
|
|
|
1999-12-28 23:57:50 +00:00
|
|
|
private:
|
|
|
|
|
2007-07-19 04:33:20 +00:00
|
|
|
//----------------------------------------------------------------
|
|
|
|
// Implementation: Clone as thawed (see ICU4J Freezable)
|
|
|
|
//----------------------------------------------------------------
|
|
|
|
|
2007-07-19 17:36:38 +00:00
|
|
|
UnicodeSet(const UnicodeSet& o, UBool /* asThawed */);
|
2007-07-19 04:33:20 +00:00
|
|
|
|
2000-01-13 07:28:31 +00:00
|
|
|
//----------------------------------------------------------------
|
|
|
|
// Implementation: Pattern parsing
|
|
|
|
//----------------------------------------------------------------
|
|
|
|
|
2003-09-29 23:00:39 +00:00
|
|
|
void applyPattern(RuleCharacterIterator& chars,
|
|
|
|
const SymbolTable* symbols,
|
|
|
|
UnicodeString& rebuiltPat,
|
2003-10-14 21:47:59 +00:00
|
|
|
uint32_t options,
|
2003-09-29 23:00:39 +00:00
|
|
|
UErrorCode& ec);
|
|
|
|
|
1999-12-28 23:57:50 +00:00
|
|
|
//----------------------------------------------------------------
|
|
|
|
// Implementation: Utility methods
|
|
|
|
//----------------------------------------------------------------
|
|
|
|
|
2007-12-14 10:17:12 +00:00
|
|
|
void ensureCapacity(int32_t newLen, UErrorCode& ec);
|
2001-03-22 00:09:10 +00:00
|
|
|
|
2007-12-14 10:17:12 +00:00
|
|
|
void ensureBufferCapacity(int32_t newLen, UErrorCode& ec);
|
2001-03-22 00:09:10 +00:00
|
|
|
|
2000-05-25 19:27:14 +00:00
|
|
|
void swapBuffers(void);
|
|
|
|
|
2006-09-29 22:00:46 +00:00
|
|
|
UBool allocateStrings(UErrorCode &status);
|
2002-04-25 23:39:57 +00:00
|
|
|
|
2001-06-12 17:34:16 +00:00
|
|
|
UnicodeString& _toPattern(UnicodeString& result,
|
|
|
|
UBool escapeUnprintable) const;
|
|
|
|
|
|
|
|
UnicodeString& _generatePattern(UnicodeString& result,
|
|
|
|
UBool escapeUnprintable) const;
|
|
|
|
|
2002-04-25 23:39:57 +00:00
|
|
|
static void _appendToPat(UnicodeString& buf, const UnicodeString& s, UBool escapeUnprintable);
|
|
|
|
|
2001-06-12 17:34:16 +00:00
|
|
|
static void _appendToPat(UnicodeString& buf, UChar32 c, UBool escapeUnprintable);
|
|
|
|
|
2000-05-25 19:27:14 +00:00
|
|
|
//----------------------------------------------------------------
|
|
|
|
// Implementation: Fundamental operators
|
|
|
|
//----------------------------------------------------------------
|
|
|
|
|
2000-05-26 01:18:36 +00:00
|
|
|
void exclusiveOr(const UChar32* other, int32_t otherLen, int8_t polarity);
|
2001-03-22 00:09:10 +00:00
|
|
|
|
2000-05-25 19:27:14 +00:00
|
|
|
void add(const UChar32* other, int32_t otherLen, int8_t polarity);
|
2001-03-22 00:09:10 +00:00
|
|
|
|
2000-05-25 19:27:14 +00:00
|
|
|
void retain(const UChar32* other, int32_t otherLen, int8_t polarity);
|
2002-04-25 23:39:57 +00:00
|
|
|
|
2002-10-30 18:24:00 +00:00
|
|
|
/**
|
|
|
|
* Return true if the given position, in the given pattern, appears
|
2004-06-15 20:52:22 +00:00
|
|
|
* to be the start of a property set pattern [:foo:], \\p{foo}, or
|
|
|
|
* \\P{foo}, or \\N{name}.
|
2002-10-30 18:24:00 +00:00
|
|
|
*/
|
|
|
|
static UBool resemblesPropertyPattern(const UnicodeString& pattern,
|
|
|
|
int32_t pos);
|
|
|
|
|
2003-09-29 23:00:39 +00:00
|
|
|
static UBool resemblesPropertyPattern(RuleCharacterIterator& chars,
|
|
|
|
int32_t iterOpts);
|
|
|
|
|
2002-10-30 18:24:00 +00:00
|
|
|
/**
|
|
|
|
* Parse the given property pattern at the given parse position
|
|
|
|
* and set this UnicodeSet to the result.
|
|
|
|
*
|
|
|
|
* The original design document is out of date, but still useful.
|
|
|
|
* Ignore the property and value names:
|
2007-06-11 19:14:47 +00:00
|
|
|
* http://source.icu-project.org/repos/icu/icuhtml/trunk/design/unicodeset_properties.html
|
2002-10-30 18:24:00 +00:00
|
|
|
*
|
|
|
|
* Recognized syntax:
|
|
|
|
*
|
|
|
|
* [:foo:] [:^foo:] - white space not allowed within "[:" or ":]"
|
2004-06-15 20:52:22 +00:00
|
|
|
* \\p{foo} \\P{foo} - white space not allowed within "\\p" or "\\P"
|
|
|
|
* \\N{name} - white space not allowed within "\\N"
|
2002-10-30 18:24:00 +00:00
|
|
|
*
|
|
|
|
* Other than the above restrictions, white space is ignored. Case
|
2004-06-15 20:52:22 +00:00
|
|
|
* is ignored except in "\\p" and "\\P" and "\\N". In 'name' leading
|
2002-10-30 18:24:00 +00:00
|
|
|
* and trailing space is deleted, and internal runs of whitespace
|
|
|
|
* are collapsed to a single space.
|
|
|
|
*
|
|
|
|
* We support binary properties, enumerated properties, and the
|
|
|
|
* following non-enumerated properties:
|
|
|
|
*
|
|
|
|
* Numeric_Value
|
|
|
|
* Name
|
|
|
|
* Unicode_1_Name
|
|
|
|
*
|
|
|
|
* @param pattern the pattern string
|
|
|
|
* @param ppos on entry, the position at which to begin parsing.
|
|
|
|
* This should be one of the locations marked '^':
|
|
|
|
*
|
2004-06-15 20:52:22 +00:00
|
|
|
* [:blah:] \\p{blah} \\P{blah} \\N{name}
|
2002-10-30 18:24:00 +00:00
|
|
|
* ^ % ^ % ^ % ^ %
|
|
|
|
*
|
|
|
|
* On return, the position after the last character parsed, that is,
|
|
|
|
* the locations marked '%'. If the parse fails, ppos is returned
|
|
|
|
* unchanged.
|
|
|
|
* @return a reference to this.
|
|
|
|
*/
|
|
|
|
UnicodeSet& applyPropertyPattern(const UnicodeString& pattern,
|
|
|
|
ParsePosition& ppos,
|
|
|
|
UErrorCode &ec);
|
|
|
|
|
2003-09-29 23:00:39 +00:00
|
|
|
void applyPropertyPattern(RuleCharacterIterator& chars,
|
|
|
|
UnicodeString& rebuiltPat,
|
|
|
|
UErrorCode& ec);
|
|
|
|
|
2008-02-16 11:26:53 +00:00
|
|
|
static const UnicodeSet* getInclusions(int32_t src, UErrorCode &status);
|
|
|
|
|
2002-10-30 18:24:00 +00:00
|
|
|
/**
|
|
|
|
* A filter that returns TRUE if the given code point should be
|
|
|
|
* included in the UnicodeSet being constructed.
|
|
|
|
*/
|
|
|
|
typedef UBool (*Filter)(UChar32 codePoint, void* context);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Given a filter, set this UnicodeSet to the code points
|
|
|
|
* contained by that filter. The filter MUST be
|
|
|
|
* property-conformant. That is, if it returns value v for one
|
|
|
|
* code point, then it must return v for all affiliated code
|
|
|
|
* points, as defined by the inclusions list. See
|
2004-09-13 23:38:31 +00:00
|
|
|
* getInclusions().
|
|
|
|
* src is a UPropertySource value.
|
2002-10-30 18:24:00 +00:00
|
|
|
*/
|
|
|
|
void applyFilter(Filter filter,
|
|
|
|
void* context,
|
2004-09-13 23:38:31 +00:00
|
|
|
int32_t src,
|
2002-10-30 18:24:00 +00:00
|
|
|
UErrorCode &status);
|
|
|
|
|
|
|
|
/**
|
2006-10-03 17:41:23 +00:00
|
|
|
* Set the new pattern to cache.
|
|
|
|
*/
|
|
|
|
void setPattern(const UnicodeString& newPat);
|
|
|
|
/**
|
|
|
|
* Release existing cached pattern.
|
2002-10-30 18:24:00 +00:00
|
|
|
*/
|
2006-10-03 17:41:23 +00:00
|
|
|
void releasePattern();
|
2002-10-30 18:24:00 +00:00
|
|
|
|
2002-04-25 23:39:57 +00:00
|
|
|
friend class UnicodeSetIterator;
|
1999-12-28 23:57:50 +00:00
|
|
|
};
|
|
|
|
|
2009-03-12 00:38:53 +00:00
|
|
|
|
|
|
|
|
2000-05-18 22:08:39 +00:00
|
|
|
inline UBool UnicodeSet::operator!=(const UnicodeSet& o) const {
|
2002-04-02 02:55:31 +00:00
|
|
|
return !operator==(o);
|
1999-12-28 23:57:50 +00:00
|
|
|
}
|
|
|
|
|
2007-07-19 04:33:20 +00:00
|
|
|
inline UBool UnicodeSet::isFrozen() const {
|
|
|
|
return (UBool)(bmpSet!=NULL || stringSpan!=NULL);
|
|
|
|
}
|
|
|
|
|
2002-04-25 23:39:57 +00:00
|
|
|
inline UBool UnicodeSet::containsSome(UChar32 start, UChar32 end) const {
|
|
|
|
return !containsNone(start, end);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline UBool UnicodeSet::containsSome(const UnicodeSet& s) const {
|
|
|
|
return !containsNone(s);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline UBool UnicodeSet::containsSome(const UnicodeString& s) const {
|
|
|
|
return !containsNone(s);
|
|
|
|
}
|
|
|
|
|
2008-01-22 17:46:22 +00:00
|
|
|
inline UBool UnicodeSet::isBogus() const {
|
|
|
|
return (UBool)(fFlags & kIsBogus);
|
|
|
|
}
|
|
|
|
|
2009-03-12 00:38:53 +00:00
|
|
|
inline UnicodeSet *UnicodeSet::fromUSet(USet *uset) {
|
|
|
|
return reinterpret_cast<UnicodeSet *>(uset);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline const UnicodeSet *UnicodeSet::fromUSet(const USet *uset) {
|
|
|
|
return reinterpret_cast<const UnicodeSet *>(uset);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline USet *UnicodeSet::toUSet() {
|
|
|
|
return reinterpret_cast<USet *>(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline const USet *UnicodeSet::toUSet() const {
|
|
|
|
return reinterpret_cast<const USet *>(this);
|
|
|
|
}
|
|
|
|
|
2001-10-08 23:26:58 +00:00
|
|
|
U_NAMESPACE_END
|
|
|
|
|
1999-12-28 23:57:50 +00:00
|
|
|
#endif
|