ICU4C 79
Loading...
Searching...
No Matches
uset.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*
6* Copyright (C) 2002-2014, International Business Machines
7* Corporation and others. All Rights Reserved.
8*
9*******************************************************************************
10* file name: uset.h
11* encoding: UTF-8
12* tab size: 8 (not used)
13* indentation:4
14*
15* created on: 2002mar07
16* created by: Markus W. Scherer
17*
18* C version of UnicodeSet.
19*/
20
21
28
29#ifndef __USET_H__
30#define __USET_H__
31
32#include "unicode/utypes.h"
33#include "unicode/uchar.h"
34
35#if U_SHOW_CPLUSPLUS_API || U_SHOW_CPLUSPLUS_HEADER_API
36#include <string>
37#include <string_view>
38#include "unicode/char16ptr.h"
40#include "unicode/utf16.h"
41#endif
42
43#ifndef USET_DEFINED
44
45#ifndef U_IN_DOXYGEN
46#define USET_DEFINED
47#endif
54typedef struct USet USet;
55#endif
56
68enum {
74
102
115
129};
130
186typedef enum USetSpanCondition {
235#ifndef U_HIDE_DEPRECATED_API
241#endif // U_HIDE_DEPRECATED_API
243
244enum {
252};
253
281
282/*********************************************************************
283 * USet API
284 *********************************************************************/
285
293U_CAPI USet* U_EXPORT2
295
306U_CAPI USet* U_EXPORT2
308
318U_CAPI USet* U_EXPORT2
319uset_openPattern(const UChar* pattern, int32_t patternLength,
320 UErrorCode* ec);
321
335U_CAPI USet* U_EXPORT2
336uset_openPatternOptions(const UChar* pattern, int32_t patternLength,
337 uint32_t options,
338 UErrorCode* ec);
339
346U_CAPI void U_EXPORT2
348
349#if U_SHOW_CPLUSPLUS_API
350
351U_NAMESPACE_BEGIN
352
363
364U_NAMESPACE_END
365
366#endif
367
377U_CAPI USet * U_EXPORT2
378uset_clone(const USet *set);
379
389U_CAPI UBool U_EXPORT2
390uset_isFrozen(const USet *set);
391
405U_CAPI void U_EXPORT2
407
418U_CAPI USet * U_EXPORT2
420
430U_CAPI void U_EXPORT2
432 UChar32 start, UChar32 end);
433
458U_CAPI int32_t U_EXPORT2
460 const UChar *pattern, int32_t patternLength,
461 uint32_t options,
462 UErrorCode *status);
463
486U_CAPI void U_EXPORT2
488 UProperty prop, int32_t value, UErrorCode* ec);
489
525U_CAPI void U_EXPORT2
527 const UChar *prop, int32_t propLength,
528 const UChar *value, int32_t valueLength,
529 UErrorCode* ec);
530
540U_CAPI UBool U_EXPORT2
541uset_resemblesPattern(const UChar *pattern, int32_t patternLength,
542 int32_t pos);
543
559U_CAPI int32_t U_EXPORT2
561 UChar* result, int32_t resultCapacity,
562 UBool escapeUnprintable,
563 UErrorCode* ec);
564
573U_CAPI void U_EXPORT2
575
588U_CAPI void U_EXPORT2
589uset_addAll(USet* set, const USet *additionalSet);
590
600U_CAPI void U_EXPORT2
602
612U_CAPI void U_EXPORT2
613uset_addString(USet* set, const UChar* str, int32_t strLen);
614
624U_CAPI void U_EXPORT2
625uset_addAllCodePoints(USet* set, const UChar *str, int32_t strLen);
626
635U_CAPI void U_EXPORT2
637
647U_CAPI void U_EXPORT2
649
659U_CAPI void U_EXPORT2
660uset_removeString(USet* set, const UChar* str, int32_t strLen);
661
671U_CAPI void U_EXPORT2
672uset_removeAllCodePoints(USet *set, const UChar *str, int32_t length);
673
685U_CAPI void U_EXPORT2
686uset_removeAll(USet* set, const USet* removeSet);
687
700U_CAPI void U_EXPORT2
701uset_retain(USet* set, UChar32 start, UChar32 end);
702
714U_CAPI void U_EXPORT2
715uset_retainString(USet *set, const UChar *str, int32_t length);
716
726U_CAPI void U_EXPORT2
727uset_retainAllCodePoints(USet *set, const UChar *str, int32_t length);
728
741U_CAPI void U_EXPORT2
742uset_retainAll(USet* set, const USet* retain);
743
752U_CAPI void U_EXPORT2
754
768U_CAPI void U_EXPORT2
770
784U_CAPI void U_EXPORT2
786
797U_CAPI void U_EXPORT2
798uset_complementString(USet *set, const UChar *str, int32_t length);
799
809U_CAPI void U_EXPORT2
810uset_complementAllCodePoints(USet *set, const UChar *str, int32_t length);
811
823U_CAPI void U_EXPORT2
824uset_complementAll(USet* set, const USet* complement);
825
833U_CAPI void U_EXPORT2
835
864U_CAPI void U_EXPORT2
865uset_closeOver(USet* set, int32_t attributes);
866
873U_CAPI void U_EXPORT2
875
883U_CAPI UBool U_EXPORT2
884uset_isEmpty(const USet* set);
885
891U_CAPI UBool U_EXPORT2
893
902U_CAPI UBool U_EXPORT2
904
914U_CAPI UBool U_EXPORT2
915uset_containsRange(const USet* set, UChar32 start, UChar32 end);
916
925U_CAPI UBool U_EXPORT2
926uset_containsString(const USet* set, const UChar* str, int32_t strLen);
927
938U_CAPI int32_t U_EXPORT2
939uset_indexOf(const USet* set, UChar32 c);
940
956U_CAPI UChar32 U_EXPORT2
957uset_charAt(const USet* set, int32_t charIndex);
958
974U_CAPI int32_t U_EXPORT2
975uset_size(const USet* set);
976
986U_CAPI int32_t U_EXPORT2
988
997U_CAPI int32_t U_EXPORT2
999
1012U_CAPI const UChar* U_EXPORT2
1013uset_getString(const USet* set U_LIFETIME_BOUND, int32_t index, int32_t* pLength);
1014
1025U_CAPI int32_t U_EXPORT2
1027
1058U_CAPI int32_t U_EXPORT2
1059uset_getItem(const USet* set, int32_t itemIndex,
1060 UChar32* start, UChar32* end,
1061 UChar* str, int32_t strCapacity,
1062 UErrorCode* ec);
1063
1072U_CAPI UBool U_EXPORT2
1073uset_containsAll(const USet* set1, const USet* set2);
1074
1085U_CAPI UBool U_EXPORT2
1086uset_containsAllCodePoints(const USet* set, const UChar *str, int32_t strLen);
1087
1096U_CAPI UBool U_EXPORT2
1097uset_containsNone(const USet* set1, const USet* set2);
1098
1107U_CAPI UBool U_EXPORT2
1108uset_containsSome(const USet* set1, const USet* set2);
1109
1129U_CAPI int32_t U_EXPORT2
1130uset_span(const USet *set, const UChar *s, int32_t length, USetSpanCondition spanCondition);
1131
1150U_CAPI int32_t U_EXPORT2
1151uset_spanBack(const USet *set, const UChar *s, int32_t length, USetSpanCondition spanCondition);
1152
1172U_CAPI int32_t U_EXPORT2
1173uset_spanUTF8(const USet *set, const char *s, int32_t length, USetSpanCondition spanCondition);
1174
1193U_CAPI int32_t U_EXPORT2
1194uset_spanBackUTF8(const USet *set, const char *s, int32_t length, USetSpanCondition spanCondition);
1195
1204U_CAPI UBool U_EXPORT2
1205uset_equals(const USet* set1, const USet* set2);
1206
1207/*********************************************************************
1208 * Serialized set API
1209 *********************************************************************/
1210
1260U_CAPI int32_t U_EXPORT2
1261uset_serialize(const USet* set, uint16_t* dest, int32_t destCapacity, UErrorCode* pErrorCode);
1262
1271U_CAPI UBool U_EXPORT2
1272uset_getSerializedSet(USerializedSet* fillSet, const uint16_t* src, int32_t srcLength);
1273
1281U_CAPI void U_EXPORT2
1283
1292U_CAPI UBool U_EXPORT2
1294
1304U_CAPI int32_t U_EXPORT2
1306
1320U_CAPI UBool U_EXPORT2
1321uset_getSerializedRange(const USerializedSet* set, int32_t rangeIndex,
1322 UChar32* pStart, UChar32* pEnd);
1323
1324#if U_SHOW_CPLUSPLUS_API || U_SHOW_CPLUSPLUS_HEADER_API
1325
1326namespace U_HEADER_ONLY_NAMESPACE {
1327
1328// Note: Not U_COMMON_API, and not a subclass of UMemory, because this is a header-only class,
1329// not intended to be used via export from the ICU DLL.
1330
1336public:
1339
1341 bool operator==(const USetCodePointIterator &other) const {
1342 // No need to compare rangeCount & end given private constructor
1343 // and assuming we don't compare iterators across the set being modified.
1344 // And comparing rangeIndex is redundant with comparing c.
1345 // We might even skip comparing uset.
1346 // Unless we want operator==() to be "correct" for more than iteration.
1347 return uset == other.uset && c == other.c;
1348 }
1349
1351 bool operator!=(const USetCodePointIterator &other) const { return !operator==(other); }
1352
1354 UChar32 operator*() const { return c; }
1355
1360 USetCodePointIterator& operator++() U_LIFETIME_BOUND {
1361 if (c < end) {
1362 ++c;
1363 } else if (rangeIndex < rangeCount) {
1364 UErrorCode errorCode = U_ZERO_ERROR;
1365 int32_t result = uset_getItem(uset, rangeIndex, &c, &end, nullptr, 0, &errorCode);
1366 if (U_SUCCESS(errorCode) && result == 0) {
1367 ++rangeIndex;
1368 } else {
1369 c = end = U_SENTINEL;
1370 }
1371 } else {
1372 c = end = U_SENTINEL;
1373 }
1374 return *this;
1375 }
1376
1382 USetCodePointIterator result(*this);
1383 operator++();
1384 return result;
1385 }
1386
1387private:
1388 friend class USetCodePoints;
1389
1390 USetCodePointIterator(const USet* pUset U_LIFETIME_BOUND,
1391 int32_t nRangeIndex,
1392 int32_t nRangeCount)
1393 : uset(pUset), rangeIndex(nRangeIndex), rangeCount(nRangeCount),
1394 c(U_SENTINEL), end(U_SENTINEL) {
1395 // Fetch the first range.
1396 operator++();
1397 }
1398
1399 const USet *uset;
1400 int32_t rangeIndex;
1401 int32_t rangeCount;
1402 UChar32 c, end;
1403};
1404
1424public:
1429 USetCodePoints(const USet* pUset U_LIFETIME_BOUND)
1430 : uset(pUset), rangeCount(uset_getRangeCount(pUset)) {}
1431
1433 USetCodePoints(const USetCodePoints &other) = default;
1434
1437 return USetCodePointIterator(uset, 0, rangeCount);
1438 }
1439
1442 return USetCodePointIterator(uset, rangeCount, rangeCount);
1443 }
1444
1445private:
1446 const USet *uset;
1447 int32_t rangeCount;
1448};
1449
1459 struct iterator {
1461 iterator(UChar32 aC) : c(aC) {}
1462
1464 bool operator==(const iterator &other) const { return c == other.c; }
1466 bool operator!=(const iterator &other) const { return !operator==(other); }
1467
1469 UChar32 operator*() const { return c; }
1470
1475 iterator& operator++() U_LIFETIME_BOUND {
1476 ++c;
1477 return *this;
1478 }
1479
1485 return c++;
1486 }
1487
1493 };
1494
1498 CodePointRange(const CodePointRange &other) = default;
1500 size_t size() const { return (rangeEnd + 1) - rangeStart; }
1502 iterator begin() const { return rangeStart; }
1504 iterator end() const { return rangeEnd + 1; }
1505
1516};
1517
1523public:
1525 USetRangeIterator(const USetRangeIterator &other) = default;
1526
1528 bool operator==(const USetRangeIterator &other) const {
1529 // No need to compare rangeCount given private constructor
1530 // and assuming we don't compare iterators across the set being modified.
1531 // We might even skip comparing uset.
1532 // Unless we want operator==() to be "correct" for more than iteration.
1533 return uset == other.uset && rangeIndex == other.rangeIndex;
1534 }
1535
1537 bool operator!=(const USetRangeIterator &other) const { return !operator==(other); }
1538
1541 if (rangeIndex < rangeCount) {
1542 UChar32 start, end;
1543 UErrorCode errorCode = U_ZERO_ERROR;
1544 int32_t result = uset_getItem(uset, rangeIndex, &start, &end, nullptr, 0, &errorCode);
1545 if (U_SUCCESS(errorCode) && result == 0) {
1546 return CodePointRange(start, end);
1547 }
1548 }
1550 }
1551
1556 USetRangeIterator& operator++() U_LIFETIME_BOUND {
1557 ++rangeIndex;
1558 return *this;
1559 }
1560
1566 USetRangeIterator result(*this);
1567 ++rangeIndex;
1568 return result;
1569 }
1570
1571private:
1572 friend class USetRanges;
1573
1574 USetRangeIterator(const USet* pUset U_LIFETIME_BOUND, int32_t nRangeIndex, int32_t nRangeCount)
1575 : uset(pUset), rangeIndex(nRangeIndex), rangeCount(nRangeCount) {}
1576
1577 const USet *uset;
1578 int32_t rangeIndex;
1579 int32_t rangeCount;
1580};
1581
1606public:
1611 USetRanges(const USet* pUset U_LIFETIME_BOUND)
1612 : uset(pUset), rangeCount(uset_getRangeCount(pUset)) {}
1613
1615 USetRanges(const USetRanges &other) = default;
1616
1619 return USetRangeIterator(uset, 0, rangeCount);
1620 }
1621
1624 return USetRangeIterator(uset, rangeCount, rangeCount);
1625 }
1626
1627private:
1628 const USet *uset;
1629 int32_t rangeCount;
1630};
1631
1637public:
1640
1642 bool operator==(const USetStringIterator &other) const {
1643 // No need to compare count given private constructor
1644 // and assuming we don't compare iterators across the set being modified.
1645 // We might even skip comparing uset.
1646 // Unless we want operator==() to be "correct" for more than iteration.
1647 return uset == other.uset && index == other.index;
1648 }
1649
1651 bool operator!=(const USetStringIterator &other) const { return !operator==(other); }
1652
1654 std::u16string_view operator*() const {
1655 if (index < count) {
1656 int32_t length;
1657 const UChar *uchars = uset_getString(uset, index, &length);
1658 // assert uchars != nullptr;
1659 return {uprv_char16PtrFromUChar(uchars), static_cast<size_t>(length)};
1660 }
1661 return {};
1662 }
1663
1668 USetStringIterator& operator++() U_LIFETIME_BOUND {
1669 ++index;
1670 return *this;
1671 }
1672
1678 USetStringIterator result(*this);
1679 ++index;
1680 return result;
1681 }
1682
1683private:
1684 friend class USetStrings;
1685
1686 USetStringIterator(const USet* pUset U_LIFETIME_BOUND, int32_t nIndex, int32_t nCount)
1687 : uset(pUset), index(nIndex), count(nCount) {}
1688
1689 const USet *uset;
1690 int32_t index;
1691 int32_t count;
1692};
1693
1717public:
1722 USetStrings(const USet* pUset U_LIFETIME_BOUND)
1723 : uset(pUset), count(uset_getStringCount(pUset)) {}
1724
1726 USetStrings(const USetStrings &other) = default;
1727
1730 return USetStringIterator(uset, 0, count);
1731 }
1732
1735 return USetStringIterator(uset, count, count);
1736 }
1737
1738private:
1739 const USet *uset;
1740 int32_t count;
1741};
1742
1748public:
1751
1753 bool operator==(const USetElementIterator &other) const {
1754 // No need to compare rangeCount & end given private constructor
1755 // and assuming we don't compare iterators across the set being modified.
1756 // We might even skip comparing uset.
1757 // Unless we want operator==() to be "correct" for more than iteration.
1758 return uset == other.uset && c == other.c && index == other.index;
1759 }
1760
1762 bool operator!=(const USetElementIterator &other) const { return !operator==(other); }
1763
1765 std::u16string operator*() const {
1766 if (c >= 0) {
1767 return c <= 0xffff ?
1768 std::u16string({static_cast<char16_t>(c)}) :
1769 std::u16string({U16_LEAD(c), U16_TRAIL(c)});
1770 } else if (index < totalCount) {
1771 int32_t length;
1772 const UChar *uchars = uset_getString(uset, index - rangeCount, &length);
1773 // assert uchars != nullptr;
1774 return {uprv_char16PtrFromUChar(uchars), static_cast<size_t>(length)};
1775 } else {
1776 return {};
1777 }
1778 }
1779
1784 USetElementIterator& operator++() U_LIFETIME_BOUND {
1785 if (c < end) {
1786 ++c;
1787 } else if (index < rangeCount) {
1788 UErrorCode errorCode = U_ZERO_ERROR;
1789 int32_t result = uset_getItem(uset, index, &c, &end, nullptr, 0, &errorCode);
1790 if (U_SUCCESS(errorCode) && result == 0) {
1791 ++index;
1792 } else {
1793 c = end = U_SENTINEL;
1794 }
1795 } else if (c >= 0) {
1796 // assert index == rangeCount;
1797 // Switch from the last range to the first string.
1798 c = end = U_SENTINEL;
1799 } else {
1800 ++index;
1801 }
1802 return *this;
1803 }
1804
1810 USetElementIterator result(*this);
1811 operator++();
1812 return result;
1813 }
1814
1815private:
1816 friend class USetElements;
1817
1818 USetElementIterator(const USet* pUset U_LIFETIME_BOUND,
1819 int32_t nIndex,
1820 int32_t nRangeCount,
1821 int32_t nTotalCount)
1822 : uset(pUset), index(nIndex), rangeCount(nRangeCount), totalCount(nTotalCount),
1823 c(U_SENTINEL), end(U_SENTINEL) {
1824 if (index < rangeCount) {
1825 // Fetch the first range.
1826 operator++();
1827 }
1828 // Otherwise don't move beyond the (index - rangeCount)-th string.
1829 }
1830
1831 const USet *uset;
1832 int32_t index;
1834 int32_t rangeCount;
1844 int32_t totalCount;
1845 UChar32 c, end;
1846};
1847
1876public:
1881 USetElements(const USet* pUset U_LIFETIME_BOUND)
1882 : uset(pUset), rangeCount(uset_getRangeCount(pUset)),
1883 stringCount(uset_getStringCount(pUset)) {}
1884
1886 USetElements(const USetElements &other) = default;
1887
1890 return USetElementIterator(uset, 0, rangeCount, rangeCount + stringCount);
1891 }
1892
1895 return USetElementIterator(uset, rangeCount + stringCount, rangeCount, rangeCount + stringCount);
1896 }
1897
1898private:
1899 const USet *uset;
1900 int32_t rangeCount, stringCount;
1901};
1902
1903} // namespace U_HEADER_ONLY_NAMESPACE
1904
1905#endif // U_SHOW_CPLUSPLUS_API || U_SHOW_CPLUSPLUS_HEADER_API
1906
1907#endif // __USET_H__
C++ API: char16_t pointer wrappers with implicit conversion from bit-compatible raw pointer types.
"Smart pointer" class, closes a USet via uset_close().
Iterator returned by USetCodePoints.
Definition uset.h:1335
bool operator==(const USetCodePointIterator &other) const
Definition uset.h:1341
USetCodePointIterator & operator++()
Pre-increment.
Definition uset.h:1360
bool operator!=(const USetCodePointIterator &other) const
Definition uset.h:1351
USetCodePointIterator operator++(int)
Post-increment.
Definition uset.h:1381
USetCodePointIterator(const USetCodePointIterator &other)=default
C++ "range" for iterating over the code points of a USet.
Definition uset.h:1423
USetCodePoints(const USetCodePoints &other)=default
USetCodePointIterator end() const
Definition uset.h:1441
USetCodePoints(const USet *pUset)
Constructs a C++ "range" object over the code points of the USet.
Definition uset.h:1429
USetCodePointIterator begin() const
Definition uset.h:1436
Iterator returned by USetElements.
Definition uset.h:1747
USetElementIterator operator++(int)
Post-increment.
Definition uset.h:1809
bool operator==(const USetElementIterator &other) const
Definition uset.h:1753
bool operator!=(const USetElementIterator &other) const
Definition uset.h:1762
USetElementIterator & operator++()
Pre-increment.
Definition uset.h:1784
USetElementIterator(const USetElementIterator &other)=default
A C++ "range" for iterating over all of the elements of a USet.
Definition uset.h:1875
USetElements(const USetElements &other)=default
USetElementIterator end() const
Definition uset.h:1894
USetElements(const USet *pUset)
Constructs a C++ "range" object over all of the elements of the USet.
Definition uset.h:1881
USetElementIterator begin() const
Definition uset.h:1889
Iterator returned by USetRanges.
Definition uset.h:1522
USetRangeIterator & operator++()
Pre-increment.
Definition uset.h:1556
CodePointRange operator*() const
Definition uset.h:1540
bool operator==(const USetRangeIterator &other) const
Definition uset.h:1528
USetRangeIterator operator++(int)
Post-increment.
Definition uset.h:1565
bool operator!=(const USetRangeIterator &other) const
Definition uset.h:1537
USetRangeIterator(const USetRangeIterator &other)=default
C++ "range" for iterating over the code point ranges of a USet.
Definition uset.h:1605
USetRangeIterator end() const
Definition uset.h:1623
USetRangeIterator begin() const
Definition uset.h:1618
USetRanges(const USet *pUset)
Constructs a C++ "range" object over the code point ranges of the USet.
Definition uset.h:1611
USetRanges(const USetRanges &other)=default
Iterator returned by USetStrings.
Definition uset.h:1636
USetStringIterator & operator++()
Pre-increment.
Definition uset.h:1668
USetStringIterator(const USetStringIterator &other)=default
bool operator!=(const USetStringIterator &other) const
Definition uset.h:1651
std::u16string_view operator*() const
Definition uset.h:1654
USetStringIterator operator++(int)
Post-increment.
Definition uset.h:1677
bool operator==(const USetStringIterator &other) const
Definition uset.h:1642
C++ "range" for iterating over the empty and multi-character strings of a USet.
Definition uset.h:1716
USetStrings(const USetStrings &other)=default
USetStringIterator begin() const
Definition uset.h:1729
USetStringIterator end() const
Definition uset.h:1734
USetStrings(const USet *pUset)
Constructs a C++ "range" object over the strings of the USet.
Definition uset.h:1722
C++ API: "Smart pointers" for use with and in ICU4C C++ code.
#define U_DEFINE_LOCAL_OPEN_POINTER(LocalPointerClassName, Type, closeFunction)
"Smart pointer" definition macro, deletes objects via the closeFunction.
A serialized form of a Unicode set.
Definition uset.h:259
uint16_t staticArray[USET_SERIALIZED_STATIC_ARRAY_CAPACITY]
A small buffer for the array to reduce memory allocations.
Definition uset.h:279
int32_t bmpLength
The length of the array that contains BMP characters.
Definition uset.h:269
const uint16_t * array
The serialized Unicode Set.
Definition uset.h:264
int32_t length
The total length of the array.
Definition uset.h:274
bool operator!=(const iterator &other) const
Definition uset.h:1466
UChar32 c
The current code point in the range.
Definition uset.h:1492
iterator & operator++()
Pre-increment.
Definition uset.h:1475
iterator operator++(int)
Post-increment.
Definition uset.h:1484
bool operator==(const iterator &other) const
Definition uset.h:1464
A contiguous range of code points in a USet/UnicodeSet.
Definition uset.h:1457
CodePointRange(UChar32 start, UChar32 end)
Definition uset.h:1496
UChar32 rangeEnd
Inclusive end of a USet/UnicodeSet range of code points.
Definition uset.h:1515
CodePointRange(const CodePointRange &other)=default
UChar32 rangeStart
Start of a USet/UnicodeSet range of code points.
Definition uset.h:1510
C API: Unicode Properties.
UProperty
Selection constants for Unicode properties.
Definition uchar.h:196
char16_t UChar
The base type for UTF-16 code units and pointers.
Definition umachine.h:400
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
#define U_CAPI
This is used to declare a function as a public ICU C API.
Definition umachine.h:110
#define U_SENTINEL
This value is intended for sentinel values for APIs that (take or) return single code points (UChar32...
Definition umachine.h:469
U_CAPI UBool uset_containsAll(const USet *set1, const USet *set2)
Returns true if set1 contains all the characters and strings of set2.
U_CAPI UBool uset_hasStrings(const USet *set)
U_CAPI int32_t uset_getStringCount(const USet *set)
U_CAPI USet * uset_open(UChar32 start, UChar32 end)
Creates a USet object that contains the range of characters start..end, inclusive.
U_CAPI UBool uset_serializedContains(const USerializedSet *set, UChar32 c)
Returns true if the given USerializedSet contains the given character.
U_CAPI UBool uset_getSerializedSet(USerializedSet *fillSet, const uint16_t *src, int32_t srcLength)
Given a serialized array, fill in the given serialized set object.
U_CAPI void uset_set(USet *set, UChar32 start, UChar32 end)
Causes the USet object to represent the range start - end.
U_CAPI void uset_addString(USet *set, const UChar *str, int32_t strLen)
Adds the given string to the given USet.
U_CAPI UBool uset_containsString(const USet *set, const UChar *str, int32_t strLen)
Returns true if the given USet contains the given string.
U_CAPI UBool uset_isEmpty(const USet *set)
Returns true if the given USet contains no characters and no strings.
U_CAPI int32_t uset_getItemCount(const USet *set)
Returns the number of items in this set.
@ USET_IGNORE_SPACE
Ignore white space within patterns unless quoted or escaped.
Definition uset.h:73
@ USET_ADD_CASE_MAPPINGS
Adds all case mappings for each element in the set.
Definition uset.h:114
@ USET_CASE_INSENSITIVE
Enable case insensitive matching.
Definition uset.h:101
@ USET_SIMPLE_CASE_INSENSITIVE
Enable case insensitive matching.
Definition uset.h:128
@ USET_SERIALIZED_STATIC_ARRAY_CAPACITY
Capacity of USerializedSet::staticArray.
Definition uset.h:251
U_CAPI int32_t uset_getSerializedRangeCount(const USerializedSet *set)
Returns the number of disjoint ranges of characters contained in the given serialized set.
U_CAPI UChar32 uset_charAt(const USet *set, int32_t charIndex)
Returns the character at the given index within this set, where the set is ordered by ascending code ...
U_CAPI void uset_retainAll(USet *set, const USet *retain)
Retains only the elements in this set that are contained in the specified set.
U_CAPI void uset_setSerializedToOne(USerializedSet *fillSet, UChar32 c)
Set the USerializedSet to contain the given character (and nothing else).
U_CAPI void uset_complementString(USet *set, const UChar *str, int32_t length)
Complements the specified string in this set.
U_CAPI void uset_applyIntPropertyValue(USet *set, UProperty prop, int32_t value, UErrorCode *ec)
Modifies the set to contain those code points which have the given value for the given binary or enum...
U_CAPI void uset_complementRange(USet *set, UChar32 start, UChar32 end)
Complements the specified range in this set.
U_CAPI UBool uset_resemblesPattern(const UChar *pattern, int32_t patternLength, int32_t pos)
Return true if the given position, in the given pattern, appears to be the start of a UnicodeSet patt...
U_CAPI void uset_addRange(USet *set, UChar32 start, UChar32 end)
Adds the given range of characters to the given USet.
U_CAPI void uset_add(USet *set, UChar32 c)
Adds the given character to the given USet.
U_CAPI void uset_complementAllCodePoints(USet *set, const UChar *str, int32_t length)
Complements EACH of the characters in this string.
U_CAPI int32_t uset_size(const USet *set)
Returns the number of characters and strings contained in this set.
U_CAPI int32_t uset_span(const USet *set, const UChar *s, int32_t length, USetSpanCondition spanCondition)
Returns the length of the initial substring of the input string which consists only of characters and...
U_CAPI USet * uset_openPatternOptions(const UChar *pattern, int32_t patternLength, uint32_t options, UErrorCode *ec)
Creates a set from the given pattern.
U_CAPI void uset_removeAllStrings(USet *set)
Remove all strings from this set.
U_CAPI void uset_clear(USet *set)
Removes all of the elements from this set.
U_CAPI void uset_removeAllCodePoints(USet *set, const UChar *str, int32_t length)
Removes EACH of the characters in this string.
USetSpanCondition
Argument values for whether span() and similar functions continue while the current character is cont...
Definition uset.h:186
@ USET_SPAN_NOT_CONTAINED
Continues a span() while there is no set element at the current position.
Definition uset.h:199
@ USET_SPAN_CONTAINED
Spans the longest substring that is a concatenation of set elements (characters or strings).
Definition uset.h:214
@ USET_SPAN_CONDITION_COUNT
One more than the last span condition.
Definition uset.h:240
@ USET_SPAN_SIMPLE
Continues a span() while there is a set element at the current position.
Definition uset.h:234
U_CAPI void uset_remove(USet *set, UChar32 c)
Removes the given character from the given USet.
U_CAPI USet * uset_openPattern(const UChar *pattern, int32_t patternLength, UErrorCode *ec)
Creates a set from the given pattern.
U_CAPI void uset_removeRange(USet *set, UChar32 start, UChar32 end)
Removes the given range of characters from the given USet.
U_CAPI USet * uset_openEmpty(void)
Create an empty USet object.
U_CAPI UBool uset_equals(const USet *set1, const USet *set2)
Returns true if set1 contains all of the characters and strings of set2, and vis versa.
U_CAPI UBool uset_isFrozen(const USet *set)
Determines whether the set has been frozen (made immutable) or not.
U_CAPI int32_t uset_getRangeCount(const USet *set)
U_CAPI USet * uset_cloneAsThawed(const USet *set)
Clone the set and make the clone mutable.
U_CAPI UBool uset_containsAllCodePoints(const USet *set, const UChar *str, int32_t strLen)
Returns true if this set contains all the characters of the given string.
U_CAPI int32_t uset_serialize(const USet *set, uint16_t *dest, int32_t destCapacity, UErrorCode *pErrorCode)
Serializes this set into an array of 16-bit integers.
U_CAPI int32_t uset_indexOf(const USet *set, UChar32 c)
Returns the index of the given character within this set, where the set is ordered by ascending code ...
U_CAPI USet * uset_clone(const USet *set)
Returns a copy of this object.
U_CAPI void uset_freeze(USet *set)
Freeze the set (make it immutable).
U_CAPI int32_t uset_spanUTF8(const USet *set, const char *s, int32_t length, USetSpanCondition spanCondition)
Returns the length of the initial substring of the input string which consists only of characters and...
U_CAPI void uset_retain(USet *set, UChar32 start, UChar32 end)
Retain only the elements in this set that are contained in the specified range.
U_CAPI int32_t uset_toPattern(const USet *set, UChar *result, int32_t resultCapacity, UBool escapeUnprintable, UErrorCode *ec)
Returns a string representation of this set.
U_CAPI int32_t uset_spanBackUTF8(const USet *set, const char *s, int32_t length, USetSpanCondition spanCondition)
Returns the start of the trailing substring of the input string which consists only of characters and...
U_CAPI void uset_complement(USet *set)
This is equivalent to uset_complementRange(set, 0, 0x10FFFF).
U_CAPI UBool uset_containsSome(const USet *set1, const USet *set2)
Returns true if set1 contains some of the characters and strings of set2.
U_CAPI int32_t uset_spanBack(const USet *set, const UChar *s, int32_t length, USetSpanCondition spanCondition)
Returns the start of the trailing substring of the input string which consists only of characters and...
U_CAPI UBool uset_containsNone(const USet *set1, const USet *set2)
Returns true if set1 contains none of the characters and strings of set2.
U_CAPI void uset_retainAllCodePoints(USet *set, const UChar *str, int32_t length)
Retains EACH of the characters in this string.
U_CAPI UBool uset_contains(const USet *set, UChar32 c)
Returns true if the given USet contains the given character.
U_CAPI int32_t uset_applyPattern(USet *set, const UChar *pattern, int32_t patternLength, uint32_t options, UErrorCode *status)
Modifies the set to represent the set specified by the given pattern.
U_CAPI void uset_complementAll(USet *set, const USet *complement)
Complements in this set all elements contained in the specified set.
U_CAPI void uset_applyPropertyAlias(USet *set, const UChar *prop, int32_t propLength, const UChar *value, int32_t valueLength, UErrorCode *ec)
Modifies the set to contain those code points which have the given value for the given property.
U_CAPI void uset_close(USet *set)
Disposes of the storage used by a USet object.
struct USet USet
USet is the C API type corresponding to C++ class UnicodeSet.
Definition uset.h:54
U_CAPI const UChar * uset_getString(const USet *set, int32_t index, int32_t *pLength)
Returns the index-th string (empty or multi-character) in the set.
U_CAPI void uset_addAll(USet *set, const USet *additionalSet)
Adds all of the elements in the specified set to this set if they're not already present.
U_CAPI void uset_removeString(USet *set, const UChar *str, int32_t strLen)
Removes the given string to the given USet.
U_CAPI void uset_compact(USet *set)
Reallocate this objects internal structures to take up the least possible space, without changing thi...
U_CAPI int32_t uset_getItem(const USet *set, int32_t itemIndex, UChar32 *start, UChar32 *end, UChar *str, int32_t strCapacity, UErrorCode *ec)
Returns an item of this set.
U_CAPI void uset_closeOver(USet *set, int32_t attributes)
Close this set over the given attribute.
U_CAPI void uset_addAllCodePoints(USet *set, const UChar *str, int32_t strLen)
Adds each of the characters in this string to the set.
U_CAPI void uset_retainString(USet *set, const UChar *str, int32_t length)
Retains only the specified string from this set if it is present.
U_CAPI void uset_removeAll(USet *set, const USet *removeSet)
Removes from this set all of its elements that are contained in the specified set.
U_CAPI UBool uset_containsRange(const USet *set, UChar32 start, UChar32 end)
Returns true if the given USet contains all characters c where start <= c && c <= end.
U_CAPI UBool uset_getSerializedRange(const USerializedSet *set, int32_t rangeIndex, UChar32 *pStart, UChar32 *pEnd)
Returns a range of characters contained in the given serialized set.
C API: 16-bit Unicode handling macros.
#define U16_TRAIL(supplementary)
Get the trail surrogate (0xdc00..0xdfff) for a supplementary code point (0x10000.....
Definition utf16.h:132
#define U16_LEAD(supplementary)
Get the lead surrogate (0xd800..0xdbff) for a supplementary code point (0x10000..0x10ffff).
Definition utf16.h:123
Basic definitions for ICU, for both C and C++ APIs.
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition utypes.h:509
@ U_ZERO_ERROR
No error, no warning.
Definition utypes.h:544
#define U_SUCCESS(x)
Does the error code indicate success?
Definition utypes.h:822