2
***************************************************************************
3
* Copyright (C) 1999-2010, International Business Machines Corporation
4
* and others. All Rights Reserved.
5
***************************************************************************
6
* Date Name Description
7
* 10/20/99 alan Creation.
8
***************************************************************************
14
#include "unicode/unifilt.h"
15
#include "unicode/unistr.h"
16
#include "unicode/uset.h"
20
* \brief C++ API: Unicode Set
28
class UnicodeSetStringSpan;
30
class RuleCharacterIterator;
33
* A mutable set of Unicode characters and multicharacter strings. Objects of this class
34
* represent <em>character classes</em> used in regular expressions.
35
* A character specifies a subset of Unicode code points. Legal
36
* code points are U+0000 to U+10FFFF, inclusive.
38
* <p>The UnicodeSet class is not designed to be subclassed.
40
* <p><code>UnicodeSet</code> supports two APIs. The first is the
41
* <em>operand</em> API that allows the caller to modify the value of
42
* a <code>UnicodeSet</code> object. It conforms to Java 2's
43
* <code>java.util.Set</code> interface, although
44
* <code>UnicodeSet</code> does not actually implement that
45
* interface. All methods of <code>Set</code> are supported, with the
46
* modification that they take a character range or single character
47
* instead of an <code>Object</code>, and they take a
48
* <code>UnicodeSet</code> instead of a <code>Collection</code>. The
49
* operand API may be thought of in terms of boolean logic: a boolean
50
* OR is implemented by <code>add</code>, a boolean AND is implemented
51
* by <code>retain</code>, a boolean XOR is implemented by
52
* <code>complement</code> taking an argument, and a boolean NOT is
53
* implemented by <code>complement</code> with no argument. In terms
54
* of traditional set theory function names, <code>add</code> is a
55
* union, <code>retain</code> is an intersection, <code>remove</code>
56
* is an asymmetric difference, and <code>complement</code> with no
57
* argument is a set complement with respect to the superset range
58
* <code>MIN_VALUE-MAX_VALUE</code>
60
* <p>The second API is the
61
* <code>applyPattern()</code>/<code>toPattern()</code> API from the
62
* <code>java.text.Format</code>-derived classes. Unlike the
63
* methods that add characters, add categories, and control the logic
64
* of the set, the method <code>applyPattern()</code> sets all
65
* attributes of a <code>UnicodeSet</code> at once, based on a
68
* <p><b>Pattern syntax</b></p>
70
* Patterns are accepted by the constructors and the
71
* <code>applyPattern()</code> methods and returned by the
72
* <code>toPattern()</code> method. These patterns follow a syntax
73
* similar to that employed by version 8 regular expression character
74
* classes. Here are some simple examples:
76
* \htmlonly<blockquote>\endhtmlonly
79
* <td nowrap valign="top" align="left"><code>[]</code></td>
80
* <td valign="top">No characters</td>
81
* </tr><tr align="top">
82
* <td nowrap valign="top" align="left"><code>[a]</code></td>
83
* <td valign="top">The character 'a'</td>
84
* </tr><tr align="top">
85
* <td nowrap valign="top" align="left"><code>[ae]</code></td>
86
* <td valign="top">The characters 'a' and 'e'</td>
89
* <td nowrap valign="top" align="left"><code>[a-e]</code></td>
90
* <td valign="top">The characters 'a' through 'e' inclusive, in Unicode code
94
* <td nowrap valign="top" align="left"><code>[\\u4E01]</code></td>
95
* <td valign="top">The character U+4E01</td>
98
* <td nowrap valign="top" align="left"><code>[a{ab}{ac}]</code></td>
99
* <td valign="top">The character 'a' and the multicharacter strings "ab" and
100
* "ac"</td>
103
* <td nowrap valign="top" align="left"><code>[\\p{Lu}]</code></td>
104
* <td valign="top">All characters in the general category Uppercase Letter</td>
107
* \htmlonly</blockquote>\endhtmlonly
109
* Any character may be preceded by a backslash in order to remove any special
110
* meaning. White space characters, as defined by UCharacter.isWhitespace(), are
111
* ignored, unless they are escaped.
113
* <p>Property patterns specify a set of characters having a certain
114
* property as defined by the Unicode standard. Both the POSIX-like
115
* "[:Lu:]" and the Perl-like syntax "\\p{Lu}" are recognized. For a
116
* complete list of supported property patterns, see the User's Guide
118
* <a href="http://icu-project.org/userguide/unicodeSet.html">
119
* http://icu-project.org/userguide/unicodeSet.html</a>.
120
* Actual determination of property data is defined by the underlying
121
* Unicode database as implemented by UCharacter.
123
* <p>Patterns specify individual characters, ranges of characters, and
124
* Unicode property sets. When elements are concatenated, they
125
* specify their union. To complement a set, place a '^' immediately
126
* after the opening '['. Property patterns are inverted by modifying
127
* their delimiters; "[:^foo]" and "\\P{foo}". In any other location,
128
* '^' has no special meaning.
130
* <p>Ranges are indicated by placing two a '-' between two
131
* characters, as in "a-z". This specifies the range of all
132
* characters from the left to the right, in Unicode order. If the
133
* left character is greater than or equal to the
134
* right character it is a syntax error. If a '-' occurs as the first
135
* character after the opening '[' or '[^', or if it occurs as the
136
* last character before the closing ']', then it is taken as a
137
* literal. Thus "[a\-b]", "[-ab]", and "[ab-]" all indicate the same
138
* set of three characters, 'a', 'b', and '-'.
140
* <p>Sets may be intersected using the '&' operator or the asymmetric
141
* set difference may be taken using the '-' operator, for example,
142
* "[[:L:]&[\\u0000-\\u0FFF]]" indicates the set of all Unicode letters
143
* with values less than 4096. Operators ('&' and '|') have equal
144
* precedence and bind left-to-right. Thus
145
* "[[:L:]-[a-z]-[\\u0100-\\u01FF]]" is equivalent to
146
* "[[[:L:]-[a-z]]-[\\u0100-\\u01FF]]". This only really matters for
147
* difference; intersection is commutative.
150
* <tr valign=top><td nowrap><code>[a]</code><td>The set containing 'a'
151
* <tr valign=top><td nowrap><code>[a-z]</code><td>The set containing 'a'
152
* through 'z' and all letters in between, in Unicode order
153
* <tr valign=top><td nowrap><code>[^a-z]</code><td>The set containing
154
* all characters but 'a' through 'z',
155
* that is, U+0000 through 'a'-1 and 'z'+1 through U+10FFFF
156
* <tr valign=top><td nowrap><code>[[<em>pat1</em>][<em>pat2</em>]]</code>
157
* <td>The union of sets specified by <em>pat1</em> and <em>pat2</em>
158
* <tr valign=top><td nowrap><code>[[<em>pat1</em>]&[<em>pat2</em>]]</code>
159
* <td>The intersection of sets specified by <em>pat1</em> and <em>pat2</em>
160
* <tr valign=top><td nowrap><code>[[<em>pat1</em>]-[<em>pat2</em>]]</code>
161
* <td>The asymmetric difference of sets specified by <em>pat1</em> and
163
* <tr valign=top><td nowrap><code>[:Lu:] or \\p{Lu}</code>
164
* <td>The set of characters having the specified
165
* Unicode property; in
166
* this case, Unicode uppercase letters
167
* <tr valign=top><td nowrap><code>[:^Lu:] or \\P{Lu}</code>
168
* <td>The set of characters <em>not</em> having the given
172
* <p><b>Warning</b>: you cannot add an empty string ("") to a UnicodeSet.</p>
174
* <p><b>Formal syntax</b></p>
176
* \htmlonly<blockquote>\endhtmlonly
179
* <td nowrap valign="top" align="right"><code>pattern := </code></td>
180
* <td valign="top"><code>('[' '^'? item* ']') |
181
* property</code></td>
184
* <td nowrap valign="top" align="right"><code>item := </code></td>
185
* <td valign="top"><code>char | (char '-' char) | pattern-expr<br>
189
* <td nowrap valign="top" align="right"><code>pattern-expr := </code></td>
190
* <td valign="top"><code>pattern | pattern-expr pattern |
191
* pattern-expr op pattern<br>
195
* <td nowrap valign="top" align="right"><code>op := </code></td>
196
* <td valign="top"><code>'&' | '-'<br>
200
* <td nowrap valign="top" align="right"><code>special := </code></td>
201
* <td valign="top"><code>'[' | ']' | '-'<br>
205
* <td nowrap valign="top" align="right"><code>char := </code></td>
206
* <td valign="top"><em>any character that is not</em><code> special<br>
207
* | ('\' </code><em>any character</em><code>)<br>
208
* | ('\\u' hex hex hex hex)<br>
212
* <td nowrap valign="top" align="right"><code>hex := </code></td>
213
* <td valign="top"><em>any character for which
214
* </em><code>Character.digit(c, 16)</code><em>
215
* returns a non-negative result</em></td>
218
* <td nowrap valign="top" align="right"><code>property := </code></td>
219
* <td valign="top"><em>a Unicode property set pattern</em></td>
225
* <td>Legend: <table>
227
* <td nowrap valign="top"><code>a := b</code></td>
228
* <td width="20" valign="top"> </td>
229
* <td valign="top"><code>a</code> may be replaced by <code>b</code> </td>
232
* <td nowrap valign="top"><code>a?</code></td>
233
* <td valign="top"></td>
234
* <td valign="top">zero or one instance of <code>a</code><br>
238
* <td nowrap valign="top"><code>a*</code></td>
239
* <td valign="top"></td>
240
* <td valign="top">one or more instances of <code>a</code><br>
244
* <td nowrap valign="top"><code>a | b</code></td>
245
* <td valign="top"></td>
246
* <td valign="top">either <code>a</code> or <code>b</code><br>
250
* <td nowrap valign="top"><code>'a'</code></td>
251
* <td valign="top"></td>
252
* <td valign="top">the literal string between the quotes </td>
258
* \htmlonly</blockquote>\endhtmlonly
261
* - Most UnicodeSet methods do not take a UErrorCode parameter because
262
* there are usually very few opportunities for failure other than a shortage
263
* of memory, error codes in low-level C++ string methods would be inconvenient,
264
* and the error code as the last parameter (ICU convention) would prevent
265
* the use of default parameter values.
266
* Instead, such methods set the UnicodeSet into a "bogus" state
267
* (see isBogus()) if an error occurs.
272
class U_COMMON_API UnicodeSet : public UnicodeFilter {
274
int32_t len; // length of list used; 0 <= len <= capacity
275
int32_t capacity; // capacity of list
276
UChar32* list; // MUST be terminated with HIGH
277
BMPSet *bmpSet; // The set is frozen iff either bmpSet or stringSpan is not NULL.
278
UChar32* buffer; // internal buffer, may be NULL
279
int32_t bufferCapacity; // capacity of buffer
283
* The pattern representation of this set. This may not be the
284
* most economical pattern. It is the pattern supplied to
285
* applyPattern(), with variables substituted and whitespace
286
* removed. For sets constructed without applyPattern(), or
287
* modified using the non-pattern API, this string will be empty,
288
* indicating that toPattern() must generate a pattern
289
* representation from the inversion list.
292
UVector* strings; // maintained in sorted order
293
UnicodeSetStringSpan *stringSpan;
297
kIsBogus = 1 // This set is bogus (i.e. not valid)
299
uint8_t fFlags; // Bit flag (see constants above)
302
* Determine if this object contains a valid set.
303
* A bogus set has no value. It is different from an empty set.
304
* It can be used to indicate that no set value is available.
306
* @return TRUE if the set is valid, FALSE otherwise
310
inline UBool isBogus(void) const;
313
* Make this UnicodeSet object invalid.
314
* The string will test TRUE with isBogus().
316
* A bogus set has no value. It is different from an empty set.
317
* It can be used to indicate that no set value is available.
319
* This utility function is used throughout the UnicodeSet
320
* implementation to indicate that a UnicodeSet operation failed,
321
* and may be used in other functions,
322
* especially but not exclusively when such functions do not
323
* take a UErrorCode for simplicity.
334
* Minimum value that can be stored in a UnicodeSet.
340
* Maximum value that can be stored in a UnicodeSet.
346
//----------------------------------------------------------------
348
//----------------------------------------------------------------
353
* Constructs an empty set.
359
* Constructs a set containing the given range. If <code>end >
360
* start</code> then an empty set is created.
362
* @param start first character, inclusive, of range
363
* @param end last character, inclusive, of range
366
UnicodeSet(UChar32 start, UChar32 end);
369
* Constructs a set from the given pattern. See the class
370
* description for the syntax of the pattern language.
371
* @param pattern a string specifying what characters are in the set
372
* @param status returns <code>U_ILLEGAL_ARGUMENT_ERROR</code> if the pattern
373
* contains a syntax error.
376
UnicodeSet(const UnicodeString& pattern,
380
* Constructs a set from the given pattern. See the class
381
* description for the syntax of the pattern language.
382
* @param pattern a string specifying what characters are in the set
383
* @param options bitmask for options to apply to the pattern.
384
* Valid options are USET_IGNORE_SPACE and USET_CASE_INSENSITIVE.
385
* @param symbols a symbol table mapping variable names to values
386
* and stand-in characters to UnicodeSets; may be NULL
387
* @param status returns <code>U_ILLEGAL_ARGUMENT_ERROR</code> if the pattern
388
* contains a syntax error.
391
UnicodeSet(const UnicodeString& pattern,
393
const SymbolTable* symbols,
397
* Constructs a set from the given pattern. See the class description
398
* for the syntax of the pattern language.
399
* @param pattern a string specifying what characters are in the set
400
* @param pos on input, the position in pattern at which to start parsing.
401
* On output, the position after the last character parsed.
402
* @param options bitmask for options to apply to the pattern.
403
* Valid options are USET_IGNORE_SPACE and USET_CASE_INSENSITIVE.
404
* @param symbols a symbol table mapping variable names to values
405
* and stand-in characters to UnicodeSets; may be NULL
406
* @param status input-output error code
409
UnicodeSet(const UnicodeString& pattern, ParsePosition& pos,
411
const SymbolTable* symbols,
415
* Constructs a set that is identical to the given UnicodeSet.
418
UnicodeSet(const UnicodeSet& o);
424
virtual ~UnicodeSet();
427
* Assigns this object to be a copy of another.
428
* A frozen set will not be modified.
431
UnicodeSet& operator=(const UnicodeSet& o);
434
* Compares the specified object with this set for equality. Returns
435
* <tt>true</tt> if the two sets
436
* have the same size, and every member of the specified set is
437
* contained in this set (or equivalently, every member of this set is
438
* contained in the specified set).
440
* @param o set to be compared for equality with this set.
441
* @return <tt>true</tt> if the specified set is equal to this set.
444
virtual UBool operator==(const UnicodeSet& o) const;
447
* Compares the specified object with this set for equality. Returns
448
* <tt>true</tt> if the specified set is not equal to this set.
451
UBool operator!=(const UnicodeSet& o) const;
454
* Returns a copy of this object. All UnicodeFunctor objects have
455
* to support cloning in order to allow classes using
456
* UnicodeFunctors, such as Transliterator, to implement cloning.
457
* If this set is frozen, then the clone will be frozen as well.
458
* Use cloneAsThawed() for a mutable clone of a frozen set.
462
virtual UnicodeFunctor* clone() const;
465
* Returns the hash code value for this set.
467
* @return the hash code value for this set.
468
* @see Object#hashCode()
471
virtual int32_t hashCode(void) const;
474
* Get a UnicodeSet pointer from a USet
476
* @param uset a USet (the ICU plain C type for UnicodeSet)
477
* @return the corresponding UnicodeSet pointer.
481
inline static UnicodeSet *fromUSet(USet *uset);
484
* Get a UnicodeSet pointer from a const USet
486
* @param uset a const USet (the ICU plain C type for UnicodeSet)
487
* @return the corresponding UnicodeSet pointer.
491
inline static const UnicodeSet *fromUSet(const USet *uset);
494
* Produce a USet * pointer for this UnicodeSet.
495
* USet is the plain C type for UnicodeSet
497
* @return a USet pointer for this UnicodeSet
500
inline USet *toUSet();
504
* Produce a const USet * pointer for this UnicodeSet.
505
* USet is the plain C type for UnicodeSet
507
* @return a const USet pointer for this UnicodeSet
510
inline const USet * toUSet() const;
513
//----------------------------------------------------------------
515
//----------------------------------------------------------------
518
* Determines whether the set has been frozen (made immutable) or not.
519
* See the ICU4J Freezable interface for details.
520
* @return TRUE/FALSE for whether the set has been frozen
525
inline UBool isFrozen() const;
528
* Freeze the set (make it immutable).
529
* Once frozen, it cannot be unfrozen and is therefore thread-safe
530
* until it is deleted.
531
* See the ICU4J Freezable interface for details.
532
* Freezing the set may also make some operations faster, for example
533
* contains() and span().
534
* A frozen set will not be modified. (It remains frozen.)
540
UnicodeFunctor *freeze();
543
* Clone the set and make the clone mutable.
544
* See the ICU4J Freezable interface for details.
545
* @return the mutable clone
550
UnicodeFunctor *cloneAsThawed() const;
552
//----------------------------------------------------------------
554
//----------------------------------------------------------------
557
* Make this object represent the range <code>start - end</code>.
558
* If <code>end > start</code> then this object is set to an
560
* A frozen set will not be modified.
562
* @param start first character in the set, inclusive
563
* @param end last character in the set, inclusive
566
UnicodeSet& set(UChar32 start, UChar32 end);
569
* Return true if the given position, in the given pattern, appears
570
* to be the start of a UnicodeSet pattern.
573
static UBool resemblesPattern(const UnicodeString& pattern,
577
* Modifies this set to represent the set specified by the given
578
* pattern, optionally ignoring white space. See the class
579
* description for the syntax of the pattern language.
580
* A frozen set will not be modified.
581
* @param pattern a string specifying what characters are in the set
582
* @param status returns <code>U_ILLEGAL_ARGUMENT_ERROR</code> if the pattern
583
* contains a syntax error.
584
* <em> Empties the set passed before applying the pattern.</em>
585
* @return a reference to this
588
UnicodeSet& applyPattern(const UnicodeString& pattern,
592
* Modifies this set to represent the set specified by the given
593
* pattern, optionally ignoring white space. See the class
594
* description for the syntax of the pattern language.
595
* A frozen set will not be modified.
596
* @param pattern a string specifying what characters are in the set
597
* @param options bitmask for options to apply to the pattern.
598
* Valid options are USET_IGNORE_SPACE and USET_CASE_INSENSITIVE.
599
* @param symbols a symbol table mapping variable names to
600
* values and stand-ins to UnicodeSets; may be NULL
601
* @param status returns <code>U_ILLEGAL_ARGUMENT_ERROR</code> if the pattern
602
* contains a syntax error.
603
*<em> Empties the set passed before applying the pattern.</em>
604
* @return a reference to this
607
UnicodeSet& applyPattern(const UnicodeString& pattern,
609
const SymbolTable* symbols,
613
* Parses the given pattern, starting at the given position. The
614
* character at pattern.charAt(pos.getIndex()) must be '[', or the
615
* parse fails. Parsing continues until the corresponding closing
616
* ']'. If a syntax error is encountered between the opening and
617
* closing brace, the parse fails. Upon return from a successful
618
* parse, the ParsePosition is updated to point to the character
619
* following the closing ']', and a StringBuffer containing a
620
* pairs list for the parsed pattern is returned. This method calls
621
* itself recursively to parse embedded subpatterns.
622
*<em> Empties the set passed before applying the pattern.</em>
623
* A frozen set will not be modified.
625
* @param pattern the string containing the pattern to be parsed.
626
* The portion of the string from pos.getIndex(), which must be a
627
* '[', to the corresponding closing ']', is parsed.
628
* @param pos upon entry, the position at which to being parsing.
629
* The character at pattern.charAt(pos.getIndex()) must be a '['.
630
* Upon return from a successful parse, pos.getIndex() is either
631
* the character after the closing ']' of the parsed pattern, or
632
* pattern.length() if the closing ']' is the last character of
633
* the pattern string.
634
* @param options bitmask for options to apply to the pattern.
635
* Valid options are USET_IGNORE_SPACE and USET_CASE_INSENSITIVE.
636
* @param symbols a symbol table mapping variable names to
637
* values and stand-ins to UnicodeSets; may be NULL
638
* @param status returns <code>U_ILLEGAL_ARGUMENT_ERROR</code> if the pattern
639
* contains a syntax error.
640
* @return a reference to this
643
UnicodeSet& applyPattern(const UnicodeString& pattern,
646
const SymbolTable* symbols,
650
* Returns a string representation of this set. If the result of
651
* calling this function is passed to a UnicodeSet constructor, it
652
* will produce another set that is equal to this one.
653
* A frozen set will not be modified.
654
* @param result the string to receive the rules. Previous
655
* contents will be deleted.
656
* @param escapeUnprintable if TRUE then convert unprintable
657
* character to their hex escape representations, \\uxxxx or
658
* \\Uxxxxxxxx. Unprintable characters are those other than
659
* U+000A, U+0020..U+007E.
662
virtual UnicodeString& toPattern(UnicodeString& result,
663
UBool escapeUnprintable = FALSE) const;
666
* Modifies this set to contain those code points which have the given value
667
* for the given binary or enumerated property, as returned by
668
* u_getIntPropertyValue. Prior contents of this set are lost.
669
* A frozen set will not be modified.
671
* @param prop a property in the range UCHAR_BIN_START..UCHAR_BIN_LIMIT-1
672
* or UCHAR_INT_START..UCHAR_INT_LIMIT-1
673
* or UCHAR_MASK_START..UCHAR_MASK_LIMIT-1.
675
* @param value a value in the range u_getIntPropertyMinValue(prop)..
676
* u_getIntPropertyMaxValue(prop), with one exception. If prop is
677
* UCHAR_GENERAL_CATEGORY_MASK, then value should not be a UCharCategory, but
678
* rather a mask value produced by U_GET_GC_MASK(). This allows grouped
679
* categories such as [:L:] to be represented.
681
* @param ec error code input/output parameter
683
* @return a reference to this set
687
UnicodeSet& applyIntPropertyValue(UProperty prop,
692
* Modifies this set to contain those code points which have the
693
* given value for the given property. Prior contents of this
695
* A frozen set will not be modified.
697
* @param prop a property alias, either short or long. The name is matched
698
* loosely. See PropertyAliases.txt for names and a description of loose
699
* matching. If the value string is empty, then this string is interpreted
700
* as either a General_Category value alias, a Script value alias, a binary
701
* property alias, or a special ID. Special IDs are matched loosely and
702
* correspond to the following sets:
704
* "ANY" = [\\u0000-\\U0010FFFF],
705
* "ASCII" = [\\u0000-\\u007F],
706
* "Assigned" = [:^Cn:].
708
* @param value a value alias, either short or long. The name is matched
709
* loosely. See PropertyValueAliases.txt for names and a description of
710
* loose matching. In addition to aliases listed, numeric values and
711
* canonical combining classes may be expressed numerically, e.g., ("nv",
712
* "0.5") or ("ccc", "220"). The value string may also be empty.
714
* @param ec error code input/output parameter
716
* @return a reference to this set
720
UnicodeSet& applyPropertyAlias(const UnicodeString& prop,
721
const UnicodeString& value,
725
* Returns the number of elements in this set (its cardinality).
726
* Note than the elements of a set may include both individual
727
* codepoints and strings.
729
* @return the number of elements in this set (its cardinality).
732
virtual int32_t size(void) const;
735
* Returns <tt>true</tt> if this set contains no elements.
737
* @return <tt>true</tt> if this set contains no elements.
740
virtual UBool isEmpty(void) const;
743
* Returns true if this set contains the given character.
744
* This function works faster with a frozen set.
745
* @param c character to be checked for containment
746
* @return true if the test condition is met
749
virtual UBool contains(UChar32 c) const;
752
* Returns true if this set contains every character
753
* of the given range.
754
* @param start first character, inclusive, of the range
755
* @param end last character, inclusive, of the range
756
* @return true if the test condition is met
759
virtual UBool contains(UChar32 start, UChar32 end) const;
762
* Returns <tt>true</tt> if this set contains the given
763
* multicharacter string.
764
* @param s string to be checked for containment
765
* @return <tt>true</tt> if this set contains the specified string
768
UBool contains(const UnicodeString& s) const;
771
* Returns true if this set contains all the characters and strings
773
* @param c set to be checked for containment
774
* @return true if the test condition is met
777
virtual UBool containsAll(const UnicodeSet& c) const;
780
* Returns true if this set contains all the characters
781
* of the given string.
782
* @param s string containing characters to be checked for containment
783
* @return true if the test condition is met
786
UBool containsAll(const UnicodeString& s) const;
789
* Returns true if this set contains none of the characters
790
* of the given range.
791
* @param start first character, inclusive, of the range
792
* @param end last character, inclusive, of the range
793
* @return true if the test condition is met
796
UBool containsNone(UChar32 start, UChar32 end) const;
799
* Returns true if this set contains none of the characters and strings
801
* @param c set to be checked for containment
802
* @return true if the test condition is met
805
UBool containsNone(const UnicodeSet& c) const;
808
* Returns true if this set contains none of the characters
809
* of the given string.
810
* @param s string containing characters to be checked for containment
811
* @return true if the test condition is met
814
UBool containsNone(const UnicodeString& s) const;
817
* Returns true if this set contains one or more of the characters
818
* in the given range.
819
* @param start first character, inclusive, of the range
820
* @param end last character, inclusive, of the range
821
* @return true if the condition is met
824
inline UBool containsSome(UChar32 start, UChar32 end) const;
827
* Returns true if this set contains one or more of the characters
828
* and strings of the given set.
829
* @param s The set to be checked for containment
830
* @return true if the condition is met
833
inline UBool containsSome(const UnicodeSet& s) const;
836
* Returns true if this set contains one or more of the characters
837
* of the given string.
838
* @param s string containing characters to be checked for containment
839
* @return true if the condition is met
842
inline UBool containsSome(const UnicodeString& s) const;
845
* Returns the length of the initial substring of the input string which
846
* consists only of characters and strings that are contained in this set
847
* (USET_SPAN_CONTAINED, USET_SPAN_SIMPLE),
848
* or only of characters and strings that are not contained
849
* in this set (USET_SPAN_NOT_CONTAINED).
850
* See USetSpanCondition for details.
851
* Similar to the strspn() C library function.
852
* Unpaired surrogates are treated according to contains() of their surrogate code points.
853
* This function works faster with a frozen set and with a non-negative string length argument.
854
* @param s start of the string
855
* @param length of the string; can be -1 for NUL-terminated
856
* @param spanCondition specifies the containment condition
857
* @return the length of the initial substring according to the spanCondition;
858
* 0 if the start of the string does not fit the spanCondition
860
* @see USetSpanCondition
862
int32_t span(const UChar *s, int32_t length, USetSpanCondition spanCondition) const;
865
* Returns the end of the substring of the input string according to the USetSpanCondition.
866
* Same as <code>start+span(s.getBuffer()+start, s.length()-start, spanCondition)</code>
867
* after pinning start to 0<=start<=s.length().
868
* @param s the string
869
* @param start the start index in the string for the span operation
870
* @param spanCondition specifies the containment condition
871
* @return the exclusive end of the substring according to the spanCondition;
872
* the substring s.tempSubStringBetween(start, end) fulfills the spanCondition
874
* @see USetSpanCondition
876
inline int32_t span(const UnicodeString &s, int32_t start, USetSpanCondition spanCondition) const;
879
* Returns the start of the trailing substring of the input string which
880
* consists only of characters and strings that are contained in this set
881
* (USET_SPAN_CONTAINED, USET_SPAN_SIMPLE),
882
* or only of characters and strings that are not contained
883
* in this set (USET_SPAN_NOT_CONTAINED).
884
* See USetSpanCondition for details.
885
* Unpaired surrogates are treated according to contains() of their surrogate code points.
886
* This function works faster with a frozen set and with a non-negative string length argument.
887
* @param s start of the string
888
* @param length of the string; can be -1 for NUL-terminated
889
* @param spanCondition specifies the containment condition
890
* @return the start of the trailing substring according to the spanCondition;
891
* the string length if the end of the string does not fit the spanCondition
893
* @see USetSpanCondition
895
int32_t spanBack(const UChar *s, int32_t length, USetSpanCondition spanCondition) const;
898
* Returns the start of the substring of the input string according to the USetSpanCondition.
899
* Same as <code>spanBack(s.getBuffer(), limit, spanCondition)</code>
900
* after pinning limit to 0<=end<=s.length().
901
* @param s the string
902
* @param limit the exclusive-end index in the string for the span operation
903
* (use s.length() or INT32_MAX for spanning back from the end of the string)
904
* @param spanCondition specifies the containment condition
905
* @return the start of the substring according to the spanCondition;
906
* the substring s.tempSubStringBetween(start, limit) fulfills the spanCondition
908
* @see USetSpanCondition
910
inline int32_t spanBack(const UnicodeString &s, int32_t limit, USetSpanCondition spanCondition) const;
913
* Returns the length of the initial substring of the input string which
914
* consists only of characters and strings that are contained in this set
915
* (USET_SPAN_CONTAINED, USET_SPAN_SIMPLE),
916
* or only of characters and strings that are not contained
917
* in this set (USET_SPAN_NOT_CONTAINED).
918
* See USetSpanCondition for details.
919
* Similar to the strspn() C library function.
920
* Malformed byte sequences are treated according to contains(0xfffd).
921
* This function works faster with a frozen set and with a non-negative string length argument.
922
* @param s start of the string (UTF-8)
923
* @param length of the string; can be -1 for NUL-terminated
924
* @param spanCondition specifies the containment condition
925
* @return the length of the initial substring according to the spanCondition;
926
* 0 if the start of the string does not fit the spanCondition
928
* @see USetSpanCondition
930
int32_t spanUTF8(const char *s, int32_t length, USetSpanCondition spanCondition) const;
933
* Returns the start of the trailing substring of the input string which
934
* consists only of characters and strings that are contained in this set
935
* (USET_SPAN_CONTAINED, USET_SPAN_SIMPLE),
936
* or only of characters and strings that are not contained
937
* in this set (USET_SPAN_NOT_CONTAINED).
938
* See USetSpanCondition for details.
939
* Malformed byte sequences are treated according to contains(0xfffd).
940
* This function works faster with a frozen set and with a non-negative string length argument.
941
* @param s start of the string (UTF-8)
942
* @param length of the string; can be -1 for NUL-terminated
943
* @param spanCondition specifies the containment condition
944
* @return the start of the trailing substring according to the spanCondition;
945
* the string length if the end of the string does not fit the spanCondition
947
* @see USetSpanCondition
949
int32_t spanBackUTF8(const char *s, int32_t length, USetSpanCondition spanCondition) const;
952
* Implement UnicodeMatcher::matches()
955
virtual UMatchDegree matches(const Replaceable& text,
962
* Returns the longest match for s in text at the given position.
963
* If limit > start then match forward from start+1 to limit
964
* matching all characters except s.charAt(0). If limit < start,
965
* go backward starting from start-1 matching all characters
966
* except s.charAt(s.length()-1). This method assumes that the
967
* first character, text.charAt(start), matches s, so it does not
969
* @param text the text to match
970
* @param start the first character to match. In the forward
971
* direction, text.charAt(start) is matched against s.charAt(0).
972
* In the reverse direction, it is matched against
973
* s.charAt(s.length()-1).
974
* @param limit the limit offset for matching, either last+1 in
975
* the forward direction, or last-1 in the reverse direction,
976
* where last is the index of the last character to match.
977
* @return If part of s matches up to the limit, return |limit -
978
* start|. If all of s matches before reaching the limit, return
979
* s.length(). If there is a mismatch between s and text, return
982
static int32_t matchRest(const Replaceable& text,
983
int32_t start, int32_t limit,
984
const UnicodeString& s);
987
* Returns the smallest value i such that c < list[i]. Caller
988
* must ensure that c is a legal value or this method will enter
989
* an infinite loop. This method performs a binary search.
990
* @param c a character in the range MIN_VALUE..MAX_VALUE
992
* @return the smallest integer i in the range 0..len-1,
993
* inclusive, such that c < list[i]
995
int32_t findCodePoint(UChar32 c) const;
1000
* Implementation of UnicodeMatcher API. Union the set of all
1001
* characters that may be matched by this object into the given
1003
* @param toUnionTo the set into which to union the source characters
1006
virtual void addMatchSetTo(UnicodeSet& toUnionTo) const;
1009
* Returns the index of the given character within this set, where
1010
* the set is ordered by ascending code point. If the character
1011
* is not in this set, return -1. The inverse of this method is
1012
* <code>charAt()</code>.
1013
* @return an index from 0..size()-1, or -1
1016
int32_t indexOf(UChar32 c) const;
1019
* Returns the character at the given index within this set, where
1020
* the set is ordered by ascending code point. If the index is
1021
* out of range, return (UChar32)-1. The inverse of this method is
1022
* <code>indexOf()</code>.
1023
* @param index an index from 0..size()-1
1024
* @return the character at the given index, or (UChar32)-1.
1027
UChar32 charAt(int32_t index) const;
1030
* Adds the specified range to this set if it is not already
1031
* present. If this set already contains the specified range,
1032
* the call leaves this set unchanged. If <code>end > start</code>
1033
* then an empty range is added, leaving the set unchanged.
1034
* This is equivalent to a boolean logic OR, or a set UNION.
1035
* A frozen set will not be modified.
1037
* @param start first character, inclusive, of range to be added
1039
* @param end last character, inclusive, of range to be added
1043
virtual UnicodeSet& add(UChar32 start, UChar32 end);
1046
* Adds the specified character to this set if it is not already
1047
* present. If this set already contains the specified character,
1048
* the call leaves this set unchanged.
1049
* A frozen set will not be modified.
1052
UnicodeSet& add(UChar32 c);
1055
* Adds the specified multicharacter to this set if it is not already
1056
* present. If this set already contains the multicharacter,
1057
* the call leaves this set unchanged.
1058
* Thus "ch" => {"ch"}
1059
* <br><b>Warning: you cannot add an empty string ("") to a UnicodeSet.</b>
1060
* A frozen set will not be modified.
1061
* @param s the source string
1062
* @return this object, for chaining
1065
UnicodeSet& add(const UnicodeString& s);
1069
* @return a code point IF the string consists of a single one.
1070
* otherwise returns -1.
1071
* @param s string to test
1073
static int32_t getSingleCP(const UnicodeString& s);
1075
void _add(const UnicodeString& s);
1079
* Adds each of the characters in this string to the set. Thus "ch" => {"c", "h"}
1080
* If this set already any particular character, it has no effect on that character.
1081
* A frozen set will not be modified.
1082
* @param s the source string
1083
* @return this object, for chaining
1086
UnicodeSet& addAll(const UnicodeString& s);
1089
* Retains EACH of the characters in this string. Note: "ch" == {"c", "h"}
1090
* If this set already any particular character, it has no effect on that character.
1091
* A frozen set will not be modified.
1092
* @param s the source string
1093
* @return this object, for chaining
1096
UnicodeSet& retainAll(const UnicodeString& s);
1099
* Complement EACH of the characters in this string. Note: "ch" == {"c", "h"}
1100
* If this set already any particular character, it has no effect on that character.
1101
* A frozen set will not be modified.
1102
* @param s the source string
1103
* @return this object, for chaining
1106
UnicodeSet& complementAll(const UnicodeString& s);
1109
* Remove EACH of the characters in this string. Note: "ch" == {"c", "h"}
1110
* If this set already any particular character, it has no effect on that character.
1111
* A frozen set will not be modified.
1112
* @param s the source string
1113
* @return this object, for chaining
1116
UnicodeSet& removeAll(const UnicodeString& s);
1119
* Makes a set from a multicharacter string. Thus "ch" => {"ch"}
1120
* <br><b>Warning: you cannot add an empty string ("") to a UnicodeSet.</b>
1121
* @param s the source string
1122
* @return a newly created set containing the given string.
1123
* The caller owns the return object and is responsible for deleting it.
1126
static UnicodeSet* U_EXPORT2 createFrom(const UnicodeString& s);
1130
* Makes a set from each of the characters in the string. Thus "ch" => {"c", "h"}
1131
* @param s the source string
1132
* @return a newly created set containing the given characters
1133
* The caller owns the return object and is responsible for deleting it.
1136
static UnicodeSet* U_EXPORT2 createFromAll(const UnicodeString& s);
1139
* Retain only the elements in this set that are contained in the
1140
* specified range. If <code>end > start</code> then an empty range is
1141
* retained, leaving the set empty. This is equivalent to
1142
* a boolean logic AND, or a set INTERSECTION.
1143
* A frozen set will not be modified.
1145
* @param start first character, inclusive, of range to be retained
1147
* @param end last character, inclusive, of range to be retained
1151
virtual UnicodeSet& retain(UChar32 start, UChar32 end);
1155
* Retain the specified character from this set if it is present.
1156
* A frozen set will not be modified.
1159
UnicodeSet& retain(UChar32 c);
1162
* Removes the specified range from this set if it is present.
1163
* The set will not contain the specified range once the call
1164
* returns. If <code>end > start</code> then an empty range is
1165
* removed, leaving the set unchanged.
1166
* A frozen set will not be modified.
1168
* @param start first character, inclusive, of range to be removed
1170
* @param end last character, inclusive, of range to be removed
1174
virtual UnicodeSet& remove(UChar32 start, UChar32 end);
1177
* Removes the specified character from this set if it is present.
1178
* The set will not contain the specified range once the call
1180
* A frozen set will not be modified.
1183
UnicodeSet& remove(UChar32 c);
1186
* Removes the specified string from this set if it is present.
1187
* The set will not contain the specified character once the call
1189
* A frozen set will not be modified.
1190
* @param s the source string
1191
* @return this object, for chaining
1194
UnicodeSet& remove(const UnicodeString& s);
1197
* Inverts this set. This operation modifies this set so that
1198
* its value is its complement. This is equivalent to
1199
* <code>complement(MIN_VALUE, MAX_VALUE)</code>.
1200
* A frozen set will not be modified.
1203
virtual UnicodeSet& complement(void);
1206
* Complements the specified range in this set. Any character in
1207
* the range will be removed if it is in this set, or will be
1208
* added if it is not in this set. If <code>end > start</code>
1209
* then an empty range is complemented, leaving the set unchanged.
1210
* This is equivalent to a boolean logic XOR.
1211
* A frozen set will not be modified.
1213
* @param start first character, inclusive, of range to be removed
1215
* @param end last character, inclusive, of range to be removed
1219
virtual UnicodeSet& complement(UChar32 start, UChar32 end);
1222
* Complements the specified character in this set. The character
1223
* will be removed if it is in this set, or will be added if it is
1225
* A frozen set will not be modified.
1228
UnicodeSet& complement(UChar32 c);
1231
* Complement the specified string in this set.
1232
* The set will not contain the specified string once the call
1234
* <br><b>Warning: you cannot add an empty string ("") to a UnicodeSet.</b>
1235
* A frozen set will not be modified.
1236
* @param s the string to complement
1237
* @return this object, for chaining
1240
UnicodeSet& complement(const UnicodeString& s);
1243
* Adds all of the elements in the specified set to this set if
1244
* they're not already present. This operation effectively
1245
* modifies this set so that its value is the <i>union</i> of the two
1246
* sets. The behavior of this operation is unspecified if the specified
1247
* collection is modified while the operation is in progress.
1248
* A frozen set will not be modified.
1250
* @param c set whose elements are to be added to this set.
1251
* @see #add(UChar32, UChar32)
1254
virtual UnicodeSet& addAll(const UnicodeSet& c);
1257
* Retains only the elements in this set that are contained in the
1258
* specified set. In other words, removes from this set all of
1259
* its elements that are not contained in the specified set. This
1260
* operation effectively modifies this set so that its value is
1261
* the <i>intersection</i> of the two sets.
1262
* A frozen set will not be modified.
1264
* @param c set that defines which elements this set will retain.
1267
virtual UnicodeSet& retainAll(const UnicodeSet& c);
1270
* Removes from this set all of its elements that are contained in the
1271
* specified set. This operation effectively modifies this
1272
* set so that its value is the <i>asymmetric set difference</i> of
1274
* A frozen set will not be modified.
1276
* @param c set that defines which elements will be removed from
1280
virtual UnicodeSet& removeAll(const UnicodeSet& c);
1283
* Complements in this set all elements contained in the specified
1284
* set. Any character in the other set will be removed if it is
1285
* in this set, or will be added if it is not in this set.
1286
* A frozen set will not be modified.
1288
* @param c set that defines which elements will be xor'ed from
1292
virtual UnicodeSet& complementAll(const UnicodeSet& c);
1295
* Removes all of the elements from this set. This set will be
1296
* empty after this call returns.
1297
* A frozen set will not be modified.
1300
virtual UnicodeSet& clear(void);
1303
* Close this set over the given attribute. For the attribute
1304
* USET_CASE, the result is to modify this set so that:
1306
* 1. For each character or string 'a' in this set, all strings or
1307
* characters 'b' such that foldCase(a) == foldCase(b) are added
1310
* 2. For each string 'e' in the resulting set, if e !=
1311
* foldCase(e), 'e' will be removed.
1313
* Example: [aq\\u00DF{Bc}{bC}{Fi}] => [aAqQ\\u00DF\\uFB01{ss}{bc}{fi}]
1315
* (Here foldCase(x) refers to the operation u_strFoldCase, and a
1316
* == b denotes that the contents are the same, not pointer
1319
* A frozen set will not be modified.
1321
* @param attribute bitmask for attributes to close over.
1322
* Currently only the USET_CASE bit is supported. Any undefined bits
1324
* @return a reference to this set.
1327
UnicodeSet& closeOver(int32_t attribute);
1330
* Remove all strings from this set.
1332
* @return a reference to this set.
1335
virtual UnicodeSet &removeAllStrings();
1338
* Iteration method that returns the number of ranges contained in
1340
* @see #getRangeStart
1344
virtual int32_t getRangeCount(void) const;
1347
* Iteration method that returns the first character in the
1348
* specified range of this set.
1349
* @see #getRangeCount
1353
virtual UChar32 getRangeStart(int32_t index) const;
1356
* Iteration method that returns the last character in the
1357
* specified range of this set.
1358
* @see #getRangeStart
1362
virtual UChar32 getRangeEnd(int32_t index) const;
1365
* Serializes this set into an array of 16-bit integers. Serialization
1366
* (currently) only records the characters in the set; multicharacter
1367
* strings are ignored.
1369
* The array has following format (each line is one 16-bit
1372
* length = (n+2*m) | (m!=0?0x8000:0)
1373
* bmpLength = n; present if m!=0
1386
* The array starts with a header. After the header are n bmp
1387
* code points, then m supplementary code points. Either n or m
1388
* or both may be zero. n+2*m is always <= 0x7FFF.
1390
* If there are no supplementary characters (if m==0) then the
1391
* header is one 16-bit integer, 'length', with value n.
1393
* If there are supplementary characters (if m!=0) then the header
1394
* is two 16-bit integers. The first, 'length', has value
1395
* (n+2*m)|0x8000. The second, 'bmpLength', has value n.
1397
* After the header the code points are stored in ascending order.
1398
* Supplementary code points are stored as most significant 16
1399
* bits followed by least significant 16 bits.
1401
* @param dest pointer to buffer of destCapacity 16-bit integers.
1402
* May be NULL only if destCapacity is zero.
1403
* @param destCapacity size of dest, or zero. Must not be negative.
1404
* @param ec error code. Will be set to U_INDEX_OUTOFBOUNDS_ERROR
1405
* if n+2*m > 0x7FFF. Will be set to U_BUFFER_OVERFLOW_ERROR if
1406
* n+2*m+(m!=0?2:1) > destCapacity.
1407
* @return the total length of the serialized format, including
1408
* the header, that is, n+2*m+(m!=0?2:1), or 0 on error other
1409
* than U_BUFFER_OVERFLOW_ERROR.
1412
int32_t serialize(uint16_t *dest, int32_t destCapacity, UErrorCode& ec) const;
1415
* Reallocate this objects internal structures to take up the least
1416
* possible space, without changing this object's value.
1417
* A frozen set will not be modified.
1420
virtual UnicodeSet& compact();
1423
* Return the class ID for this class. This is useful only for
1424
* comparing to a return value from getDynamicClassID(). For example:
1426
* . Base* polymorphic_pointer = createPolymorphicObject();
1427
* . if (polymorphic_pointer->getDynamicClassID() ==
1428
* . Derived::getStaticClassID()) ...
1430
* @return The class ID for all objects of this class.
1433
static UClassID U_EXPORT2 getStaticClassID(void);
1436
* Implement UnicodeFunctor API.
1438
* @return The class ID for this object. All objects of a given
1439
* class have the same class ID. Objects of other classes have
1440
* different class IDs.
1443
virtual UClassID getDynamicClassID(void) const;
1447
// Private API for the USet API
1449
friend class USetAccess;
1451
int32_t getStringCount() const;
1453
const UnicodeString* getString(int32_t index) const;
1455
//----------------------------------------------------------------
1456
// RuleBasedTransliterator support
1457
//----------------------------------------------------------------
1462
* Returns <tt>true</tt> if this set contains any character whose low byte
1463
* is the given value. This is used by <tt>RuleBasedTransliterator</tt> for
1466
virtual UBool matchesIndexValue(uint8_t v) const;
1470
//----------------------------------------------------------------
1471
// Implementation: Clone as thawed (see ICU4J Freezable)
1472
//----------------------------------------------------------------
1474
UnicodeSet(const UnicodeSet& o, UBool /* asThawed */);
1476
//----------------------------------------------------------------
1477
// Implementation: Pattern parsing
1478
//----------------------------------------------------------------
1480
void applyPattern(RuleCharacterIterator& chars,
1481
const SymbolTable* symbols,
1482
UnicodeString& rebuiltPat,
1486
//----------------------------------------------------------------
1487
// Implementation: Utility methods
1488
//----------------------------------------------------------------
1490
void ensureCapacity(int32_t newLen, UErrorCode& ec);
1492
void ensureBufferCapacity(int32_t newLen, UErrorCode& ec);
1494
void swapBuffers(void);
1496
UBool allocateStrings(UErrorCode &status);
1498
UnicodeString& _toPattern(UnicodeString& result,
1499
UBool escapeUnprintable) const;
1501
UnicodeString& _generatePattern(UnicodeString& result,
1502
UBool escapeUnprintable) const;
1504
static void _appendToPat(UnicodeString& buf, const UnicodeString& s, UBool escapeUnprintable);
1506
static void _appendToPat(UnicodeString& buf, UChar32 c, UBool escapeUnprintable);
1508
//----------------------------------------------------------------
1509
// Implementation: Fundamental operators
1510
//----------------------------------------------------------------
1512
void exclusiveOr(const UChar32* other, int32_t otherLen, int8_t polarity);
1514
void add(const UChar32* other, int32_t otherLen, int8_t polarity);
1516
void retain(const UChar32* other, int32_t otherLen, int8_t polarity);
1519
* Return true if the given position, in the given pattern, appears
1520
* to be the start of a property set pattern [:foo:], \\p{foo}, or
1521
* \\P{foo}, or \\N{name}.
1523
static UBool resemblesPropertyPattern(const UnicodeString& pattern,
1526
static UBool resemblesPropertyPattern(RuleCharacterIterator& chars,
1530
* Parse the given property pattern at the given parse position
1531
* and set this UnicodeSet to the result.
1533
* The original design document is out of date, but still useful.
1534
* Ignore the property and value names:
1535
* http://source.icu-project.org/repos/icu/icuhtml/trunk/design/unicodeset_properties.html
1537
* Recognized syntax:
1539
* [:foo:] [:^foo:] - white space not allowed within "[:" or ":]"
1540
* \\p{foo} \\P{foo} - white space not allowed within "\\p" or "\\P"
1541
* \\N{name} - white space not allowed within "\\N"
1543
* Other than the above restrictions, white space is ignored. Case
1544
* is ignored except in "\\p" and "\\P" and "\\N". In 'name' leading
1545
* and trailing space is deleted, and internal runs of whitespace
1546
* are collapsed to a single space.
1548
* We support binary properties, enumerated properties, and the
1549
* following non-enumerated properties:
1555
* @param pattern the pattern string
1556
* @param ppos on entry, the position at which to begin parsing.
1557
* This should be one of the locations marked '^':
1559
* [:blah:] \\p{blah} \\P{blah} \\N{name}
1562
* On return, the position after the last character parsed, that is,
1563
* the locations marked '%'. If the parse fails, ppos is returned
1565
* @return a reference to this.
1567
UnicodeSet& applyPropertyPattern(const UnicodeString& pattern,
1568
ParsePosition& ppos,
1571
void applyPropertyPattern(RuleCharacterIterator& chars,
1572
UnicodeString& rebuiltPat,
1575
static const UnicodeSet* getInclusions(int32_t src, UErrorCode &status);
1578
* A filter that returns TRUE if the given code point should be
1579
* included in the UnicodeSet being constructed.
1581
typedef UBool (*Filter)(UChar32 codePoint, void* context);
1584
* Given a filter, set this UnicodeSet to the code points
1585
* contained by that filter. The filter MUST be
1586
* property-conformant. That is, if it returns value v for one
1587
* code point, then it must return v for all affiliated code
1588
* points, as defined by the inclusions list. See
1590
* src is a UPropertySource value.
1592
void applyFilter(Filter filter,
1595
UErrorCode &status);
1598
* Set the new pattern to cache.
1600
void setPattern(const UnicodeString& newPat);
1602
* Release existing cached pattern.
1604
void releasePattern();
1606
friend class UnicodeSetIterator;
1611
inline UBool UnicodeSet::operator!=(const UnicodeSet& o) const {
1612
return !operator==(o);
1615
inline UBool UnicodeSet::isFrozen() const {
1616
return (UBool)(bmpSet!=NULL || stringSpan!=NULL);
1619
inline UBool UnicodeSet::containsSome(UChar32 start, UChar32 end) const {
1620
return !containsNone(start, end);
1623
inline UBool UnicodeSet::containsSome(const UnicodeSet& s) const {
1624
return !containsNone(s);
1627
inline UBool UnicodeSet::containsSome(const UnicodeString& s) const {
1628
return !containsNone(s);
1631
inline UBool UnicodeSet::isBogus() const {
1632
return (UBool)(fFlags & kIsBogus);
1635
inline UnicodeSet *UnicodeSet::fromUSet(USet *uset) {
1636
return reinterpret_cast<UnicodeSet *>(uset);
1639
inline const UnicodeSet *UnicodeSet::fromUSet(const USet *uset) {
1640
return reinterpret_cast<const UnicodeSet *>(uset);
1643
inline USet *UnicodeSet::toUSet() {
1644
return reinterpret_cast<USet *>(this);
1647
inline const USet *UnicodeSet::toUSet() const {
1648
return reinterpret_cast<const USet *>(this);
1651
inline int32_t UnicodeSet::span(const UnicodeString &s, int32_t start, USetSpanCondition spanCondition) const {
1652
int32_t sLength=s.length();
1655
} else if(start>sLength) {
1658
return start+span(s.getBuffer()+start, sLength-start, spanCondition);
1661
inline int32_t UnicodeSet::spanBack(const UnicodeString &s, int32_t limit, USetSpanCondition spanCondition) const {
1662
int32_t sLength=s.length();
1665
} else if(limit>sLength) {
1668
return spanBack(s.getBuffer(), limit, spanCondition);