jpayne@69: // © 2016 and later: Unicode, Inc. and others. jpayne@69: // License & terms of use: http://www.unicode.org/copyright.html jpayne@69: /* jpayne@69: ******************************************************************************* jpayne@69: * jpayne@69: * Copyright (C) 2002-2014, International Business Machines jpayne@69: * Corporation and others. All Rights Reserved. jpayne@69: * jpayne@69: ******************************************************************************* jpayne@69: * file name: uset.h jpayne@69: * encoding: UTF-8 jpayne@69: * tab size: 8 (not used) jpayne@69: * indentation:4 jpayne@69: * jpayne@69: * created on: 2002mar07 jpayne@69: * created by: Markus W. Scherer jpayne@69: * jpayne@69: * C version of UnicodeSet. jpayne@69: */ jpayne@69: jpayne@69: jpayne@69: /** jpayne@69: * \file jpayne@69: * \brief C API: Unicode Set jpayne@69: * jpayne@69: *
This is a C wrapper around the C++ UnicodeSet class.
jpayne@69: */ jpayne@69: jpayne@69: #ifndef __USET_H__ jpayne@69: #define __USET_H__ jpayne@69: jpayne@69: #include "unicode/utypes.h" jpayne@69: #include "unicode/uchar.h" jpayne@69: #include "unicode/localpointer.h" jpayne@69: jpayne@69: #ifndef USET_DEFINED jpayne@69: jpayne@69: #ifndef U_IN_DOXYGEN jpayne@69: #define USET_DEFINED jpayne@69: #endif jpayne@69: /** jpayne@69: * USet is the C API type corresponding to C++ class UnicodeSet. jpayne@69: * Use the uset_* API to manipulate. Create with jpayne@69: * uset_open*, and destroy with uset_close. jpayne@69: * @stable ICU 2.4 jpayne@69: */ jpayne@69: typedef struct USet USet; jpayne@69: #endif jpayne@69: jpayne@69: /** jpayne@69: * Bitmask values to be passed to uset_openPatternOptions() or jpayne@69: * uset_applyPattern() taking an option parameter. jpayne@69: * @stable ICU 2.4 jpayne@69: */ jpayne@69: enum { jpayne@69: /** jpayne@69: * Ignore white space within patterns unless quoted or escaped. jpayne@69: * @stable ICU 2.4 jpayne@69: */ jpayne@69: USET_IGNORE_SPACE = 1, jpayne@69: jpayne@69: /** jpayne@69: * Enable case insensitive matching. E.g., "[ab]" with this flag jpayne@69: * will match 'a', 'A', 'b', and 'B'. "[^ab]" with this flag will jpayne@69: * match all except 'a', 'A', 'b', and 'B'. This performs a full jpayne@69: * closure over case mappings, e.g. U+017F for s. jpayne@69: * jpayne@69: * The resulting set is a superset of the input for the code points but jpayne@69: * not for the strings. jpayne@69: * It performs a case mapping closure of the code points and adds jpayne@69: * full case folding strings for the code points, and reduces strings of jpayne@69: * the original set to their full case folding equivalents. jpayne@69: * jpayne@69: * This is designed for case-insensitive matches, for example jpayne@69: * in regular expressions. The full code point case closure allows checking of jpayne@69: * an input character directly against the closure set. jpayne@69: * Strings are matched by comparing the case-folded form from the closure jpayne@69: * set with an incremental case folding of the string in question. jpayne@69: * jpayne@69: * The closure set will also contain single code points if the original jpayne@69: * set contained case-equivalent strings (like U+00DF for "ss" or "Ss" etc.). jpayne@69: * This is not necessary (that is, redundant) for the above matching method jpayne@69: * but results in the same closure sets regardless of whether the original jpayne@69: * set contained the code point or a string. jpayne@69: * jpayne@69: * @stable ICU 2.4 jpayne@69: */ jpayne@69: USET_CASE_INSENSITIVE = 2, jpayne@69: jpayne@69: /** jpayne@69: * Enable case insensitive matching. E.g., "[ab]" with this flag jpayne@69: * will match 'a', 'A', 'b', and 'B'. "[^ab]" with this flag will jpayne@69: * match all except 'a', 'A', 'b', and 'B'. This adds the lower-, jpayne@69: * title-, and uppercase mappings as well as the case folding jpayne@69: * of each existing element in the set. jpayne@69: * @stable ICU 3.2 jpayne@69: */ jpayne@69: USET_ADD_CASE_MAPPINGS = 4 jpayne@69: }; jpayne@69: jpayne@69: /** jpayne@69: * Argument values for whether span() and similar functions continue while jpayne@69: * the current character is contained vs. not contained in the set. jpayne@69: * jpayne@69: * The functionality is straightforward for sets with only single code points, jpayne@69: * without strings (which is the common case): jpayne@69: * - USET_SPAN_CONTAINED and USET_SPAN_SIMPLE work the same. jpayne@69: * - USET_SPAN_CONTAINED and USET_SPAN_SIMPLE are inverses of USET_SPAN_NOT_CONTAINED. jpayne@69: * - span() and spanBack() partition any string the same way when jpayne@69: * alternating between span(USET_SPAN_NOT_CONTAINED) and jpayne@69: * span(either "contained" condition). jpayne@69: * - Using a complemented (inverted) set and the opposite span conditions jpayne@69: * yields the same results. jpayne@69: * jpayne@69: * When a set contains multi-code point strings, then these statements may not jpayne@69: * be true, depending on the strings in the set (for example, whether they jpayne@69: * overlap with each other) and the string that is processed. jpayne@69: * For a set with strings: jpayne@69: * - The complement of the set contains the opposite set of code points, jpayne@69: * but the same set of strings. jpayne@69: * Therefore, complementing both the set and the span conditions jpayne@69: * may yield different results. jpayne@69: * - When starting spans at different positions in a string jpayne@69: * (span(s, ...) vs. span(s+1, ...)) the ends of the spans may be different jpayne@69: * because a set string may start before the later position. jpayne@69: * - span(USET_SPAN_SIMPLE) may be shorter than jpayne@69: * span(USET_SPAN_CONTAINED) because it will not recursively try jpayne@69: * all possible paths. jpayne@69: * For example, with a set which contains the three strings "xy", "xya" and "ax", jpayne@69: * span("xyax", USET_SPAN_CONTAINED) will return 4 but jpayne@69: * span("xyax", USET_SPAN_SIMPLE) will return 3. jpayne@69: * span(USET_SPAN_SIMPLE) will never be longer than jpayne@69: * span(USET_SPAN_CONTAINED). jpayne@69: * - With either "contained" condition, span() and spanBack() may partition jpayne@69: * a string in different ways. jpayne@69: * For example, with a set which contains the two strings "ab" and "ba", jpayne@69: * and when processing the string "aba", jpayne@69: * span() will yield contained/not-contained boundaries of { 0, 2, 3 } jpayne@69: * while spanBack() will yield boundaries of { 0, 1, 3 }. jpayne@69: * jpayne@69: * Note: If it is important to get the same boundaries whether iterating forward jpayne@69: * or backward through a string, then either only span() should be used and jpayne@69: * the boundaries cached for backward operation, or an ICU BreakIterator jpayne@69: * could be used. jpayne@69: * jpayne@69: * Note: Unpaired surrogates are treated like surrogate code points. jpayne@69: * Similarly, set strings match only on code point boundaries, jpayne@69: * never in the middle of a surrogate pair. jpayne@69: * Illegal UTF-8 sequences are treated like U+FFFD. jpayne@69: * When processing UTF-8 strings, malformed set strings jpayne@69: * (strings with unpaired surrogates which cannot be converted to UTF-8) jpayne@69: * are ignored. jpayne@69: * jpayne@69: * @stable ICU 3.8 jpayne@69: */ jpayne@69: typedef enum USetSpanCondition { jpayne@69: /** jpayne@69: * Continues a span() while there is no set element at the current position. jpayne@69: * Increments by one code point at a time. jpayne@69: * Stops before the first set element (character or string). jpayne@69: * (For code points only, this is like while contains(current)==FALSE). jpayne@69: * jpayne@69: * When span() returns, the substring between where it started and the position jpayne@69: * it returned consists only of characters that are not in the set, jpayne@69: * and none of its strings overlap with the span. jpayne@69: * jpayne@69: * @stable ICU 3.8 jpayne@69: */ jpayne@69: USET_SPAN_NOT_CONTAINED = 0, jpayne@69: /** jpayne@69: * Spans the longest substring that is a concatenation of set elements (characters or strings). jpayne@69: * (For characters only, this is like while contains(current)==TRUE). jpayne@69: * jpayne@69: * When span() returns, the substring between where it started and the position jpayne@69: * it returned consists only of set elements (characters or strings) that are in the set. jpayne@69: * jpayne@69: * If a set contains strings, then the span will be the longest substring for which there jpayne@69: * exists at least one non-overlapping concatenation of set elements (characters or strings). jpayne@69: * This is equivalent to a POSIX regular expression for(OR of each set element)*
.
jpayne@69: * (Java/ICU/Perl regex stops at the first match of an OR.)
jpayne@69: *
jpayne@69: * @stable ICU 3.8
jpayne@69: */
jpayne@69: USET_SPAN_CONTAINED = 1,
jpayne@69: /**
jpayne@69: * Continues a span() while there is a set element at the current position.
jpayne@69: * Increments by the longest matching element at each position.
jpayne@69: * (For characters only, this is like while contains(current)==TRUE).
jpayne@69: *
jpayne@69: * When span() returns, the substring between where it started and the position
jpayne@69: * it returned consists only of set elements (characters or strings) that are in the set.
jpayne@69: *
jpayne@69: * If a set only contains single characters, then this is the same
jpayne@69: * as USET_SPAN_CONTAINED.
jpayne@69: *
jpayne@69: * If a set contains strings, then the span will be the longest substring
jpayne@69: * with a match at each position with the longest single set element (character or string).
jpayne@69: *
jpayne@69: * Use this span condition together with other longest-match algorithms,
jpayne@69: * such as ICU converters (ucnv_getUnicodeSet()).
jpayne@69: *
jpayne@69: * @stable ICU 3.8
jpayne@69: */
jpayne@69: USET_SPAN_SIMPLE = 2,
jpayne@69: #ifndef U_HIDE_DEPRECATED_API
jpayne@69: /**
jpayne@69: * One more than the last span condition.
jpayne@69: * @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420.
jpayne@69: */
jpayne@69: USET_SPAN_CONDITION_COUNT
jpayne@69: #endif // U_HIDE_DEPRECATED_API
jpayne@69: } USetSpanCondition;
jpayne@69:
jpayne@69: enum {
jpayne@69: /**
jpayne@69: * Capacity of USerializedSet::staticArray.
jpayne@69: * Enough for any single-code point set.
jpayne@69: * Also provides padding for nice sizeof(USerializedSet).
jpayne@69: * @stable ICU 2.4
jpayne@69: */
jpayne@69: USET_SERIALIZED_STATIC_ARRAY_CAPACITY=8
jpayne@69: };
jpayne@69:
jpayne@69: /**
jpayne@69: * A serialized form of a Unicode set. Limited manipulations are
jpayne@69: * possible directly on a serialized set. See below.
jpayne@69: * @stable ICU 2.4
jpayne@69: */
jpayne@69: typedef struct USerializedSet {
jpayne@69: /**
jpayne@69: * The serialized Unicode Set.
jpayne@69: * @stable ICU 2.4
jpayne@69: */
jpayne@69: const uint16_t *array;
jpayne@69: /**
jpayne@69: * The length of the array that contains BMP characters.
jpayne@69: * @stable ICU 2.4
jpayne@69: */
jpayne@69: int32_t bmpLength;
jpayne@69: /**
jpayne@69: * The total length of the array.
jpayne@69: * @stable ICU 2.4
jpayne@69: */
jpayne@69: int32_t length;
jpayne@69: /**
jpayne@69: * A small buffer for the array to reduce memory allocations.
jpayne@69: * @stable ICU 2.4
jpayne@69: */
jpayne@69: uint16_t staticArray[USET_SERIALIZED_STATIC_ARRAY_CAPACITY];
jpayne@69: } USerializedSet;
jpayne@69:
jpayne@69: /*********************************************************************
jpayne@69: * USet API
jpayne@69: *********************************************************************/
jpayne@69:
jpayne@69: /**
jpayne@69: * Create an empty USet object.
jpayne@69: * Equivalent to uset_open(1, 0).
jpayne@69: * @return a newly created USet. The caller must call uset_close() on
jpayne@69: * it when done.
jpayne@69: * @stable ICU 4.2
jpayne@69: */
jpayne@69: U_STABLE USet* U_EXPORT2
jpayne@69: uset_openEmpty(void);
jpayne@69:
jpayne@69: /**
jpayne@69: * Creates a USet object that contains the range of characters
jpayne@69: * start..end, inclusive. If start > end
jpayne@69: * then an empty set is created (same as using uset_openEmpty()).
jpayne@69: * @param start first character of the range, inclusive
jpayne@69: * @param end last character of the range, inclusive
jpayne@69: * @return a newly created USet. The caller must call uset_close() on
jpayne@69: * it when done.
jpayne@69: * @stable ICU 2.4
jpayne@69: */
jpayne@69: U_STABLE USet* U_EXPORT2
jpayne@69: uset_open(UChar32 start, UChar32 end);
jpayne@69:
jpayne@69: /**
jpayne@69: * Creates a set from the given pattern. See the UnicodeSet class
jpayne@69: * description for the syntax of the pattern language.
jpayne@69: * @param pattern a string specifying what characters are in the set
jpayne@69: * @param patternLength the length of the pattern, or -1 if null
jpayne@69: * terminated
jpayne@69: * @param ec the error code
jpayne@69: * @stable ICU 2.4
jpayne@69: */
jpayne@69: U_STABLE USet* U_EXPORT2
jpayne@69: uset_openPattern(const UChar* pattern, int32_t patternLength,
jpayne@69: UErrorCode* ec);
jpayne@69:
jpayne@69: /**
jpayne@69: * Creates a set from the given pattern. See the UnicodeSet class
jpayne@69: * description for the syntax of the pattern language.
jpayne@69: * @param pattern a string specifying what characters are in the set
jpayne@69: * @param patternLength the length of the pattern, or -1 if null
jpayne@69: * terminated
jpayne@69: * @param options bitmask for options to apply to the pattern.
jpayne@69: * Valid options are USET_IGNORE_SPACE and USET_CASE_INSENSITIVE.
jpayne@69: * @param ec the error code
jpayne@69: * @stable ICU 2.4
jpayne@69: */
jpayne@69: U_STABLE USet* U_EXPORT2
jpayne@69: uset_openPatternOptions(const UChar* pattern, int32_t patternLength,
jpayne@69: uint32_t options,
jpayne@69: UErrorCode* ec);
jpayne@69:
jpayne@69: /**
jpayne@69: * Disposes of the storage used by a USet object. This function should
jpayne@69: * be called exactly once for objects returned by uset_open().
jpayne@69: * @param set the object to dispose of
jpayne@69: * @stable ICU 2.4
jpayne@69: */
jpayne@69: U_STABLE void U_EXPORT2
jpayne@69: uset_close(USet* set);
jpayne@69:
jpayne@69: #if U_SHOW_CPLUSPLUS_API
jpayne@69:
jpayne@69: U_NAMESPACE_BEGIN
jpayne@69:
jpayne@69: /**
jpayne@69: * \class LocalUSetPointer
jpayne@69: * "Smart pointer" class, closes a USet via uset_close().
jpayne@69: * For most methods see the LocalPointerBase base class.
jpayne@69: *
jpayne@69: * @see LocalPointerBase
jpayne@69: * @see LocalPointer
jpayne@69: * @stable ICU 4.4
jpayne@69: */
jpayne@69: U_DEFINE_LOCAL_OPEN_POINTER(LocalUSetPointer, USet, uset_close);
jpayne@69:
jpayne@69: U_NAMESPACE_END
jpayne@69:
jpayne@69: #endif
jpayne@69:
jpayne@69: /**
jpayne@69: * Returns a copy of this object.
jpayne@69: * If this set is frozen, then the clone will be frozen as well.
jpayne@69: * Use uset_cloneAsThawed() for a mutable clone of a frozen set.
jpayne@69: * @param set the original set
jpayne@69: * @return the newly allocated copy of the set
jpayne@69: * @see uset_cloneAsThawed
jpayne@69: * @stable ICU 3.8
jpayne@69: */
jpayne@69: U_STABLE USet * U_EXPORT2
jpayne@69: uset_clone(const USet *set);
jpayne@69:
jpayne@69: /**
jpayne@69: * Determines whether the set has been frozen (made immutable) or not.
jpayne@69: * See the ICU4J Freezable interface for details.
jpayne@69: * @param set the set
jpayne@69: * @return TRUE/FALSE for whether the set has been frozen
jpayne@69: * @see uset_freeze
jpayne@69: * @see uset_cloneAsThawed
jpayne@69: * @stable ICU 3.8
jpayne@69: */
jpayne@69: U_STABLE UBool U_EXPORT2
jpayne@69: uset_isFrozen(const USet *set);
jpayne@69:
jpayne@69: /**
jpayne@69: * Freeze the set (make it immutable).
jpayne@69: * Once frozen, it cannot be unfrozen and is therefore thread-safe
jpayne@69: * until it is deleted.
jpayne@69: * See the ICU4J Freezable interface for details.
jpayne@69: * Freezing the set may also make some operations faster, for example
jpayne@69: * uset_contains() and uset_span().
jpayne@69: * A frozen set will not be modified. (It remains frozen.)
jpayne@69: * @param set the set
jpayne@69: * @return the same set, now frozen
jpayne@69: * @see uset_isFrozen
jpayne@69: * @see uset_cloneAsThawed
jpayne@69: * @stable ICU 3.8
jpayne@69: */
jpayne@69: U_STABLE void U_EXPORT2
jpayne@69: uset_freeze(USet *set);
jpayne@69:
jpayne@69: /**
jpayne@69: * Clone the set and make the clone mutable.
jpayne@69: * See the ICU4J Freezable interface for details.
jpayne@69: * @param set the set
jpayne@69: * @return the mutable clone
jpayne@69: * @see uset_freeze
jpayne@69: * @see uset_isFrozen
jpayne@69: * @see uset_clone
jpayne@69: * @stable ICU 3.8
jpayne@69: */
jpayne@69: U_STABLE USet * U_EXPORT2
jpayne@69: uset_cloneAsThawed(const USet *set);
jpayne@69:
jpayne@69: /**
jpayne@69: * Causes the USet object to represent the range start - end
.
jpayne@69: * If start > end
then this USet is set to an empty range.
jpayne@69: * A frozen set will not be modified.
jpayne@69: * @param set the object to set to the given range
jpayne@69: * @param start first character in the set, inclusive
jpayne@69: * @param end last character in the set, inclusive
jpayne@69: * @stable ICU 3.2
jpayne@69: */
jpayne@69: U_STABLE void U_EXPORT2
jpayne@69: uset_set(USet* set,
jpayne@69: UChar32 start, UChar32 end);
jpayne@69:
jpayne@69: /**
jpayne@69: * Modifies the set to represent the set specified by the given
jpayne@69: * pattern. See the UnicodeSet class description for the syntax of
jpayne@69: * the pattern language. See also the User Guide chapter about UnicodeSet.
jpayne@69: * Empties the set passed before applying the pattern.
jpayne@69: * A frozen set will not be modified.
jpayne@69: * @param set The set to which the pattern is to be applied.
jpayne@69: * @param pattern A pointer to UChar string specifying what characters are in the set.
jpayne@69: * The character at pattern[0] must be a '['.
jpayne@69: * @param patternLength The length of the UChar string. -1 if NUL terminated.
jpayne@69: * @param options A bitmask for options to apply to the pattern.
jpayne@69: * Valid options are USET_IGNORE_SPACE and USET_CASE_INSENSITIVE.
jpayne@69: * @param status Returns an error if the pattern cannot be parsed.
jpayne@69: * @return Upon successful parse, the value is either
jpayne@69: * the index of the character after the closing ']'
jpayne@69: * of the parsed pattern.
jpayne@69: * If the status code indicates failure, then the return value
jpayne@69: * is the index of the error in the source.
jpayne@69: *
jpayne@69: * @stable ICU 2.8
jpayne@69: */
jpayne@69: U_STABLE int32_t U_EXPORT2
jpayne@69: uset_applyPattern(USet *set,
jpayne@69: const UChar *pattern, int32_t patternLength,
jpayne@69: uint32_t options,
jpayne@69: UErrorCode *status);
jpayne@69:
jpayne@69: /**
jpayne@69: * Modifies the set to contain those code points which have the given value
jpayne@69: * for the given binary or enumerated property, as returned by
jpayne@69: * u_getIntPropertyValue. Prior contents of this set are lost.
jpayne@69: * A frozen set will not be modified.
jpayne@69: *
jpayne@69: * @param set the object to contain the code points defined by the property
jpayne@69: *
jpayne@69: * @param prop a property in the range UCHAR_BIN_START..UCHAR_BIN_LIMIT-1
jpayne@69: * or UCHAR_INT_START..UCHAR_INT_LIMIT-1
jpayne@69: * or UCHAR_MASK_START..UCHAR_MASK_LIMIT-1.
jpayne@69: *
jpayne@69: * @param value a value in the range u_getIntPropertyMinValue(prop)..
jpayne@69: * u_getIntPropertyMaxValue(prop), with one exception. If prop is
jpayne@69: * UCHAR_GENERAL_CATEGORY_MASK, then value should not be a UCharCategory, but
jpayne@69: * rather a mask value produced by U_GET_GC_MASK(). This allows grouped
jpayne@69: * categories such as [:L:] to be represented.
jpayne@69: *
jpayne@69: * @param ec error code input/output parameter
jpayne@69: *
jpayne@69: * @stable ICU 3.2
jpayne@69: */
jpayne@69: U_STABLE void U_EXPORT2
jpayne@69: uset_applyIntPropertyValue(USet* set,
jpayne@69: UProperty prop, int32_t value, UErrorCode* ec);
jpayne@69:
jpayne@69: /**
jpayne@69: * Modifies the set to contain those code points which have the
jpayne@69: * given value for the given property. Prior contents of this
jpayne@69: * set are lost.
jpayne@69: * A frozen set will not be modified.
jpayne@69: *
jpayne@69: * @param set the object to contain the code points defined by the given
jpayne@69: * property and value alias
jpayne@69: *
jpayne@69: * @param prop a string specifying a property alias, either short or long.
jpayne@69: * The name is matched loosely. See PropertyAliases.txt for names and a
jpayne@69: * description of loose matching. If the value string is empty, then this
jpayne@69: * string is interpreted as either a General_Category value alias, a Script
jpayne@69: * value alias, a binary property alias, or a special ID. Special IDs are
jpayne@69: * matched loosely and correspond to the following sets:
jpayne@69: *
jpayne@69: * "ANY" = [\\u0000-\\U0010FFFF],
jpayne@69: * "ASCII" = [\\u0000-\\u007F],
jpayne@69: * "Assigned" = [:^Cn:].
jpayne@69: *
jpayne@69: * @param propLength the length of the prop, or -1 if NULL
jpayne@69: *
jpayne@69: * @param value a string specifying a value alias, either short or long.
jpayne@69: * The name is matched loosely. See PropertyValueAliases.txt for names
jpayne@69: * and a description of loose matching. In addition to aliases listed,
jpayne@69: * numeric values and canonical combining classes may be expressed
jpayne@69: * numerically, e.g., ("nv", "0.5") or ("ccc", "220"). The value string
jpayne@69: * may also be empty.
jpayne@69: *
jpayne@69: * @param valueLength the length of the value, or -1 if NULL
jpayne@69: *
jpayne@69: * @param ec error code input/output parameter
jpayne@69: *
jpayne@69: * @stable ICU 3.2
jpayne@69: */
jpayne@69: U_STABLE void U_EXPORT2
jpayne@69: uset_applyPropertyAlias(USet* set,
jpayne@69: const UChar *prop, int32_t propLength,
jpayne@69: const UChar *value, int32_t valueLength,
jpayne@69: UErrorCode* ec);
jpayne@69:
jpayne@69: /**
jpayne@69: * Return true if the given position, in the given pattern, appears
jpayne@69: * to be the start of a UnicodeSet pattern.
jpayne@69: *
jpayne@69: * @param pattern a string specifying the pattern
jpayne@69: * @param patternLength the length of the pattern, or -1 if NULL
jpayne@69: * @param pos the given position
jpayne@69: * @stable ICU 3.2
jpayne@69: */
jpayne@69: U_STABLE UBool U_EXPORT2
jpayne@69: uset_resemblesPattern(const UChar *pattern, int32_t patternLength,
jpayne@69: int32_t pos);
jpayne@69:
jpayne@69: /**
jpayne@69: * Returns a string representation of this set. If the result of
jpayne@69: * calling this function is passed to a uset_openPattern(), it
jpayne@69: * will produce another set that is equal to this one.
jpayne@69: * @param set the set
jpayne@69: * @param result the string to receive the rules, may be NULL
jpayne@69: * @param resultCapacity the capacity of result, may be 0 if result is NULL
jpayne@69: * @param escapeUnprintable if TRUE then convert unprintable
jpayne@69: * character to their hex escape representations, \\uxxxx or
jpayne@69: * \\Uxxxxxxxx. Unprintable characters are those other than
jpayne@69: * U+000A, U+0020..U+007E.
jpayne@69: * @param ec error code.
jpayne@69: * @return length of string, possibly larger than resultCapacity
jpayne@69: * @stable ICU 2.4
jpayne@69: */
jpayne@69: U_STABLE int32_t U_EXPORT2
jpayne@69: uset_toPattern(const USet* set,
jpayne@69: UChar* result, int32_t resultCapacity,
jpayne@69: UBool escapeUnprintable,
jpayne@69: UErrorCode* ec);
jpayne@69:
jpayne@69: /**
jpayne@69: * Adds the given character to the given USet. After this call,
jpayne@69: * uset_contains(set, c) will return TRUE.
jpayne@69: * A frozen set will not be modified.
jpayne@69: * @param set the object to which to add the character
jpayne@69: * @param c the character to add
jpayne@69: * @stable ICU 2.4
jpayne@69: */
jpayne@69: U_STABLE void U_EXPORT2
jpayne@69: uset_add(USet* set, UChar32 c);
jpayne@69:
jpayne@69: /**
jpayne@69: * Adds all of the elements in the specified set to this set if
jpayne@69: * they're not already present. This operation effectively
jpayne@69: * modifies this set so that its value is the union of the two
jpayne@69: * sets. The behavior of this operation is unspecified if the specified
jpayne@69: * collection is modified while the operation is in progress.
jpayne@69: * A frozen set will not be modified.
jpayne@69: *
jpayne@69: * @param set the object to which to add the set
jpayne@69: * @param additionalSet the source set whose elements are to be added to this set.
jpayne@69: * @stable ICU 2.6
jpayne@69: */
jpayne@69: U_STABLE void U_EXPORT2
jpayne@69: uset_addAll(USet* set, const USet *additionalSet);
jpayne@69:
jpayne@69: /**
jpayne@69: * Adds the given range of characters to the given USet. After this call,
jpayne@69: * uset_contains(set, start, end) will return TRUE.
jpayne@69: * A frozen set will not be modified.
jpayne@69: * @param set the object to which to add the character
jpayne@69: * @param start the first character of the range to add, inclusive
jpayne@69: * @param end the last character of the range to add, inclusive
jpayne@69: * @stable ICU 2.2
jpayne@69: */
jpayne@69: U_STABLE void U_EXPORT2
jpayne@69: uset_addRange(USet* set, UChar32 start, UChar32 end);
jpayne@69:
jpayne@69: /**
jpayne@69: * Adds the given string to the given USet. After this call,
jpayne@69: * uset_containsString(set, str, strLen) will return TRUE.
jpayne@69: * A frozen set will not be modified.
jpayne@69: * @param set the object to which to add the character
jpayne@69: * @param str the string to add
jpayne@69: * @param strLen the length of the string or -1 if null terminated.
jpayne@69: * @stable ICU 2.4
jpayne@69: */
jpayne@69: U_STABLE void U_EXPORT2
jpayne@69: uset_addString(USet* set, const UChar* str, int32_t strLen);
jpayne@69:
jpayne@69: /**
jpayne@69: * Adds each of the characters in this string to the set. Thus "ch" => {"c", "h"}
jpayne@69: * If this set already any particular character, it has no effect on that character.
jpayne@69: * A frozen set will not be modified.
jpayne@69: * @param set the object to which to add the character
jpayne@69: * @param str the source string
jpayne@69: * @param strLen the length of the string or -1 if null terminated.
jpayne@69: * @stable ICU 3.4
jpayne@69: */
jpayne@69: U_STABLE void U_EXPORT2
jpayne@69: uset_addAllCodePoints(USet* set, const UChar *str, int32_t strLen);
jpayne@69:
jpayne@69: /**
jpayne@69: * Removes the given character from the given USet. After this call,
jpayne@69: * uset_contains(set, c) will return FALSE.
jpayne@69: * A frozen set will not be modified.
jpayne@69: * @param set the object from which to remove the character
jpayne@69: * @param c the character to remove
jpayne@69: * @stable ICU 2.4
jpayne@69: */
jpayne@69: U_STABLE void U_EXPORT2
jpayne@69: uset_remove(USet* set, UChar32 c);
jpayne@69:
jpayne@69: /**
jpayne@69: * Removes the given range of characters from the given USet. After this call,
jpayne@69: * uset_contains(set, start, end) will return FALSE.
jpayne@69: * A frozen set will not be modified.
jpayne@69: * @param set the object to which to add the character
jpayne@69: * @param start the first character of the range to remove, inclusive
jpayne@69: * @param end the last character of the range to remove, inclusive
jpayne@69: * @stable ICU 2.2
jpayne@69: */
jpayne@69: U_STABLE void U_EXPORT2
jpayne@69: uset_removeRange(USet* set, UChar32 start, UChar32 end);
jpayne@69:
jpayne@69: /**
jpayne@69: * Removes the given string to the given USet. After this call,
jpayne@69: * uset_containsString(set, str, strLen) will return FALSE.
jpayne@69: * A frozen set will not be modified.
jpayne@69: * @param set the object to which to add the character
jpayne@69: * @param str the string to remove
jpayne@69: * @param strLen the length of the string or -1 if null terminated.
jpayne@69: * @stable ICU 2.4
jpayne@69: */
jpayne@69: U_STABLE void U_EXPORT2
jpayne@69: uset_removeString(USet* set, const UChar* str, int32_t strLen);
jpayne@69:
jpayne@69: /**
jpayne@69: * Removes from this set all of its elements that are contained in the
jpayne@69: * specified set. This operation effectively modifies this
jpayne@69: * set so that its value is the asymmetric set difference of
jpayne@69: * the two sets.
jpayne@69: * A frozen set will not be modified.
jpayne@69: * @param set the object from which the elements are to be removed
jpayne@69: * @param removeSet the object that defines which elements will be
jpayne@69: * removed from this set
jpayne@69: * @stable ICU 3.2
jpayne@69: */
jpayne@69: U_STABLE void U_EXPORT2
jpayne@69: uset_removeAll(USet* set, const USet* removeSet);
jpayne@69:
jpayne@69: /**
jpayne@69: * Retain only the elements in this set that are contained in the
jpayne@69: * specified range. If start > end
then an empty range is
jpayne@69: * retained, leaving the set empty. This is equivalent to
jpayne@69: * a boolean logic AND, or a set INTERSECTION.
jpayne@69: * A frozen set will not be modified.
jpayne@69: *
jpayne@69: * @param set the object for which to retain only the specified range
jpayne@69: * @param start first character, inclusive, of range to be retained
jpayne@69: * to this set.
jpayne@69: * @param end last character, inclusive, of range to be retained
jpayne@69: * to this set.
jpayne@69: * @stable ICU 3.2
jpayne@69: */
jpayne@69: U_STABLE void U_EXPORT2
jpayne@69: uset_retain(USet* set, UChar32 start, UChar32 end);
jpayne@69:
jpayne@69: /**
jpayne@69: * Retains only the elements in this set that are contained in the
jpayne@69: * specified set. In other words, removes from this set all of
jpayne@69: * its elements that are not contained in the specified set. This
jpayne@69: * operation effectively modifies this set so that its value is
jpayne@69: * the intersection of the two sets.
jpayne@69: * A frozen set will not be modified.
jpayne@69: *
jpayne@69: * @param set the object on which to perform the retain
jpayne@69: * @param retain set that defines which elements this set will retain
jpayne@69: * @stable ICU 3.2
jpayne@69: */
jpayne@69: U_STABLE void U_EXPORT2
jpayne@69: uset_retainAll(USet* set, const USet* retain);
jpayne@69:
jpayne@69: /**
jpayne@69: * Reallocate this objects internal structures to take up the least
jpayne@69: * possible space, without changing this object's value.
jpayne@69: * A frozen set will not be modified.
jpayne@69: *
jpayne@69: * @param set the object on which to perfrom the compact
jpayne@69: * @stable ICU 3.2
jpayne@69: */
jpayne@69: U_STABLE void U_EXPORT2
jpayne@69: uset_compact(USet* set);
jpayne@69:
jpayne@69: /**
jpayne@69: * Inverts this set. This operation modifies this set so that
jpayne@69: * its value is its complement. This operation does not affect
jpayne@69: * the multicharacter strings, if any.
jpayne@69: * A frozen set will not be modified.
jpayne@69: * @param set the set
jpayne@69: * @stable ICU 2.4
jpayne@69: */
jpayne@69: U_STABLE void U_EXPORT2
jpayne@69: uset_complement(USet* set);
jpayne@69:
jpayne@69: /**
jpayne@69: * Complements in this set all elements contained in the specified
jpayne@69: * set. Any character in the other set will be removed if it is
jpayne@69: * in this set, or will be added if it is not in this set.
jpayne@69: * A frozen set will not be modified.
jpayne@69: *
jpayne@69: * @param set the set with which to complement
jpayne@69: * @param complement set that defines which elements will be xor'ed
jpayne@69: * from this set.
jpayne@69: * @stable ICU 3.2
jpayne@69: */
jpayne@69: U_STABLE void U_EXPORT2
jpayne@69: uset_complementAll(USet* set, const USet* complement);
jpayne@69:
jpayne@69: /**
jpayne@69: * Removes all of the elements from this set. This set will be
jpayne@69: * empty after this call returns.
jpayne@69: * A frozen set will not be modified.
jpayne@69: * @param set the set
jpayne@69: * @stable ICU 2.4
jpayne@69: */
jpayne@69: U_STABLE void U_EXPORT2
jpayne@69: uset_clear(USet* set);
jpayne@69:
jpayne@69: /**
jpayne@69: * Close this set over the given attribute. For the attribute
jpayne@69: * USET_CASE, the result is to modify this set so that:
jpayne@69: *
jpayne@69: * 1. For each character or string 'a' in this set, all strings or
jpayne@69: * characters 'b' such that foldCase(a) == foldCase(b) are added
jpayne@69: * to this set.
jpayne@69: *
jpayne@69: * 2. For each string 'e' in the resulting set, if e !=
jpayne@69: * foldCase(e), 'e' will be removed.
jpayne@69: *
jpayne@69: * Example: [aq\\u00DF{Bc}{bC}{Fi}] => [aAqQ\\u00DF\\uFB01{ss}{bc}{fi}]
jpayne@69: *
jpayne@69: * (Here foldCase(x) refers to the operation u_strFoldCase, and a
jpayne@69: * == b denotes that the contents are the same, not pointer
jpayne@69: * comparison.)
jpayne@69: *
jpayne@69: * A frozen set will not be modified.
jpayne@69: *
jpayne@69: * @param set the set
jpayne@69: *
jpayne@69: * @param attributes bitmask for attributes to close over.
jpayne@69: * Currently only the USET_CASE bit is supported. Any undefined bits
jpayne@69: * are ignored.
jpayne@69: * @stable ICU 4.2
jpayne@69: */
jpayne@69: U_STABLE void U_EXPORT2
jpayne@69: uset_closeOver(USet* set, int32_t attributes);
jpayne@69:
jpayne@69: /**
jpayne@69: * Remove all strings from this set.
jpayne@69: *
jpayne@69: * @param set the set
jpayne@69: * @stable ICU 4.2
jpayne@69: */
jpayne@69: U_STABLE void U_EXPORT2
jpayne@69: uset_removeAllStrings(USet* set);
jpayne@69:
jpayne@69: /**
jpayne@69: * Returns TRUE if the given USet contains no characters and no
jpayne@69: * strings.
jpayne@69: * @param set the set
jpayne@69: * @return true if set is empty
jpayne@69: * @stable ICU 2.4
jpayne@69: */
jpayne@69: U_STABLE UBool U_EXPORT2
jpayne@69: uset_isEmpty(const USet* set);
jpayne@69:
jpayne@69: /**
jpayne@69: * Returns TRUE if the given USet contains the given character.
jpayne@69: * This function works faster with a frozen set.
jpayne@69: * @param set the set
jpayne@69: * @param c The codepoint to check for within the set
jpayne@69: * @return true if set contains c
jpayne@69: * @stable ICU 2.4
jpayne@69: */
jpayne@69: U_STABLE UBool U_EXPORT2
jpayne@69: uset_contains(const USet* set, UChar32 c);
jpayne@69:
jpayne@69: /**
jpayne@69: * Returns TRUE if the given USet contains all characters c
jpayne@69: * where start <= c && c <= end.
jpayne@69: * @param set the set
jpayne@69: * @param start the first character of the range to test, inclusive
jpayne@69: * @param end the last character of the range to test, inclusive
jpayne@69: * @return TRUE if set contains the range
jpayne@69: * @stable ICU 2.2
jpayne@69: */
jpayne@69: U_STABLE UBool U_EXPORT2
jpayne@69: uset_containsRange(const USet* set, UChar32 start, UChar32 end);
jpayne@69:
jpayne@69: /**
jpayne@69: * Returns TRUE if the given USet contains the given string.
jpayne@69: * @param set the set
jpayne@69: * @param str the string
jpayne@69: * @param strLen the length of the string or -1 if null terminated.
jpayne@69: * @return true if set contains str
jpayne@69: * @stable ICU 2.4
jpayne@69: */
jpayne@69: U_STABLE UBool U_EXPORT2
jpayne@69: uset_containsString(const USet* set, const UChar* str, int32_t strLen);
jpayne@69:
jpayne@69: /**
jpayne@69: * Returns the index of the given character within this set, where
jpayne@69: * the set is ordered by ascending code point. If the character
jpayne@69: * is not in this set, return -1. The inverse of this method is
jpayne@69: * charAt()
.
jpayne@69: * @param set the set
jpayne@69: * @param c the character to obtain the index for
jpayne@69: * @return an index from 0..size()-1, or -1
jpayne@69: * @stable ICU 3.2
jpayne@69: */
jpayne@69: U_STABLE int32_t U_EXPORT2
jpayne@69: uset_indexOf(const USet* set, UChar32 c);
jpayne@69:
jpayne@69: /**
jpayne@69: * Returns the character at the given index within this set, where
jpayne@69: * the set is ordered by ascending code point. If the index is
jpayne@69: * out of range, return (UChar32)-1. The inverse of this method is
jpayne@69: * indexOf()
.
jpayne@69: * @param set the set
jpayne@69: * @param charIndex an index from 0..size()-1 to obtain the char for
jpayne@69: * @return the character at the given index, or (UChar32)-1.
jpayne@69: * @stable ICU 3.2
jpayne@69: */
jpayne@69: U_STABLE UChar32 U_EXPORT2
jpayne@69: uset_charAt(const USet* set, int32_t charIndex);
jpayne@69:
jpayne@69: /**
jpayne@69: * Returns the number of characters and strings contained in the given
jpayne@69: * USet.
jpayne@69: * @param set the set
jpayne@69: * @return a non-negative integer counting the characters and strings
jpayne@69: * contained in set
jpayne@69: * @stable ICU 2.4
jpayne@69: */
jpayne@69: U_STABLE int32_t U_EXPORT2
jpayne@69: uset_size(const USet* set);
jpayne@69:
jpayne@69: /**
jpayne@69: * Returns the number of items in this set. An item is either a range
jpayne@69: * of characters or a single multicharacter string.
jpayne@69: * @param set the set
jpayne@69: * @return a non-negative integer counting the character ranges
jpayne@69: * and/or strings contained in set
jpayne@69: * @stable ICU 2.4
jpayne@69: */
jpayne@69: U_STABLE int32_t U_EXPORT2
jpayne@69: uset_getItemCount(const USet* set);
jpayne@69:
jpayne@69: /**
jpayne@69: * Returns an item of this set. An item is either a range of
jpayne@69: * characters or a single multicharacter string.
jpayne@69: * @param set the set
jpayne@69: * @param itemIndex a non-negative integer in the range 0..
jpayne@69: * uset_getItemCount(set)-1
jpayne@69: * @param start pointer to variable to receive first character
jpayne@69: * in range, inclusive
jpayne@69: * @param end pointer to variable to receive last character in range,
jpayne@69: * inclusive
jpayne@69: * @param str buffer to receive the string, may be NULL
jpayne@69: * @param strCapacity capacity of str, or 0 if str is NULL
jpayne@69: * @param ec error code
jpayne@69: * @return the length of the string (>= 2), or 0 if the item is a
jpayne@69: * range, in which case it is the range *start..*end, or -1 if
jpayne@69: * itemIndex is out of range
jpayne@69: * @stable ICU 2.4
jpayne@69: */
jpayne@69: U_STABLE int32_t U_EXPORT2
jpayne@69: uset_getItem(const USet* set, int32_t itemIndex,
jpayne@69: UChar32* start, UChar32* end,
jpayne@69: UChar* str, int32_t strCapacity,
jpayne@69: UErrorCode* ec);
jpayne@69:
jpayne@69: /**
jpayne@69: * Returns true if set1 contains all the characters and strings
jpayne@69: * of set2. It answers the question, 'Is set1 a superset of set2?'
jpayne@69: * @param set1 set to be checked for containment
jpayne@69: * @param set2 set to be checked for containment
jpayne@69: * @return true if the test condition is met
jpayne@69: * @stable ICU 3.2
jpayne@69: */
jpayne@69: U_STABLE UBool U_EXPORT2
jpayne@69: uset_containsAll(const USet* set1, const USet* set2);
jpayne@69:
jpayne@69: /**
jpayne@69: * Returns true if this set contains all the characters
jpayne@69: * of the given string. This is does not check containment of grapheme
jpayne@69: * clusters, like uset_containsString.
jpayne@69: * @param set set of characters to be checked for containment
jpayne@69: * @param str string containing codepoints to be checked for containment
jpayne@69: * @param strLen the length of the string or -1 if null terminated.
jpayne@69: * @return true if the test condition is met
jpayne@69: * @stable ICU 3.4
jpayne@69: */
jpayne@69: U_STABLE UBool U_EXPORT2
jpayne@69: uset_containsAllCodePoints(const USet* set, const UChar *str, int32_t strLen);
jpayne@69:
jpayne@69: /**
jpayne@69: * Returns true if set1 contains none of the characters and strings
jpayne@69: * of set2. It answers the question, 'Is set1 a disjoint set of set2?'
jpayne@69: * @param set1 set to be checked for containment
jpayne@69: * @param set2 set to be checked for containment
jpayne@69: * @return true if the test condition is met
jpayne@69: * @stable ICU 3.2
jpayne@69: */
jpayne@69: U_STABLE UBool U_EXPORT2
jpayne@69: uset_containsNone(const USet* set1, const USet* set2);
jpayne@69:
jpayne@69: /**
jpayne@69: * Returns true if set1 contains some of the characters and strings
jpayne@69: * of set2. It answers the question, 'Does set1 and set2 have an intersection?'
jpayne@69: * @param set1 set to be checked for containment
jpayne@69: * @param set2 set to be checked for containment
jpayne@69: * @return true if the test condition is met
jpayne@69: * @stable ICU 3.2
jpayne@69: */
jpayne@69: U_STABLE UBool U_EXPORT2
jpayne@69: uset_containsSome(const USet* set1, const USet* set2);
jpayne@69:
jpayne@69: /**
jpayne@69: * Returns the length of the initial substring of the input string which
jpayne@69: * consists only of characters and strings that are contained in this set
jpayne@69: * (USET_SPAN_CONTAINED, USET_SPAN_SIMPLE),
jpayne@69: * or only of characters and strings that are not contained
jpayne@69: * in this set (USET_SPAN_NOT_CONTAINED).
jpayne@69: * See USetSpanCondition for details.
jpayne@69: * Similar to the strspn() C library function.
jpayne@69: * Unpaired surrogates are treated according to contains() of their surrogate code points.
jpayne@69: * This function works faster with a frozen set and with a non-negative string length argument.
jpayne@69: * @param set the set
jpayne@69: * @param s start of the string
jpayne@69: * @param length of the string; can be -1 for NUL-terminated
jpayne@69: * @param spanCondition specifies the containment condition
jpayne@69: * @return the length of the initial substring according to the spanCondition;
jpayne@69: * 0 if the start of the string does not fit the spanCondition
jpayne@69: * @stable ICU 3.8
jpayne@69: * @see USetSpanCondition
jpayne@69: */
jpayne@69: U_STABLE int32_t U_EXPORT2
jpayne@69: uset_span(const USet *set, const UChar *s, int32_t length, USetSpanCondition spanCondition);
jpayne@69:
jpayne@69: /**
jpayne@69: * Returns the start of the trailing substring of the input string which
jpayne@69: * consists only of characters and strings that are contained in this set
jpayne@69: * (USET_SPAN_CONTAINED, USET_SPAN_SIMPLE),
jpayne@69: * or only of characters and strings that are not contained
jpayne@69: * in this set (USET_SPAN_NOT_CONTAINED).
jpayne@69: * See USetSpanCondition for details.
jpayne@69: * Unpaired surrogates are treated according to contains() of their surrogate code points.
jpayne@69: * This function works faster with a frozen set and with a non-negative string length argument.
jpayne@69: * @param set the set
jpayne@69: * @param s start of the string
jpayne@69: * @param length of the string; can be -1 for NUL-terminated
jpayne@69: * @param spanCondition specifies the containment condition
jpayne@69: * @return the start of the trailing substring according to the spanCondition;
jpayne@69: * the string length if the end of the string does not fit the spanCondition
jpayne@69: * @stable ICU 3.8
jpayne@69: * @see USetSpanCondition
jpayne@69: */
jpayne@69: U_STABLE int32_t U_EXPORT2
jpayne@69: uset_spanBack(const USet *set, const UChar *s, int32_t length, USetSpanCondition spanCondition);
jpayne@69:
jpayne@69: /**
jpayne@69: * Returns the length of the initial substring of the input string which
jpayne@69: * consists only of characters and strings that are contained in this set
jpayne@69: * (USET_SPAN_CONTAINED, USET_SPAN_SIMPLE),
jpayne@69: * or only of characters and strings that are not contained
jpayne@69: * in this set (USET_SPAN_NOT_CONTAINED).
jpayne@69: * See USetSpanCondition for details.
jpayne@69: * Similar to the strspn() C library function.
jpayne@69: * Malformed byte sequences are treated according to contains(0xfffd).
jpayne@69: * This function works faster with a frozen set and with a non-negative string length argument.
jpayne@69: * @param set the set
jpayne@69: * @param s start of the string (UTF-8)
jpayne@69: * @param length of the string; can be -1 for NUL-terminated
jpayne@69: * @param spanCondition specifies the containment condition
jpayne@69: * @return the length of the initial substring according to the spanCondition;
jpayne@69: * 0 if the start of the string does not fit the spanCondition
jpayne@69: * @stable ICU 3.8
jpayne@69: * @see USetSpanCondition
jpayne@69: */
jpayne@69: U_STABLE int32_t U_EXPORT2
jpayne@69: uset_spanUTF8(const USet *set, const char *s, int32_t length, USetSpanCondition spanCondition);
jpayne@69:
jpayne@69: /**
jpayne@69: * Returns the start of the trailing substring of the input string which
jpayne@69: * consists only of characters and strings that are contained in this set
jpayne@69: * (USET_SPAN_CONTAINED, USET_SPAN_SIMPLE),
jpayne@69: * or only of characters and strings that are not contained
jpayne@69: * in this set (USET_SPAN_NOT_CONTAINED).
jpayne@69: * See USetSpanCondition for details.
jpayne@69: * Malformed byte sequences are treated according to contains(0xfffd).
jpayne@69: * This function works faster with a frozen set and with a non-negative string length argument.
jpayne@69: * @param set the set
jpayne@69: * @param s start of the string (UTF-8)
jpayne@69: * @param length of the string; can be -1 for NUL-terminated
jpayne@69: * @param spanCondition specifies the containment condition
jpayne@69: * @return the start of the trailing substring according to the spanCondition;
jpayne@69: * the string length if the end of the string does not fit the spanCondition
jpayne@69: * @stable ICU 3.8
jpayne@69: * @see USetSpanCondition
jpayne@69: */
jpayne@69: U_STABLE int32_t U_EXPORT2
jpayne@69: uset_spanBackUTF8(const USet *set, const char *s, int32_t length, USetSpanCondition spanCondition);
jpayne@69:
jpayne@69: /**
jpayne@69: * Returns true if set1 contains all of the characters and strings
jpayne@69: * of set2, and vis versa. It answers the question, 'Is set1 equal to set2?'
jpayne@69: * @param set1 set to be checked for containment
jpayne@69: * @param set2 set to be checked for containment
jpayne@69: * @return true if the test condition is met
jpayne@69: * @stable ICU 3.2
jpayne@69: */
jpayne@69: U_STABLE UBool U_EXPORT2
jpayne@69: uset_equals(const USet* set1, const USet* set2);
jpayne@69:
jpayne@69: /*********************************************************************
jpayne@69: * Serialized set API
jpayne@69: *********************************************************************/
jpayne@69:
jpayne@69: /**
jpayne@69: * Serializes this set into an array of 16-bit integers. Serialization
jpayne@69: * (currently) only records the characters in the set; multicharacter
jpayne@69: * strings are ignored.
jpayne@69: *
jpayne@69: * The array
jpayne@69: * has following format (each line is one 16-bit integer):
jpayne@69: *
jpayne@69: * length = (n+2*m) | (m!=0?0x8000:0)
jpayne@69: * bmpLength = n; present if m!=0
jpayne@69: * bmp[0]
jpayne@69: * bmp[1]
jpayne@69: * ...
jpayne@69: * bmp[n-1]
jpayne@69: * supp-high[0]
jpayne@69: * supp-low[0]
jpayne@69: * supp-high[1]
jpayne@69: * supp-low[1]
jpayne@69: * ...
jpayne@69: * supp-high[m-1]
jpayne@69: * supp-low[m-1]
jpayne@69: *
jpayne@69: * The array starts with a header. After the header are n bmp
jpayne@69: * code points, then m supplementary code points. Either n or m
jpayne@69: * or both may be zero. n+2*m is always <= 0x7FFF.
jpayne@69: *
jpayne@69: * If there are no supplementary characters (if m==0) then the
jpayne@69: * header is one 16-bit integer, 'length', with value n.
jpayne@69: *
jpayne@69: * If there are supplementary characters (if m!=0) then the header
jpayne@69: * is two 16-bit integers. The first, 'length', has value
jpayne@69: * (n+2*m)|0x8000. The second, 'bmpLength', has value n.
jpayne@69: *
jpayne@69: * After the header the code points are stored in ascending order.
jpayne@69: * Supplementary code points are stored as most significant 16
jpayne@69: * bits followed by least significant 16 bits.
jpayne@69: *
jpayne@69: * @param set the set
jpayne@69: * @param dest pointer to buffer of destCapacity 16-bit integers.
jpayne@69: * May be NULL only if destCapacity is zero.
jpayne@69: * @param destCapacity size of dest, or zero. Must not be negative.
jpayne@69: * @param pErrorCode pointer to the error code. Will be set to
jpayne@69: * U_INDEX_OUTOFBOUNDS_ERROR if n+2*m > 0x7FFF. Will be set to
jpayne@69: * U_BUFFER_OVERFLOW_ERROR if n+2*m+(m!=0?2:1) > destCapacity.
jpayne@69: * @return the total length of the serialized format, including
jpayne@69: * the header, that is, n+2*m+(m!=0?2:1), or 0 on error other
jpayne@69: * than U_BUFFER_OVERFLOW_ERROR.
jpayne@69: * @stable ICU 2.4
jpayne@69: */
jpayne@69: U_STABLE int32_t U_EXPORT2
jpayne@69: uset_serialize(const USet* set, uint16_t* dest, int32_t destCapacity, UErrorCode* pErrorCode);
jpayne@69:
jpayne@69: /**
jpayne@69: * Given a serialized array, fill in the given serialized set object.
jpayne@69: * @param fillSet pointer to result
jpayne@69: * @param src pointer to start of array
jpayne@69: * @param srcLength length of array
jpayne@69: * @return true if the given array is valid, otherwise false
jpayne@69: * @stable ICU 2.4
jpayne@69: */
jpayne@69: U_STABLE UBool U_EXPORT2
jpayne@69: uset_getSerializedSet(USerializedSet* fillSet, const uint16_t* src, int32_t srcLength);
jpayne@69:
jpayne@69: /**
jpayne@69: * Set the USerializedSet to contain the given character (and nothing
jpayne@69: * else).
jpayne@69: * @param fillSet pointer to result
jpayne@69: * @param c The codepoint to set
jpayne@69: * @stable ICU 2.4
jpayne@69: */
jpayne@69: U_STABLE void U_EXPORT2
jpayne@69: uset_setSerializedToOne(USerializedSet* fillSet, UChar32 c);
jpayne@69:
jpayne@69: /**
jpayne@69: * Returns TRUE if the given USerializedSet contains the given
jpayne@69: * character.
jpayne@69: * @param set the serialized set
jpayne@69: * @param c The codepoint to check for within the set
jpayne@69: * @return true if set contains c
jpayne@69: * @stable ICU 2.4
jpayne@69: */
jpayne@69: U_STABLE UBool U_EXPORT2
jpayne@69: uset_serializedContains(const USerializedSet* set, UChar32 c);
jpayne@69:
jpayne@69: /**
jpayne@69: * Returns the number of disjoint ranges of characters contained in
jpayne@69: * the given serialized set. Ignores any strings contained in the
jpayne@69: * set.
jpayne@69: * @param set the serialized set
jpayne@69: * @return a non-negative integer counting the character ranges
jpayne@69: * contained in set
jpayne@69: * @stable ICU 2.4
jpayne@69: */
jpayne@69: U_STABLE int32_t U_EXPORT2
jpayne@69: uset_getSerializedRangeCount(const USerializedSet* set);
jpayne@69:
jpayne@69: /**
jpayne@69: * Returns a range of characters contained in the given serialized
jpayne@69: * set.
jpayne@69: * @param set the serialized set
jpayne@69: * @param rangeIndex a non-negative integer in the range 0..
jpayne@69: * uset_getSerializedRangeCount(set)-1
jpayne@69: * @param pStart pointer to variable to receive first character
jpayne@69: * in range, inclusive
jpayne@69: * @param pEnd pointer to variable to receive last character in range,
jpayne@69: * inclusive
jpayne@69: * @return true if rangeIndex is valid, otherwise false
jpayne@69: * @stable ICU 2.4
jpayne@69: */
jpayne@69: U_STABLE UBool U_EXPORT2
jpayne@69: uset_getSerializedRange(const USerializedSet* set, int32_t rangeIndex,
jpayne@69: UChar32* pStart, UChar32* pEnd);
jpayne@69:
jpayne@69: #endif