ICU4C 79
Loading...
Searching...
No Matches
uniset.h
Go to the documentation of this file.
1// © 2016 and later: Unicode, Inc. and others.
2// License & terms of use: http://www.unicode.org/copyright.html
3/*
4***************************************************************************
5* Copyright (C) 1999-2016, International Business Machines Corporation
6* and others. All Rights Reserved.
7***************************************************************************
8* Date Name Description
9* 10/20/99 alan Creation.
10***************************************************************************
11*/
12
13#ifndef UNICODESET_H
14#define UNICODESET_H
15
16#include "unicode/utypes.h"
17
18#if U_SHOW_CPLUSPLUS_API
19
20#include "unicode/ucpmap.h"
21#include "unicode/unifilt.h"
22#include "unicode/unistr.h"
23#include "unicode/uset.h"
24
29
30U_NAMESPACE_BEGIN
31
32// Forward Declarations.
33class BMPSet;
34class ParsePosition;
35class RBBIRuleScanner;
36class SymbolTable;
37class UnicodeSetStringSpan;
38class UVector;
39class RuleCharacterIterator;
40
176private:
181 static constexpr int32_t INITIAL_CAPACITY = 25;
182 // fFlags constant
183 static constexpr uint8_t kIsBogus = 1; // This set is bogus (i.e. not valid)
184
185 UChar32* list = stackList; // MUST be terminated with HIGH
186 int32_t capacity = INITIAL_CAPACITY; // capacity of list
187 int32_t len = 1; // length of list used; 1 <= len <= capacity
188 uint8_t fFlags = 0; // Bit flag (see constants above)
189
190 BMPSet *bmpSet = nullptr; // The set is frozen iff either bmpSet or stringSpan is not nullptr.
191 UChar32* buffer = nullptr; // internal buffer, may be nullptr
192 int32_t bufferCapacity = 0; // capacity of buffer
193
203 char16_t *pat = nullptr;
204 int32_t patLen = 0;
205
206 UVector* strings_ = nullptr; // maintained in sorted order
207 UnicodeSetStringSpan *stringSpan = nullptr;
208
214 UChar32 stackList[INITIAL_CAPACITY];
215
216public:
226 inline UBool isBogus() const;
227
245
246public:
247
248 enum {
254
259 MAX_VALUE = 0x10ffff
260 };
261
262 //----------------------------------------------------------------
263 // Constructors &c
264 //----------------------------------------------------------------
265
266public:
267
273
283
284#ifndef U_HIDE_INTERNAL_API
289 kSerialized /* result of serialize() */
290 };
291
302 UnicodeSet(const uint16_t buffer[], int32_t bufferLen,
303 ESerialization serialization, UErrorCode &status);
304#endif /* U_HIDE_INTERNAL_API */
305
314 UnicodeSet(const UnicodeString& pattern,
315 UErrorCode& status);
316
317#ifndef U_HIDE_INTERNAL_API
332 UnicodeSet(const UnicodeString& pattern,
333 uint32_t options,
334 const SymbolTable* symbols,
335 UErrorCode& status);
336#endif /* U_HIDE_INTERNAL_API */
337
354 uint32_t options,
355 const SymbolTable* symbols,
356 UErrorCode& status);
357
363
368 virtual ~UnicodeSet();
369
375 UnicodeSet& operator=(const UnicodeSet& o) U_LIFETIME_BOUND;
376
388 bool operator==(const UnicodeSet& o) const;
389
395 inline bool operator!=(const UnicodeSet& o) const;
396
406 virtual UnicodeSet* clone() const override;
407
415 int32_t hashCode() const;
416
425 inline static UnicodeSet* fromUSet(USet* uset U_LIFETIME_BOUND);
426
435 inline static const UnicodeSet* fromUSet(const USet* uset U_LIFETIME_BOUND);
436
444 inline USet* toUSet() U_LIFETIME_BOUND;
445
453 inline const USet* toUSet() const U_LIFETIME_BOUND;
454
455
456 //----------------------------------------------------------------
457 // Freezable API
458 //----------------------------------------------------------------
459
468 inline UBool isFrozen() const;
469
483 UnicodeSet* freeze() U_LIFETIME_BOUND;
484
494
495 //----------------------------------------------------------------
496 // Public API
497 //----------------------------------------------------------------
498
508 UnicodeSet& set(UChar32 start, UChar32 end) U_LIFETIME_BOUND;
509
515 static UBool resemblesPattern(const UnicodeString& pattern,
516 int32_t pos);
517
530 UnicodeSet& applyPattern(const UnicodeString& pattern, UErrorCode& status) U_LIFETIME_BOUND;
531
532#ifndef U_HIDE_INTERNAL_API
552 uint32_t options,
553 const SymbolTable* symbols,
554 UErrorCode& status) U_LIFETIME_BOUND;
555#endif /* U_HIDE_INTERNAL_API */
556
591 ParsePosition& pos,
592 uint32_t options,
593 const SymbolTable* symbols,
594 UErrorCode& status) U_LIFETIME_BOUND;
595
609 virtual UnicodeString& toPattern(UnicodeString& result U_LIFETIME_BOUND,
610 UBool escapeUnprintable = false) const override;
611
635 int32_t value,
636 UErrorCode& ec) U_LIFETIME_BOUND;
637
668 const UnicodeString& value,
669 UErrorCode& ec) U_LIFETIME_BOUND;
670
683 int32_t size() const;
684
691 UBool isEmpty() const;
692
698
706 virtual UBool contains(UChar32 c) const override;
707
717
725 UBool contains(const UnicodeString& s) const;
726
734 UBool containsAll(const UnicodeSet& c) const;
735
744
754
763
772
781 inline UBool containsSome(UChar32 start, UChar32 end) const;
782
790 inline UBool containsSome(const UnicodeSet& s) const;
791
799 inline UBool containsSome(const UnicodeString& s) const;
800
819 int32_t span(const char16_t *s, int32_t length, USetSpanCondition spanCondition) const;
820
833 inline int32_t span(const UnicodeString &s, int32_t start, USetSpanCondition spanCondition) const;
834
852 int32_t spanBack(const char16_t *s, int32_t length, USetSpanCondition spanCondition) const;
853
867 inline int32_t spanBack(const UnicodeString &s, int32_t limit, USetSpanCondition spanCondition) const;
868
887 int32_t spanUTF8(const char *s, int32_t length, USetSpanCondition spanCondition) const;
888
906 int32_t spanBackUTF8(const char *s, int32_t length, USetSpanCondition spanCondition) const;
907
913 int32_t& offset,
914 int32_t limit,
915 UBool incremental) override;
916
917private:
940 static int32_t matchRest(const Replaceable& text,
941 int32_t start, int32_t limit,
942 const UnicodeString& s);
943
953 int32_t findCodePoint(UChar32 c) const;
954
955public:
956
964 virtual void addMatchSetTo(UnicodeSet& toUnionTo) const override;
965
974 int32_t indexOf(UChar32 c) const;
975
991 UChar32 charAt(int32_t index) const;
992
1010 inline U_HEADER_NESTED_NAMESPACE::USetCodePoints codePoints() const U_LIFETIME_BOUND {
1011 return U_HEADER_NESTED_NAMESPACE::USetCodePoints(toUSet());
1012 }
1013
1036 inline U_HEADER_NESTED_NAMESPACE::USetRanges ranges() const U_LIFETIME_BOUND {
1037 return U_HEADER_NESTED_NAMESPACE::USetRanges(toUSet());
1038 }
1039
1060 inline U_HEADER_NESTED_NAMESPACE::USetStrings strings() const U_LIFETIME_BOUND {
1061 return U_HEADER_NESTED_NAMESPACE::USetStrings(toUSet());
1062 }
1063
1088 inline U_HEADER_NESTED_NAMESPACE::USetElementIterator begin() const U_LIFETIME_BOUND {
1089 return U_HEADER_NESTED_NAMESPACE::USetElements(toUSet()).begin();
1090 }
1091
1100 inline U_HEADER_NESTED_NAMESPACE::USetElementIterator end() const U_LIFETIME_BOUND {
1101 return U_HEADER_NESTED_NAMESPACE::USetElements(toUSet()).end();
1102 }
1103
1118 UnicodeSet& add(UChar32 start, UChar32 end) U_LIFETIME_BOUND;
1119
1130 UnicodeSet& add(UChar32 c) U_LIFETIME_BOUND;
1131
1143 UnicodeSet& add(const UnicodeString& s) U_LIFETIME_BOUND;
1144
1145 private:
1151 static int32_t getSingleCP(const UnicodeString& s);
1152
1153 void _add(const UnicodeString& s);
1154
1155 public:
1164 UnicodeSet& addAll(const UnicodeString& s) U_LIFETIME_BOUND;
1165
1173 UnicodeSet& retainAll(const UnicodeString& s) U_LIFETIME_BOUND;
1174
1182 UnicodeSet& complementAll(const UnicodeString& s) U_LIFETIME_BOUND;
1183
1191 UnicodeSet& removeAll(const UnicodeString& s) U_LIFETIME_BOUND;
1192
1201 static UnicodeSet* U_EXPORT2 createFrom(const UnicodeString& s);
1202
1203
1211 static UnicodeSet* U_EXPORT2 createFromAll(const UnicodeString& s);
1212
1224 UnicodeSet& retain(UChar32 start, UChar32 end) U_LIFETIME_BOUND;
1225
1226
1235 UnicodeSet& retain(UChar32 c) U_LIFETIME_BOUND;
1236
1247 UnicodeSet& retain(const UnicodeString& s) U_LIFETIME_BOUND;
1248
1262 UnicodeSet& remove(UChar32 start, UChar32 end) U_LIFETIME_BOUND;
1263
1274 UnicodeSet& remove(UChar32 c) U_LIFETIME_BOUND;
1275
1285 UnicodeSet& remove(const UnicodeString& s) U_LIFETIME_BOUND;
1286
1299 UnicodeSet& complement() U_LIFETIME_BOUND;
1300
1313 UnicodeSet& complement(UChar32 start, UChar32 end) U_LIFETIME_BOUND;
1314
1325 UnicodeSet& complement(UChar32 c) U_LIFETIME_BOUND;
1326
1336 UnicodeSet& complement(const UnicodeString& s) U_LIFETIME_BOUND;
1337
1350 UnicodeSet& addAll(const UnicodeSet& c) U_LIFETIME_BOUND;
1351
1363 UnicodeSet& retainAll(const UnicodeSet& c) U_LIFETIME_BOUND;
1364
1376 UnicodeSet& removeAll(const UnicodeSet& c) U_LIFETIME_BOUND;
1377
1388 UnicodeSet& complementAll(const UnicodeSet& c) U_LIFETIME_BOUND;
1389
1396 UnicodeSet& clear() U_LIFETIME_BOUND;
1397
1425 UnicodeSet& closeOver(int32_t attribute) U_LIFETIME_BOUND;
1426
1433 UnicodeSet& removeAllStrings() U_LIFETIME_BOUND;
1434
1442 int32_t getRangeCount() const;
1443
1451 UChar32 getRangeStart(int32_t index) const;
1452
1460 UChar32 getRangeEnd(int32_t index) const;
1461
1510 int32_t serialize(uint16_t *dest, int32_t destCapacity, UErrorCode& ec) const;
1511
1518 UnicodeSet& compact() U_LIFETIME_BOUND;
1519
1531 static UClassID U_EXPORT2 getStaticClassID();
1532
1541 virtual UClassID getDynamicClassID() const override;
1542
1543 private:
1544
1545 // Private API for the USet API
1546
1547 friend class USetAccess;
1548
1549 const UnicodeString* getString(int32_t index) const U_LIFETIME_BOUND;
1550
1551 //----------------------------------------------------------------
1552 // RuleBasedTransliterator support
1553 //----------------------------------------------------------------
1554
1555private:
1556
1562 virtual UBool matchesIndexValue(uint8_t v) const override;
1563
1564private:
1565 friend class RBBIRuleScanner;
1566
1567 //----------------------------------------------------------------
1568 // Implementation: Clone as thawed (see ICU4J Freezable)
1569 //----------------------------------------------------------------
1570
1571 UnicodeSet(const UnicodeSet& o, UBool /* asThawed */);
1572 UnicodeSet& copyFrom(const UnicodeSet& o, UBool asThawed) U_LIFETIME_BOUND;
1573
1574 //----------------------------------------------------------------
1575 // Implementation: Pattern parsing
1576 //----------------------------------------------------------------
1577
1578 void applyPatternIgnoreSpace(const UnicodeString& pattern,
1579 ParsePosition& pos,
1580 const SymbolTable* symbols,
1581 UErrorCode& status);
1582
1583 void applyPattern(const UnicodeString &pattern,
1584 const ParsePosition& parsePosition,
1585 RuleCharacterIterator &chars,
1586 const SymbolTable *symbols,
1587 UnicodeString &rebuiltPat,
1588 uint32_t options,
1589 UnicodeSet &(UnicodeSet::*caseClosure)(int32_t attribute),
1590 UErrorCode &ec);
1591
1592 // Recursive-descent predictive parsing. These functions parse the syntactic categories
1593 // matching their name in the base grammar of PD UTR #56 (before the highlighted changes are
1594 // applied).
1595 // See https://www.unicode.org/reports/tr61/tr61-1.html#Set-Operations.
1596 // `parseUnicodeSet` clears `*this` and makes it represent the parsed UnicodeSet; all other functions
1597 // add the set represented by the parsed construct to `*this`.
1598
1599 class Lexer;
1600
1601 static UnicodeSet parseUnicodeSet(Lexer &lexer,
1602 UnicodeString &rebuiltPat,
1603 uint32_t options,
1604 UnicodeSet &(UnicodeSet::*caseClosure)(int32_t attribute),
1605 int32_t depth,
1606 UErrorCode &ec);
1607
1608 static UnicodeSet parseContent(Lexer &lexer,
1609 UnicodeString &rebuiltPat,
1610 uint32_t options,
1611 UnicodeSet &(UnicodeSet::*caseClosure)(int32_t attribute),
1612 int32_t depth,
1613 bool &containsSetOperation,
1614 UErrorCode &ec);
1615
1616 void parseMutation(Lexer &lexer,
1617 UnicodeString &rebuiltPat,
1618 uint32_t options,
1619 UnicodeSet &(UnicodeSet::*caseClosure)(int32_t attribute),
1620 int32_t depth,
1621 bool &containsSetOperation,
1622 UErrorCode &ec);
1623
1624 void parseSetOperations(Lexer &lexer,
1625 UnicodeString &rebuiltPat,
1626 uint32_t options,
1627 UnicodeSet &(UnicodeSet::*caseClosure)(int32_t attribute),
1628 int32_t depth,
1629 UErrorCode &ec);
1630
1631 static UnicodeSet parseElements(Lexer &lexer,
1632 UnicodeString &rebuiltPat,
1633 UErrorCode &ec);
1634
1635
1636 void closeOverCaseInsensitive(bool simple);
1637 void closeOverAddCaseMappings();
1638
1639 //----------------------------------------------------------------
1640 // Implementation: Utility methods
1641 //----------------------------------------------------------------
1642
1643 static int32_t nextCapacity(int32_t minCapacity);
1644
1645 bool ensureCapacity(int32_t newLen);
1646
1647 bool ensureBufferCapacity(int32_t newLen);
1648
1649 void swapBuffers();
1650
1651 UBool allocateStrings(UErrorCode &status);
1652 int32_t stringsSize() const;
1653 UBool stringsContains(const UnicodeString &s) const;
1654
1655 UnicodeString& _toPattern(UnicodeString& result U_LIFETIME_BOUND,
1656 UBool escapeUnprintable) const;
1657
1658 UnicodeString& _generatePattern(UnicodeString& result U_LIFETIME_BOUND,
1659 UBool escapeUnprintable) const;
1660
1661 static void _appendToPat(UnicodeString& buf, const UnicodeString& s, UBool escapeUnprintable);
1662
1663 static void _appendToPat(UnicodeString& buf, UChar32 c, UBool escapeUnprintable);
1664
1665 static void _appendToPat(UnicodeString &result, UChar32 start, UChar32 end,
1666 UBool escapeUnprintable);
1667
1668 //----------------------------------------------------------------
1669 // Implementation: Fundamental operators
1670 //----------------------------------------------------------------
1671
1672 void exclusiveOr(const UChar32* other, int32_t otherLen, int8_t polarity);
1673
1674 void add(const UChar32* other, int32_t otherLen, int8_t polarity);
1675
1676 void retain(const UChar32* other, int32_t otherLen, int8_t polarity);
1677
1683 static UBool resemblesPropertyPattern(const UnicodeString& pattern,
1684 int32_t pos);
1685
1725 UnicodeSet& applyPropertyPattern(const UnicodeString& pattern,
1726 ParsePosition& ppos,
1727 UErrorCode& ec) U_LIFETIME_BOUND;
1728
1733 typedef UBool (*Filter)(UChar32 codePoint, void* context);
1734
1744 void applyFilter(Filter filter,
1745 void* context,
1746 const UnicodeSet* inclusions,
1747 UErrorCode &status);
1748
1752 void setPattern(const UnicodeString& newPat) {
1753 setPattern(newPat.getBuffer(), newPat.length());
1754 }
1755 void setPattern(const char16_t *newPat, int32_t newPatLen);
1759 void releasePattern();
1760
1761 friend class UnicodeSetIterator;
1762};
1763
1764
1765
1766inline bool UnicodeSet::operator!=(const UnicodeSet& o) const {
1767 return !operator==(o);
1768}
1769
1771 return bmpSet != nullptr || stringSpan != nullptr;
1772}
1773
1775 return !containsNone(start, end);
1776}
1777
1779 return !containsNone(s);
1780}
1781
1783 return !containsNone(s);
1784}
1785
1787 return fFlags & kIsBogus;
1788}
1789
1790inline UnicodeSet* UnicodeSet::fromUSet(USet* uset U_LIFETIME_BOUND) {
1791 return reinterpret_cast<UnicodeSet *>(uset);
1792}
1793
1794inline const UnicodeSet* UnicodeSet::fromUSet(const USet* uset U_LIFETIME_BOUND) {
1795 return reinterpret_cast<const UnicodeSet *>(uset);
1796}
1797
1798inline USet* UnicodeSet::toUSet() U_LIFETIME_BOUND {
1799 return reinterpret_cast<USet*>(this);
1800}
1801
1802inline const USet* UnicodeSet::toUSet() const U_LIFETIME_BOUND {
1803 return reinterpret_cast<const USet *>(this);
1804}
1805
1806inline int32_t UnicodeSet::span(const UnicodeString &s, int32_t start, USetSpanCondition spanCondition) const {
1807 int32_t sLength=s.length();
1808 if(start<0) {
1809 start=0;
1810 } else if(start>sLength) {
1811 start=sLength;
1812 }
1813 return start+span(s.getBuffer()+start, sLength-start, spanCondition);
1814}
1815
1816inline int32_t UnicodeSet::spanBack(const UnicodeString &s, int32_t limit, USetSpanCondition spanCondition) const {
1817 int32_t sLength=s.length();
1818 if(limit<0) {
1819 limit=0;
1820 } else if(limit>sLength) {
1821 limit=sLength;
1822 }
1823 return spanBack(s.getBuffer(), limit, spanCondition);
1824}
1825
1826U_NAMESPACE_END
1827
1828#endif /* U_SHOW_CPLUSPLUS_API */
1829
1830#endif
ParsePosition is a simple class used by Format and its subclasses to keep track of the current positi...
Definition parsepos.h:52
Replaceable is an abstract base class representing a string of characters that supports the replaceme...
Definition rep.h:77
An interface that defines both lookup protocol and parsing of symbolic names.
Definition symtable.h:59
UnicodeFilter defines a protocol for selecting a subset of the full range (U+0000 to U+10FFFF) of Uni...
Definition unifilt.h:65
UnicodeSetIterator iterates over the contents of a UnicodeSet.
Definition usetiter.h:67
U_HEADER_NESTED_NAMESPACE::USetStrings strings() const
Returns a C++ "range" for iterating over the empty and multi-character strings of this set.
Definition uniset.h:1060
UnicodeSet & operator=(const UnicodeSet &o)
Assigns this object to be a copy of another.
UnicodeSet & addAll(const UnicodeString &s)
Adds each of the characters in this string to the set.
UnicodeSet()
Constructs an empty set.
static UnicodeSet * fromUSet(USet *uset)
Get a UnicodeSet pointer from a USet.
Definition uniset.h:1790
int32_t spanBackUTF8(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...
UChar32 getRangeEnd(int32_t index) const
Iteration method that returns the last character in the specified range of this set.
UBool isBogus() const
Determine if this object contains a valid set.
Definition uniset.h:1786
int32_t size() const
Returns the number of elements in this set (its cardinality).
UnicodeSet(UChar32 start, UChar32 end)
Constructs a set containing the given range.
static UnicodeSet * createFromAll(const UnicodeString &s)
Makes a set from each of the characters in the string.
int32_t spanUTF8(const char *s, int32_t length, USetSpanCondition spanCondition) const
Returns the length of the initial substring of the input string which consists only of characters and...
UnicodeSet & complementAll(const UnicodeString &s)
Complement EACH of the characters in this string.
@ MIN_VALUE
Minimum value that can be stored in a UnicodeSet.
Definition uniset.h:253
@ MAX_VALUE
Maximum value that can be stored in a UnicodeSet.
Definition uniset.h:259
void setToBogus()
Make this UnicodeSet object invalid.
virtual UnicodeSet * clone() const override
Returns a copy of this object.
UnicodeSet & applyPropertyAlias(const UnicodeString &prop, const UnicodeString &value, UErrorCode &ec)
Modifies this set to contain those code points which have the given value for the given property.
virtual UClassID getDynamicClassID() const override
Implement UnicodeFunctor API.
int32_t hashCode() const
Returns the hash code value for this set.
UnicodeSet & applyPattern(const UnicodeString &pattern, UErrorCode &status)
Modifies this set to represent the set specified by the given pattern, ignoring Unicode Pattern_White...
virtual void addMatchSetTo(UnicodeSet &toUnionTo) const override
Implementation of UnicodeMatcher API.
UnicodeSet & add(const UnicodeString &s)
Adds the specified multicharacter to this set if it is not already present.
UnicodeSet & clear()
Removes all of the elements from this set.
UBool isFrozen() const
Determines whether the set has been frozen (made immutable) or not.
Definition uniset.h:1770
UnicodeSet & applyPattern(const UnicodeString &pattern, uint32_t options, const SymbolTable *symbols, UErrorCode &status)
Modifies this set to represent the set specified by the given pattern, optionally ignoring Unicode Pa...
UnicodeSet * cloneAsThawed() const
Clone the set and make the clone mutable.
int32_t indexOf(UChar32 c) const
Returns the index of the given character within this set, where the set is ordered by ascending code ...
U_HEADER_NESTED_NAMESPACE::USetCodePoints codePoints() const
Returns a C++ "range" for iterating over the code points of this set.
Definition uniset.h:1010
UnicodeSet & closeOver(int32_t attribute)
Close this set over the given attribute.
U_HEADER_NESTED_NAMESPACE::USetElementIterator end() const
Definition uniset.h:1100
UnicodeSet(const UnicodeString &pattern, ParsePosition &pos, uint32_t options, const SymbolTable *symbols, UErrorCode &status)
Constructs a set from the given pattern.
UnicodeSet & compact()
Reallocate this objects internal structures to take up the least possible space, without changing thi...
U_HEADER_NESTED_NAMESPACE::USetElementIterator begin() const
Returns a C++ iterator for iterating over all of the elements of this set.
Definition uniset.h:1088
U_HEADER_NESTED_NAMESPACE::USetRanges ranges() const
Returns a C++ "range" for iterating over the code point ranges of this set.
Definition uniset.h:1036
UBool containsNone(const UnicodeString &s) const
Returns true if this set contains none of the characters of the given string.
UnicodeSet(const UnicodeSet &o)
Constructs a set that is identical to the given UnicodeSet.
static UBool resemblesPattern(const UnicodeString &pattern, int32_t pos)
Return true if the given position, in the given pattern, appears to be the start of a UnicodeSet patt...
virtual ~UnicodeSet()
Destructs the set.
UnicodeSet & retain(UChar32 c)
Retain the specified character from this set if it is present.
UnicodeSet & add(UChar32 start, UChar32 end)
Adds the specified range to this set if it is not already present.
int32_t span(const char16_t *s, int32_t length, USetSpanCondition spanCondition) const
Returns the length of the initial substring of the input string which consists only of characters and...
UnicodeSet & retainAll(const UnicodeString &s)
Retains EACH of the characters in this string.
UChar32 charAt(int32_t index) const
Returns the character at the given index within this set, where the set is ordered by ascending code ...
static UClassID getStaticClassID()
Return the class ID for this class.
UBool containsNone(UChar32 start, UChar32 end) const
Returns true if this set contains none of the characters of the given range.
UBool containsAll(const UnicodeString &s) const
Returns true if this set contains all the characters of the given string.
UnicodeSet & removeAll(const UnicodeString &s)
Remove EACH of the characters in this string.
int32_t serialize(uint16_t *dest, int32_t destCapacity, UErrorCode &ec) const
Serializes this set into an array of 16-bit integers.
UnicodeSet & set(UChar32 start, UChar32 end)
Make this object represent the range start - end.
UBool contains(const UnicodeString &s) const
Returns true if this set contains the given multicharacter string.
UMatchDegree matches(const Replaceable &text, int32_t &offset, int32_t limit, UBool incremental) override
Implement UnicodeMatcher::matches().
static UnicodeSet * createFrom(const UnicodeString &s)
Makes a set from a multicharacter string.
bool operator==(const UnicodeSet &o) const
Compares the specified object with this set for equality.
UnicodeSet(const UnicodeString &pattern, UErrorCode &status)
Constructs a set from the given pattern.
UBool hasStrings() const
int32_t getRangeCount() const
Iteration method that returns the number of ranges contained in this set.
UnicodeSet & remove(UChar32 c)
Removes the specified character from this set if it is present.
virtual UnicodeString & toPattern(UnicodeString &result, UBool escapeUnprintable=false) const override
Returns a string representation of this set.
UChar32 getRangeStart(int32_t index) const
Iteration method that returns the first character in the specified range of this set.
UnicodeSet & add(UChar32 c)
Adds the specified character to this set if it is not already present.
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 binary or enu...
int32_t spanBack(const char16_t *s, int32_t length, USetSpanCondition spanCondition) const
Returns the start of the trailing substring of the input string which consists only of characters and...
UBool isEmpty() const
Returns true if this set contains no elements.
UnicodeSet & removeAllStrings()
Remove all strings from this set.
UnicodeSet & remove(const UnicodeString &s)
Removes the specified string from this set if it is present.
UBool containsAll(const UnicodeSet &c) const
Returns true if this set contains all the characters and strings of the given set.
UnicodeSet & complement()
This is equivalent to complement(MIN_VALUE, MAX_VALUE).
bool operator!=(const UnicodeSet &o) const
Compares the specified object with this set for equality.
Definition uniset.h:1766
UnicodeSet * freeze()
Freeze the set (make it immutable).
UnicodeSet & applyPattern(const UnicodeString &pattern, ParsePosition &pos, uint32_t options, const SymbolTable *symbols, UErrorCode &status)
Parses the given pattern, starting at the given position.
virtual UBool contains(UChar32 c) const override
Returns true if this set contains the given character.
UnicodeSet & retain(const UnicodeString &s)
Retains only the specified string from this set if it is present.
UnicodeSet(const uint16_t buffer[], int32_t bufferLen, ESerialization serialization, UErrorCode &status)
Constructs a set from the output of serialize().
UnicodeSet(const UnicodeString &pattern, uint32_t options, const SymbolTable *symbols, UErrorCode &status)
Constructs a set from the given pattern.
USet * toUSet()
Produce a USet * pointer for this UnicodeSet.
Definition uniset.h:1798
UnicodeSet & retain(UChar32 start, UChar32 end)
Retain only the elements in this set that are contained in the specified range.
UBool contains(UChar32 start, UChar32 end) const
Returns true if this set contains every character of the given range.
UnicodeSet & remove(UChar32 start, UChar32 end)
Removes the specified range from this set if it is present.
UBool containsSome(UChar32 start, UChar32 end) const
Returns true if this set contains one or more of the characters in the given range.
Definition uniset.h:1774
UBool containsNone(const UnicodeSet &c) const
Returns true if this set contains none of the characters and strings of the given set.
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition unistr.h:303
int32_t length() const
Return the length of the UnicodeString object.
Definition unistr.h:4269
char16_t * getBuffer(int32_t minCapacity)
Get a read/write pointer to the internal buffer.
UMatchDegree
Constants returned by UnicodeMatcher::matches() indicating the degree of match.
Definition unimatch.h:33
bool operator!=(const StringPiece &x, const StringPiece &y)
Global operator != for StringPiece.
UProperty
Selection constants for Unicode properties.
Definition uchar.h:196
C API: This file defines an abstract map from Unicode code points to integer values.
int32_t UChar32
Define UChar32 as a type for single Unicode code points.
Definition umachine.h:449
int8_t UBool
The ICU boolean type, a signed-byte integer.
Definition umachine.h:269
C++ API: Unicode Filter.
C++ API: Unicode String.
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
Definition uobject.h:96
C API: Unicode Set.
USetSpanCondition
Argument values for whether span() and similar functions continue while the current character is cont...
Definition uset.h:186
struct USet USet
USet is the C API type corresponding to C++ class UnicodeSet.
Definition uset.h:54
Basic definitions for ICU, for both C and C++ APIs.
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition utypes.h:509
#define U_COMMON_API
Set to export library symbols from inside the common library, and to import them from outside.
Definition utypes.h:315