Loading...
Searching...
No Matches
uset.h
Go to the documentation of this file.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
*
* Copyright (C) 2002-2014, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
* file name: uset.h
* encoding: UTF-8
* tab size: 8 (not used)
* indentation:4
*
* created on: 2002mar07
* created by: Markus W. Scherer
*
* C version of UnicodeSet.
*/
#ifndef __USET_H__
#define __USET_H__
#include "unicode/utypes.h"
#include "unicode/uchar.h"
#if U_SHOW_CPLUSPLUS_API || U_SHOW_CPLUSPLUS_HEADER_API
#include <string>
#include <string_view>
#include "unicode/char16ptr.h"
#include "unicode/localpointer.h"
#include "unicode/utf16.h"
#endif
#ifndef USET_DEFINED
#ifndef U_IN_DOXYGEN
#define USET_DEFINED
#endif
typedef struct USet USet;
#endif
enum {
USET_IGNORE_SPACE = 1,
USET_CASE_INSENSITIVE = 2,
USET_ADD_CASE_MAPPINGS = 4,
USET_SIMPLE_CASE_INSENSITIVE = 6
};
typedef enum USetSpanCondition {
USET_SPAN_NOT_CONTAINED = 0,
USET_SPAN_CONTAINED = 1,
USET_SPAN_SIMPLE = 2,
#ifndef U_HIDE_DEPRECATED_API
USET_SPAN_CONDITION_COUNT
#endif // U_HIDE_DEPRECATED_API
} USetSpanCondition;
enum {
USET_SERIALIZED_STATIC_ARRAY_CAPACITY=8
};
typedef struct USerializedSet {
const uint16_t *array;
int32_t bmpLength;
int32_t length;
uint16_t staticArray[USET_SERIALIZED_STATIC_ARRAY_CAPACITY];
} USerializedSet;
/*********************************************************************
* USet API
*********************************************************************/
U_CAPI USet* U_EXPORT2
uset_openEmpty(void);
U_CAPI USet* U_EXPORT2
uset_open(UChar32 start, UChar32 end);
U_CAPI USet* U_EXPORT2
uset_openPattern(const UChar* pattern, int32_t patternLength,
UErrorCode* ec);
U_CAPI USet* U_EXPORT2
uset_openPatternOptions(const UChar* pattern, int32_t patternLength,
uint32_t options,
UErrorCode* ec);
U_CAPI void U_EXPORT2
uset_close(USet* set);
#if U_SHOW_CPLUSPLUS_API
U_NAMESPACE_BEGIN
U_DEFINE_LOCAL_OPEN_POINTER(LocalUSetPointer, USet, uset_close);
U_NAMESPACE_END
#endif
U_CAPI USet * U_EXPORT2
uset_clone(const USet *set);
U_CAPI UBool U_EXPORT2
uset_isFrozen(const USet *set);
U_CAPI void U_EXPORT2
uset_freeze(USet *set);
U_CAPI USet * U_EXPORT2
uset_cloneAsThawed(const USet *set);
U_CAPI void U_EXPORT2
uset_set(USet* set,
UChar32 start, UChar32 end);
U_CAPI int32_t U_EXPORT2
uset_applyPattern(USet *set,
const UChar *pattern, int32_t patternLength,
uint32_t options,
UErrorCode *status);
U_CAPI void U_EXPORT2
uset_applyIntPropertyValue(USet* set,
UProperty prop, int32_t value, UErrorCode* ec);
U_CAPI void U_EXPORT2
uset_applyPropertyAlias(USet* set,
const UChar *prop, int32_t propLength,
const UChar *value, int32_t valueLength,
UErrorCode* ec);
U_CAPI UBool U_EXPORT2
uset_resemblesPattern(const UChar *pattern, int32_t patternLength,
int32_t pos);
U_CAPI int32_t U_EXPORT2
uset_toPattern(const USet* set,
UChar* result, int32_t resultCapacity,
UBool escapeUnprintable,
UErrorCode* ec);
U_CAPI void U_EXPORT2
uset_add(USet* set, UChar32 c);
U_CAPI void U_EXPORT2
uset_addAll(USet* set, const USet *additionalSet);
U_CAPI void U_EXPORT2
uset_addRange(USet* set, UChar32 start, UChar32 end);
U_CAPI void U_EXPORT2
uset_addString(USet* set, const UChar* str, int32_t strLen);
U_CAPI void U_EXPORT2
uset_addAllCodePoints(USet* set, const UChar *str, int32_t strLen);
U_CAPI void U_EXPORT2
uset_remove(USet* set, UChar32 c);
U_CAPI void U_EXPORT2
uset_removeRange(USet* set, UChar32 start, UChar32 end);
U_CAPI void U_EXPORT2
uset_removeString(USet* set, const UChar* str, int32_t strLen);
U_CAPI void U_EXPORT2
uset_removeAllCodePoints(USet *set, const UChar *str, int32_t length);
U_CAPI void U_EXPORT2
uset_removeAll(USet* set, const USet* removeSet);
U_CAPI void U_EXPORT2
uset_retain(USet* set, UChar32 start, UChar32 end);
U_CAPI void U_EXPORT2
uset_retainString(USet *set, const UChar *str, int32_t length);
U_CAPI void U_EXPORT2
uset_retainAllCodePoints(USet *set, const UChar *str, int32_t length);
U_CAPI void U_EXPORT2
uset_retainAll(USet* set, const USet* retain);
U_CAPI void U_EXPORT2
uset_compact(USet* set);
U_CAPI void U_EXPORT2
uset_complement(USet* set);
U_CAPI void U_EXPORT2
uset_complementRange(USet *set, UChar32 start, UChar32 end);
U_CAPI void U_EXPORT2
uset_complementString(USet *set, const UChar *str, int32_t length);
U_CAPI void U_EXPORT2
uset_complementAllCodePoints(USet *set, const UChar *str, int32_t length);
U_CAPI void U_EXPORT2
uset_complementAll(USet* set, const USet* complement);
U_CAPI void U_EXPORT2
uset_clear(USet* set);
U_CAPI void U_EXPORT2
uset_closeOver(USet* set, int32_t attributes);
U_CAPI void U_EXPORT2
uset_removeAllStrings(USet* set);
U_CAPI UBool U_EXPORT2
uset_isEmpty(const USet* set);
U_CAPI UBool U_EXPORT2
uset_hasStrings(const USet *set);
U_CAPI UBool U_EXPORT2
uset_contains(const USet* set, UChar32 c);
U_CAPI UBool U_EXPORT2
uset_containsRange(const USet* set, UChar32 start, UChar32 end);
U_CAPI UBool U_EXPORT2
uset_containsString(const USet* set, const UChar* str, int32_t strLen);
U_CAPI int32_t U_EXPORT2
uset_indexOf(const USet* set, UChar32 c);
U_CAPI UChar32 U_EXPORT2
uset_charAt(const USet* set, int32_t charIndex);
U_CAPI int32_t U_EXPORT2
uset_size(const USet* set);
U_CAPI int32_t U_EXPORT2
uset_getRangeCount(const USet *set);
U_CAPI int32_t U_EXPORT2
uset_getStringCount(const USet *set);
U_CAPI const UChar* U_EXPORT2
uset_getString(const USet *set, int32_t index, int32_t *pLength);
U_CAPI int32_t U_EXPORT2
uset_getItemCount(const USet* set);
U_CAPI int32_t U_EXPORT2
uset_getItem(const USet* set, int32_t itemIndex,
UChar32* start, UChar32* end,
UChar* str, int32_t strCapacity,
UErrorCode* ec);
U_CAPI UBool U_EXPORT2
uset_containsAll(const USet* set1, const USet* set2);
U_CAPI UBool U_EXPORT2
uset_containsAllCodePoints(const USet* set, const UChar *str, int32_t strLen);
U_CAPI UBool U_EXPORT2
uset_containsNone(const USet* set1, const USet* set2);
U_CAPI UBool U_EXPORT2
uset_containsSome(const USet* set1, const USet* set2);
U_CAPI int32_t U_EXPORT2
uset_span(const USet *set, const UChar *s, int32_t length, USetSpanCondition spanCondition);
U_CAPI int32_t U_EXPORT2
uset_spanBack(const USet *set, const UChar *s, int32_t length, USetSpanCondition spanCondition);
U_CAPI int32_t U_EXPORT2
uset_spanUTF8(const USet *set, const char *s, int32_t length, USetSpanCondition spanCondition);
U_CAPI int32_t U_EXPORT2
uset_spanBackUTF8(const USet *set, const char *s, int32_t length, USetSpanCondition spanCondition);
U_CAPI UBool U_EXPORT2
uset_equals(const USet* set1, const USet* set2);
/*********************************************************************
* Serialized set API
*********************************************************************/
U_CAPI int32_t U_EXPORT2
uset_serialize(const USet* set, uint16_t* dest, int32_t destCapacity, UErrorCode* pErrorCode);
U_CAPI UBool U_EXPORT2
uset_getSerializedSet(USerializedSet* fillSet, const uint16_t* src, int32_t srcLength);
U_CAPI void U_EXPORT2
uset_setSerializedToOne(USerializedSet* fillSet, UChar32 c);
U_CAPI UBool U_EXPORT2
uset_serializedContains(const USerializedSet* set, UChar32 c);
U_CAPI int32_t U_EXPORT2
uset_getSerializedRangeCount(const USerializedSet* set);
U_CAPI UBool U_EXPORT2
uset_getSerializedRange(const USerializedSet* set, int32_t rangeIndex,
UChar32* pStart, UChar32* pEnd);
#if U_SHOW_CPLUSPLUS_API || U_SHOW_CPLUSPLUS_HEADER_API
namespace U_HEADER_ONLY_NAMESPACE {
// Note: Not U_COMMON_API, and not a subclass of UMemory, because this is a header-only class,
// not intended to be used via export from the ICU DLL.
class USetCodePointIterator {
public:
USetCodePointIterator(const USetCodePointIterator &other) = default;
bool operator==(const USetCodePointIterator &other) const {
// No need to compare rangeCount & end given private constructor
// and assuming we don't compare iterators across the set being modified.
// And comparing rangeIndex is redundant with comparing c.
// We might even skip comparing uset.
// Unless we want operator==() to be "correct" for more than iteration.
return uset == other.uset && c == other.c;
}
bool operator!=(const USetCodePointIterator &other) const { return !operator==(other); }
UChar32 operator*() const { return c; }
USetCodePointIterator &operator++() {
if (c < end) {
++c;
} else if (rangeIndex < rangeCount) {
UErrorCode errorCode = U_ZERO_ERROR;
int32_t result = uset_getItem(uset, rangeIndex, &c, &end, nullptr, 0, &errorCode);
if (U_SUCCESS(errorCode) && result == 0) {
++rangeIndex;
} else {
c = end = U_SENTINEL;
}
} else {
c = end = U_SENTINEL;
}
return *this;
}
USetCodePointIterator operator++(int) {
USetCodePointIterator result(*this);
operator++();
return result;
}
private:
friend class USetCodePoints;
USetCodePointIterator(const USet *pUset, int32_t nRangeIndex, int32_t nRangeCount)
: uset(pUset), rangeIndex(nRangeIndex), rangeCount(nRangeCount),
c(U_SENTINEL), end(U_SENTINEL) {
// Fetch the first range.
operator++();
}
const USet *uset;
int32_t rangeIndex;
int32_t rangeCount;
UChar32 c, end;
};
class USetCodePoints {
public:
USetCodePoints(const USet *pUset) : uset(pUset), rangeCount(uset_getRangeCount(pUset)) {}
USetCodePoints(const USetCodePoints &other) = default;
USetCodePointIterator begin() const {
return USetCodePointIterator(uset, 0, rangeCount);
}
USetCodePointIterator end() const {
return USetCodePointIterator(uset, rangeCount, rangeCount);
}
private:
const USet *uset;
int32_t rangeCount;
};
struct CodePointRange {
struct iterator {
iterator(UChar32 aC) : c(aC) {}
bool operator==(const iterator &other) const { return c == other.c; }
bool operator!=(const iterator &other) const { return !operator==(other); }
UChar32 operator*() const { return c; }
iterator &operator++() {
++c;
return *this;
}
iterator operator++(int) {
return c++;
}
UChar32 c;
};
CodePointRange(UChar32 start, UChar32 end) : rangeStart(start), rangeEnd(end) {}
CodePointRange(const CodePointRange &other) = default;
size_t size() const { return (rangeEnd + 1) - rangeStart; }
iterator begin() const { return rangeStart; }
iterator end() const { return rangeEnd + 1; }
UChar32 rangeStart;
UChar32 rangeEnd;
};
class USetRangeIterator {
public:
USetRangeIterator(const USetRangeIterator &other) = default;
bool operator==(const USetRangeIterator &other) const {
// No need to compare rangeCount given private constructor
// and assuming we don't compare iterators across the set being modified.
// We might even skip comparing uset.
// Unless we want operator==() to be "correct" for more than iteration.
return uset == other.uset && rangeIndex == other.rangeIndex;
}
bool operator!=(const USetRangeIterator &other) const { return !operator==(other); }
CodePointRange operator*() const {
if (rangeIndex < rangeCount) {
UChar32 start, end;
UErrorCode errorCode = U_ZERO_ERROR;
int32_t result = uset_getItem(uset, rangeIndex, &start, &end, nullptr, 0, &errorCode);
if (U_SUCCESS(errorCode) && result == 0) {
return CodePointRange(start, end);
}
}
return CodePointRange(U_SENTINEL, U_SENTINEL);
}
USetRangeIterator &operator++() {
++rangeIndex;
return *this;
}
USetRangeIterator operator++(int) {
USetRangeIterator result(*this);
++rangeIndex;
return result;
}
private:
friend class USetRanges;
USetRangeIterator(const USet *pUset, int32_t nRangeIndex, int32_t nRangeCount)
: uset(pUset), rangeIndex(nRangeIndex), rangeCount(nRangeCount) {}
const USet *uset;
int32_t rangeIndex;
int32_t rangeCount;
};
class USetRanges {
public:
USetRanges(const USet *pUset) : uset(pUset), rangeCount(uset_getRangeCount(pUset)) {}
USetRanges(const USetRanges &other) = default;
USetRangeIterator begin() const {
return USetRangeIterator(uset, 0, rangeCount);
}
USetRangeIterator end() const {
return USetRangeIterator(uset, rangeCount, rangeCount);
}
private:
const USet *uset;
int32_t rangeCount;
};
class USetStringIterator {
public:
USetStringIterator(const USetStringIterator &other) = default;
bool operator==(const USetStringIterator &other) const {
// No need to compare count given private constructor
// and assuming we don't compare iterators across the set being modified.
// We might even skip comparing uset.
// Unless we want operator==() to be "correct" for more than iteration.
return uset == other.uset && index == other.index;
}
bool operator!=(const USetStringIterator &other) const { return !operator==(other); }
std::u16string_view operator*() const {
if (index < count) {
int32_t length;
const UChar *uchars = uset_getString(uset, index, &length);
// assert uchars != nullptr;
return {uprv_char16PtrFromUChar(uchars), static_cast<size_t>(length)};
}
return {};
}
USetStringIterator &operator++() {
++index;
return *this;
}
USetStringIterator operator++(int) {
USetStringIterator result(*this);
++index;
return result;
}
private:
friend class USetStrings;
USetStringIterator(const USet *pUset, int32_t nIndex, int32_t nCount)
: uset(pUset), index(nIndex), count(nCount) {}
const USet *uset;
int32_t index;
int32_t count;
};
class USetStrings {
public:
USetStrings(const USet *pUset) : uset(pUset), count(uset_getStringCount(pUset)) {}
USetStrings(const USetStrings &other) = default;
USetStringIterator begin() const {
return USetStringIterator(uset, 0, count);
}
USetStringIterator end() const {
return USetStringIterator(uset, count, count);
}
private:
const USet *uset;
int32_t count;
};
#ifndef U_HIDE_DRAFT_API
class USetElementIterator {
public:
USetElementIterator(const USetElementIterator &other) = default;
bool operator==(const USetElementIterator &other) const {
// No need to compare rangeCount & end given private constructor
// and assuming we don't compare iterators across the set being modified.
// We might even skip comparing uset.
// Unless we want operator==() to be "correct" for more than iteration.
return uset == other.uset && c == other.c && index == other.index;
}
bool operator!=(const USetElementIterator &other) const { return !operator==(other); }
std::u16string operator*() const {
if (c >= 0) {
return c <= 0xffff ?
std::u16string({static_cast<char16_t>(c)}) :
std::u16string({U16_LEAD(c), U16_TRAIL(c)});
} else if (index < totalCount) {
int32_t length;
const UChar *uchars = uset_getString(uset, index - rangeCount, &length);
// assert uchars != nullptr;
return {uprv_char16PtrFromUChar(uchars), static_cast<size_t>(length)};
} else {
return {};
}
}
USetElementIterator &operator++() {
if (c < end) {
++c;
} else if (index < rangeCount) {
UErrorCode errorCode = U_ZERO_ERROR;
int32_t result = uset_getItem(uset, index, &c, &end, nullptr, 0, &errorCode);
if (U_SUCCESS(errorCode) && result == 0) {
++index;
} else {
c = end = U_SENTINEL;
}
} else if (c >= 0) {
// assert index == rangeCount;
// Switch from the last range to the first string.
c = end = U_SENTINEL;
} else {
++index;
}
return *this;
}
USetElementIterator operator++(int) {
USetElementIterator result(*this);
operator++();
return result;
}
private:
friend class USetElements;
USetElementIterator(const USet *pUset, int32_t nIndex, int32_t nRangeCount, int32_t nTotalCount)
: uset(pUset), index(nIndex), rangeCount(nRangeCount), totalCount(nTotalCount),
c(U_SENTINEL), end(U_SENTINEL) {
if (index < rangeCount) {
// Fetch the first range.
operator++();
}
// Otherwise don't move beyond the (index - rangeCount)-th string.
}
const USet *uset;
int32_t index;
int32_t rangeCount;
int32_t totalCount;
UChar32 c, end;
};
class USetElements {
public:
USetElements(const USet *pUset)
: uset(pUset), rangeCount(uset_getRangeCount(pUset)),
stringCount(uset_getStringCount(pUset)) {}
USetElements(const USetElements &other) = default;
USetElementIterator begin() const {
return USetElementIterator(uset, 0, rangeCount, rangeCount + stringCount);
}
USetElementIterator end() const {
return USetElementIterator(uset, rangeCount + stringCount, rangeCount, rangeCount + stringCount);
}
private:
const USet *uset;
int32_t rangeCount, stringCount;
};
#endif // U_HIDE_DRAFT_API
} // namespace U_HEADER_ONLY_NAMESPACE
#endif // U_SHOW_CPLUSPLUS_API || U_SHOW_CPLUSPLUS_HEADER_API
#endif // __USET_H__
char16ptr.h
C++ API: char16_t pointer wrappers with implicit conversion from bit-compatible raw pointer types.
LocalUSetPointer
"Smart pointer" class, closes a USet via uset_close().
U_HEADER_ONLY_NAMESPACE::USetCodePointIterator
Iterator returned by USetCodePoints.
Definition uset.h:1336
U_HEADER_ONLY_NAMESPACE::USetCodePointIterator::operator==
bool operator==(const USetCodePointIterator &other) const
Definition uset.h:1342
U_HEADER_ONLY_NAMESPACE::USetCodePointIterator::operator++
USetCodePointIterator & operator++()
Pre-increment.
Definition uset.h:1361
U_HEADER_ONLY_NAMESPACE::USetCodePointIterator::operator*
UChar32 operator*() const
Definition uset.h:1355
U_HEADER_ONLY_NAMESPACE::USetCodePointIterator::operator!=
bool operator!=(const USetCodePointIterator &other) const
Definition uset.h:1352
U_HEADER_ONLY_NAMESPACE::USetCodePointIterator::operator++
USetCodePointIterator operator++(int)
Post-increment.
Definition uset.h:1382
U_HEADER_ONLY_NAMESPACE::USetCodePointIterator::USetCodePointIterator
USetCodePointIterator(const USetCodePointIterator &other)=default
U_HEADER_ONLY_NAMESPACE::USetCodePoints
C++ "range" for iterating over the code points of a USet.
Definition uset.h:1422
U_HEADER_ONLY_NAMESPACE::USetCodePoints::USetCodePoints
USetCodePoints(const USetCodePoints &other)=default
U_HEADER_ONLY_NAMESPACE::USetCodePoints::end
USetCodePointIterator end() const
Definition uset.h:1439
U_HEADER_ONLY_NAMESPACE::USetCodePoints::USetCodePoints
USetCodePoints(const USet *pUset)
Constructs a C++ "range" object over the code points of the USet.
Definition uset.h:1428
U_HEADER_ONLY_NAMESPACE::USetCodePoints::begin
USetCodePointIterator begin() const
Definition uset.h:1434
U_HEADER_ONLY_NAMESPACE::USetElementIterator
Iterator returned by USetElements.
Definition uset.h:1744
U_HEADER_ONLY_NAMESPACE::USetElementIterator::operator++
USetElementIterator operator++(int)
Post-increment.
Definition uset.h:1806
U_HEADER_ONLY_NAMESPACE::USetElementIterator::operator==
bool operator==(const USetElementIterator &other) const
Definition uset.h:1750
U_HEADER_ONLY_NAMESPACE::USetElementIterator::operator!=
bool operator!=(const USetElementIterator &other) const
Definition uset.h:1759
U_HEADER_ONLY_NAMESPACE::USetElementIterator::operator++
USetElementIterator & operator++()
Pre-increment.
Definition uset.h:1781
U_HEADER_ONLY_NAMESPACE::USetElementIterator::USetElementIterator
USetElementIterator(const USetElementIterator &other)=default
U_HEADER_ONLY_NAMESPACE::USetElementIterator::operator*
std::u16string operator*() const
Definition uset.h:1762
U_HEADER_ONLY_NAMESPACE::USetElements
A C++ "range" for iterating over all of the elements of a USet.
Definition uset.h:1869
U_HEADER_ONLY_NAMESPACE::USetElements::USetElements
USetElements(const USetElements &other)=default
U_HEADER_ONLY_NAMESPACE::USetElements::end
USetElementIterator end() const
Definition uset.h:1888
U_HEADER_ONLY_NAMESPACE::USetElements::USetElements
USetElements(const USet *pUset)
Constructs a C++ "range" object over all of the elements of the USet.
Definition uset.h:1875
U_HEADER_ONLY_NAMESPACE::USetElements::begin
USetElementIterator begin() const
Definition uset.h:1883
U_HEADER_ONLY_NAMESPACE::USetRangeIterator
Iterator returned by USetRanges.
Definition uset.h:1520
U_HEADER_ONLY_NAMESPACE::USetRangeIterator::operator++
USetRangeIterator & operator++()
Pre-increment.
Definition uset.h:1554
U_HEADER_ONLY_NAMESPACE::USetRangeIterator::operator*
CodePointRange operator*() const
Definition uset.h:1538
U_HEADER_ONLY_NAMESPACE::USetRangeIterator::operator==
bool operator==(const USetRangeIterator &other) const
Definition uset.h:1526
U_HEADER_ONLY_NAMESPACE::USetRangeIterator::operator++
USetRangeIterator operator++(int)
Post-increment.
Definition uset.h:1563
U_HEADER_ONLY_NAMESPACE::USetRangeIterator::operator!=
bool operator!=(const USetRangeIterator &other) const
Definition uset.h:1535
U_HEADER_ONLY_NAMESPACE::USetRangeIterator::USetRangeIterator
USetRangeIterator(const USetRangeIterator &other)=default
U_HEADER_ONLY_NAMESPACE::USetRanges
C++ "range" for iterating over the code point ranges of a USet.
Definition uset.h:1603
U_HEADER_ONLY_NAMESPACE::USetRanges::end
USetRangeIterator end() const
Definition uset.h:1620
U_HEADER_ONLY_NAMESPACE::USetRanges::begin
USetRangeIterator begin() const
Definition uset.h:1615
U_HEADER_ONLY_NAMESPACE::USetRanges::USetRanges
USetRanges(const USet *pUset)
Constructs a C++ "range" object over the code point ranges of the USet.
Definition uset.h:1609
U_HEADER_ONLY_NAMESPACE::USetRanges::USetRanges
USetRanges(const USetRanges &other)=default
U_HEADER_ONLY_NAMESPACE::USetStringIterator
Iterator returned by USetStrings.
Definition uset.h:1633
U_HEADER_ONLY_NAMESPACE::USetStringIterator::operator++
USetStringIterator & operator++()
Pre-increment.
Definition uset.h:1665
U_HEADER_ONLY_NAMESPACE::USetStringIterator::USetStringIterator
USetStringIterator(const USetStringIterator &other)=default
U_HEADER_ONLY_NAMESPACE::USetStringIterator::operator!=
bool operator!=(const USetStringIterator &other) const
Definition uset.h:1648
U_HEADER_ONLY_NAMESPACE::USetStringIterator::operator*
std::u16string_view operator*() const
Definition uset.h:1651
U_HEADER_ONLY_NAMESPACE::USetStringIterator::operator++
USetStringIterator operator++(int)
Post-increment.
Definition uset.h:1674
U_HEADER_ONLY_NAMESPACE::USetStringIterator::operator==
bool operator==(const USetStringIterator &other) const
Definition uset.h:1639
U_HEADER_ONLY_NAMESPACE::USetStrings
C++ "range" for iterating over the empty and multi-character strings of a USet.
Definition uset.h:1713
U_HEADER_ONLY_NAMESPACE::USetStrings::USetStrings
USetStrings(const USetStrings &other)=default
U_HEADER_ONLY_NAMESPACE::USetStrings::begin
USetStringIterator begin() const
Definition uset.h:1725
U_HEADER_ONLY_NAMESPACE::USetStrings::end
USetStringIterator end() const
Definition uset.h:1730
U_HEADER_ONLY_NAMESPACE::USetStrings::USetStrings
USetStrings(const USet *pUset)
Constructs a C++ "range" object over the strings of the USet.
Definition uset.h:1719
localpointer.h
C++ API: "Smart pointers" for use with and in ICU4C C++ code.
U_DEFINE_LOCAL_OPEN_POINTER
#define U_DEFINE_LOCAL_OPEN_POINTER(LocalPointerClassName, Type, closeFunction)
"Smart pointer" definition macro, deletes objects via the closeFunction.
Definition localpointer.h:548
USerializedSet
A serialized form of a Unicode set.
Definition uset.h:259
USerializedSet::staticArray
uint16_t staticArray[USET_SERIALIZED_STATIC_ARRAY_CAPACITY]
A small buffer for the array to reduce memory allocations.
Definition uset.h:279
USerializedSet::bmpLength
int32_t bmpLength
The length of the array that contains BMP characters.
Definition uset.h:269
USerializedSet::array
const uint16_t * array
The serialized Unicode Set.
Definition uset.h:264
USerializedSet::length
int32_t length
The total length of the array.
Definition uset.h:274
U_HEADER_ONLY_NAMESPACE::CodePointRange::iterator
Definition uset.h:1457
U_HEADER_ONLY_NAMESPACE::CodePointRange::iterator::operator!=
bool operator!=(const iterator &other) const
Definition uset.h:1464
U_HEADER_ONLY_NAMESPACE::CodePointRange::iterator::iterator
iterator(UChar32 aC)
Definition uset.h:1459
U_HEADER_ONLY_NAMESPACE::CodePointRange::iterator::operator*
UChar32 operator*() const
Definition uset.h:1467
U_HEADER_ONLY_NAMESPACE::CodePointRange::iterator::c
UChar32 c
The current code point in the range.
Definition uset.h:1490
U_HEADER_ONLY_NAMESPACE::CodePointRange::iterator::operator++
iterator & operator++()
Pre-increment.
Definition uset.h:1473
U_HEADER_ONLY_NAMESPACE::CodePointRange::iterator::operator++
iterator operator++(int)
Post-increment.
Definition uset.h:1482
U_HEADER_ONLY_NAMESPACE::CodePointRange::iterator::operator==
bool operator==(const iterator &other) const
Definition uset.h:1462
U_HEADER_ONLY_NAMESPACE::CodePointRange
A contiguous range of code points in a USet/UnicodeSet.
Definition uset.h:1455
U_HEADER_ONLY_NAMESPACE::CodePointRange::begin
iterator begin() const
Definition uset.h:1500
U_HEADER_ONLY_NAMESPACE::CodePointRange::CodePointRange
CodePointRange(UChar32 start, UChar32 end)
Definition uset.h:1494
U_HEADER_ONLY_NAMESPACE::CodePointRange::size
size_t size() const
Definition uset.h:1498
U_HEADER_ONLY_NAMESPACE::CodePointRange::end
iterator end() const
Definition uset.h:1502
U_HEADER_ONLY_NAMESPACE::CodePointRange::rangeEnd
UChar32 rangeEnd
Inclusive end of a USet/UnicodeSet range of code points.
Definition uset.h:1513
U_HEADER_ONLY_NAMESPACE::CodePointRange::CodePointRange
CodePointRange(const CodePointRange &other)=default
U_HEADER_ONLY_NAMESPACE::CodePointRange::rangeStart
UChar32 rangeStart
Start of a USet/UnicodeSet range of code points.
Definition uset.h:1508
uchar.h
C API: Unicode Properties.
UProperty
UProperty
Selection constants for Unicode properties.
Definition uchar.h:196
UChar
char16_t UChar
The base type for UTF-16 code units and pointers.
Definition umachine.h:400
UChar32
int32_t UChar32
Define UChar32 as a type for single Unicode code points.
Definition umachine.h:449
UBool
int8_t UBool
The ICU boolean type, a signed-byte integer.
Definition umachine.h:269
U_CAPI
#define U_CAPI
This is used to declare a function as a public ICU C API.
Definition umachine.h:110
U_SENTINEL
#define U_SENTINEL
This value is intended for sentinel values for APIs that (take or) return single code points (UChar32...
Definition umachine.h:469
uset_containsAll
U_CAPI UBool uset_containsAll(const USet *set1, const USet *set2)
Returns true if set1 contains all the characters and strings of set2.
uset_hasStrings
U_CAPI UBool uset_hasStrings(const USet *set)
uset_getStringCount
U_CAPI int32_t uset_getStringCount(const USet *set)
uset_open
U_CAPI USet * uset_open(UChar32 start, UChar32 end)
Creates a USet object that contains the range of characters start..end, inclusive.
uset_serializedContains
U_CAPI UBool uset_serializedContains(const USerializedSet *set, UChar32 c)
Returns true if the given USerializedSet contains the given character.
uset_getSerializedSet
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.
uset_set
U_CAPI void uset_set(USet *set, UChar32 start, UChar32 end)
Causes the USet object to represent the range start - end.
uset_addString
U_CAPI void uset_addString(USet *set, const UChar *str, int32_t strLen)
Adds the given string to the given USet.
uset_containsString
U_CAPI UBool uset_containsString(const USet *set, const UChar *str, int32_t strLen)
Returns true if the given USet contains the given string.
uset_isEmpty
U_CAPI UBool uset_isEmpty(const USet *set)
Returns true if the given USet contains no characters and no strings.
uset_getItemCount
U_CAPI int32_t uset_getItemCount(const USet *set)
Returns the number of items in this set.
USET_IGNORE_SPACE
@ USET_IGNORE_SPACE
Ignore white space within patterns unless quoted or escaped.
Definition uset.h:73
USET_ADD_CASE_MAPPINGS
@ USET_ADD_CASE_MAPPINGS
Adds all case mappings for each element in the set.
Definition uset.h:114
USET_CASE_INSENSITIVE
@ USET_CASE_INSENSITIVE
Enable case insensitive matching.
Definition uset.h:101
USET_SIMPLE_CASE_INSENSITIVE
@ USET_SIMPLE_CASE_INSENSITIVE
Enable case insensitive matching.
Definition uset.h:128
USET_SERIALIZED_STATIC_ARRAY_CAPACITY
@ USET_SERIALIZED_STATIC_ARRAY_CAPACITY
Capacity of USerializedSet::staticArray.
Definition uset.h:251
uset_getSerializedRangeCount
U_CAPI int32_t uset_getSerializedRangeCount(const USerializedSet *set)
Returns the number of disjoint ranges of characters contained in the given serialized set.
uset_charAt
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 ...
uset_retainAll
U_CAPI void uset_retainAll(USet *set, const USet *retain)
Retains only the elements in this set that are contained in the specified set.
uset_setSerializedToOne
U_CAPI void uset_setSerializedToOne(USerializedSet *fillSet, UChar32 c)
Set the USerializedSet to contain the given character (and nothing else).
uset_complementString
U_CAPI void uset_complementString(USet *set, const UChar *str, int32_t length)
Complements the specified string in this set.
uset_applyIntPropertyValue
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...
uset_complementRange
U_CAPI void uset_complementRange(USet *set, UChar32 start, UChar32 end)
Complements the specified range in this set.
uset_resemblesPattern
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...
uset_addRange
U_CAPI void uset_addRange(USet *set, UChar32 start, UChar32 end)
Adds the given range of characters to the given USet.
uset_add
U_CAPI void uset_add(USet *set, UChar32 c)
Adds the given character to the given USet.
uset_complementAllCodePoints
U_CAPI void uset_complementAllCodePoints(USet *set, const UChar *str, int32_t length)
Complements EACH of the characters in this string.
uset_size
U_CAPI int32_t uset_size(const USet *set)
Returns the number of characters and strings contained in this set.
uset_span
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...
uset_openPatternOptions
U_CAPI USet * uset_openPatternOptions(const UChar *pattern, int32_t patternLength, uint32_t options, UErrorCode *ec)
Creates a set from the given pattern.
uset_removeAllStrings
U_CAPI void uset_removeAllStrings(USet *set)
Remove all strings from this set.
uset_clear
U_CAPI void uset_clear(USet *set)
Removes all of the elements from this set.
uset_removeAllCodePoints
U_CAPI void uset_removeAllCodePoints(USet *set, const UChar *str, int32_t length)
Removes EACH of the characters in this string.
USetSpanCondition
USetSpanCondition
Argument values for whether span() and similar functions continue while the current character is cont...
Definition uset.h:186
USET_SPAN_NOT_CONTAINED
@ USET_SPAN_NOT_CONTAINED
Continues a span() while there is no set element at the current position.
Definition uset.h:199
USET_SPAN_CONTAINED
@ 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
@ USET_SPAN_CONDITION_COUNT
One more than the last span condition.
Definition uset.h:240
USET_SPAN_SIMPLE
@ USET_SPAN_SIMPLE
Continues a span() while there is a set element at the current position.
Definition uset.h:234
uset_remove
U_CAPI void uset_remove(USet *set, UChar32 c)
Removes the given character from the given USet.
uset_openPattern
U_CAPI USet * uset_openPattern(const UChar *pattern, int32_t patternLength, UErrorCode *ec)
Creates a set from the given pattern.
uset_removeRange
U_CAPI void uset_removeRange(USet *set, UChar32 start, UChar32 end)
Removes the given range of characters from the given USet.
uset_openEmpty
U_CAPI USet * uset_openEmpty(void)
Create an empty USet object.
uset_equals
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.
uset_isFrozen
U_CAPI UBool uset_isFrozen(const USet *set)
Determines whether the set has been frozen (made immutable) or not.
uset_getRangeCount
U_CAPI int32_t uset_getRangeCount(const USet *set)
uset_cloneAsThawed
U_CAPI USet * uset_cloneAsThawed(const USet *set)
Clone the set and make the clone mutable.
uset_containsAllCodePoints
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.
uset_serialize
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.
uset_indexOf
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 ...
uset_clone
U_CAPI USet * uset_clone(const USet *set)
Returns a copy of this object.
uset_freeze
U_CAPI void uset_freeze(USet *set)
Freeze the set (make it immutable).
uset_spanUTF8
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...
uset_retain
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.
uset_toPattern
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.
uset_spanBackUTF8
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...
uset_complement
U_CAPI void uset_complement(USet *set)
This is equivalent to uset_complementRange(set, 0, 0x10FFFF).
uset_containsSome
U_CAPI UBool uset_containsSome(const USet *set1, const USet *set2)
Returns true if set1 contains some of the characters and strings of set2.
uset_spanBack
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...
uset_containsNone
U_CAPI UBool uset_containsNone(const USet *set1, const USet *set2)
Returns true if set1 contains none of the characters and strings of set2.
uset_retainAllCodePoints
U_CAPI void uset_retainAllCodePoints(USet *set, const UChar *str, int32_t length)
Retains EACH of the characters in this string.
uset_contains
U_CAPI UBool uset_contains(const USet *set, UChar32 c)
Returns true if the given USet contains the given character.
uset_applyPattern
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.
uset_complementAll
U_CAPI void uset_complementAll(USet *set, const USet *complement)
Complements in this set all elements contained in the specified set.
uset_applyPropertyAlias
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.
uset_close
U_CAPI void uset_close(USet *set)
Disposes of the storage used by a USet object.
USet
struct USet USet
USet is the C API type corresponding to C++ class UnicodeSet.
Definition uset.h:54
uset_getString
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.
uset_addAll
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.
uset_removeString
U_CAPI void uset_removeString(USet *set, const UChar *str, int32_t strLen)
Removes the given string to the given USet.
uset_compact
U_CAPI void uset_compact(USet *set)
Reallocate this objects internal structures to take up the least possible space, without changing thi...
uset_getItem
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.
uset_closeOver
U_CAPI void uset_closeOver(USet *set, int32_t attributes)
Close this set over the given attribute.
uset_addAllCodePoints
U_CAPI void uset_addAllCodePoints(USet *set, const UChar *str, int32_t strLen)
Adds each of the characters in this string to the set.
uset_retainString
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.
uset_removeAll
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.
uset_containsRange
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.
uset_getSerializedRange
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.
utf16.h
C API: 16-bit Unicode handling macros.
U16_TRAIL
#define U16_TRAIL(supplementary)
Get the trail surrogate (0xdc00..0xdfff) for a supplementary code point (0x10000.....
Definition utf16.h:132
U16_LEAD
#define U16_LEAD(supplementary)
Get the lead surrogate (0xd800..0xdbff) for a supplementary code point (0x10000..0x10ffff).
Definition utf16.h:123
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
UErrorCode
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition utypes.h:509
U_ZERO_ERROR
@ U_ZERO_ERROR
No error, no warning.
Definition utypes.h:544
U_SUCCESS
#define U_SUCCESS(x)
Does the error code indicate success?
Definition utypes.h:822