sl@0: /* sl@0: ******************************************************************************* sl@0: * sl@0: * Copyright (C) 2002-2005, International Business Machines sl@0: * Corporation and others. All Rights Reserved. sl@0: * sl@0: ******************************************************************************* sl@0: * file name: uset.h sl@0: * encoding: US-ASCII sl@0: * tab size: 8 (not used) sl@0: * indentation:4 sl@0: * sl@0: * created on: 2002mar07 sl@0: * created by: Markus W. Scherer sl@0: * sl@0: * C version of UnicodeSet. sl@0: */ sl@0: sl@0: sl@0: /** sl@0: * \file sl@0: * \brief C API: Unicode Set sl@0: * sl@0: *

This is a C wrapper around the C++ UnicodeSet class.

sl@0: */ sl@0: sl@0: #ifndef __USET_H__ sl@0: #define __USET_H__ sl@0: sl@0: #include "unicode/utypes.h" sl@0: #include "unicode/uchar.h" sl@0: sl@0: #ifndef UCNV_H sl@0: struct USet; sl@0: /** sl@0: * A UnicodeSet. Use the uset_* API to manipulate. Create with sl@0: * uset_open*, and destroy with uset_close. sl@0: * @stable ICU 2.4 sl@0: */ sl@0: typedef struct USet USet; sl@0: #endif sl@0: sl@0: /** sl@0: * Bitmask values to be passed to uset_openPatternOptions() or sl@0: * uset_applyPattern() taking an option parameter. sl@0: * @stable ICU 2.4 sl@0: */ sl@0: enum { sl@0: /** sl@0: * Ignore white space within patterns unless quoted or escaped. sl@0: * @stable ICU 2.4 sl@0: */ sl@0: USET_IGNORE_SPACE = 1, sl@0: sl@0: /** sl@0: * Enable case insensitive matching. E.g., "[ab]" with this flag sl@0: * will match 'a', 'A', 'b', and 'B'. "[^ab]" with this flag will sl@0: * match all except 'a', 'A', 'b', and 'B'. This performs a full sl@0: * closure over case mappings, e.g. U+017F for s. sl@0: * sl@0: * The resulting set is a superset of the input for the code points but sl@0: * not for the strings. sl@0: * It performs a case mapping closure of the code points and adds sl@0: * full case folding strings for the code points, and reduces strings of sl@0: * the original set to their full case folding equivalents. sl@0: * sl@0: * This is designed for case-insensitive matches, for example sl@0: * in regular expressions. The full code point case closure allows checking of sl@0: * an input character directly against the closure set. sl@0: * Strings are matched by comparing the case-folded form from the closure sl@0: * set with an incremental case folding of the string in question. sl@0: * sl@0: * The closure set will also contain single code points if the original sl@0: * set contained case-equivalent strings (like U+00DF for "ss" or "Ss" etc.). sl@0: * This is not necessary (that is, redundant) for the above matching method sl@0: * but results in the same closure sets regardless of whether the original sl@0: * set contained the code point or a string. sl@0: * sl@0: * @stable ICU 2.4 sl@0: */ sl@0: USET_CASE_INSENSITIVE = 2, sl@0: sl@0: /** sl@0: * Bitmask for UnicodeSet::closeOver() indicating letter case. sl@0: * This may be ORed together with other selectors. sl@0: * @internal sl@0: */ sl@0: USET_CASE = 2, sl@0: sl@0: /** sl@0: * Enable case insensitive matching. E.g., "[ab]" with this flag sl@0: * will match 'a', 'A', 'b', and 'B'. "[^ab]" with this flag will sl@0: * match all except 'a', 'A', 'b', and 'B'. This adds the lower-, sl@0: * title-, and uppercase mappings as well as the case folding sl@0: * of each existing element in the set. sl@0: * @draft ICU 3.2 sl@0: */ sl@0: USET_ADD_CASE_MAPPINGS = 4, sl@0: sl@0: /** sl@0: * Enough for any single-code point set sl@0: * @internal sl@0: */ sl@0: USET_SERIALIZED_STATIC_ARRAY_CAPACITY=8 sl@0: }; sl@0: sl@0: /** sl@0: * A serialized form of a Unicode set. Limited manipulations are sl@0: * possible directly on a serialized set. See below. sl@0: * @stable ICU 2.4 sl@0: */ sl@0: typedef struct USerializedSet { sl@0: /** sl@0: * The serialized Unicode Set. sl@0: * @stable ICU 2.4 sl@0: */ sl@0: const uint16_t *array; sl@0: /** sl@0: * The length of the array that contains BMP characters. sl@0: * @stable ICU 2.4 sl@0: */ sl@0: int32_t bmpLength; sl@0: /** sl@0: * The total length of the array. sl@0: * @stable ICU 2.4 sl@0: */ sl@0: int32_t length; sl@0: /** sl@0: * A small buffer for the array to reduce memory allocations. sl@0: * @stable ICU 2.4 sl@0: */ sl@0: uint16_t staticArray[USET_SERIALIZED_STATIC_ARRAY_CAPACITY]; sl@0: } USerializedSet; sl@0: sl@0: /********************************************************************* sl@0: * USet API sl@0: *********************************************************************/ sl@0: sl@0: /** sl@0: * Creates a USet object that contains the range of characters sl@0: * start..end, inclusive. sl@0: * @param start first character of the range, inclusive sl@0: * @param end last character of the range, inclusive sl@0: * @return a newly created USet. The caller must call uset_close() on sl@0: * it when done. sl@0: * @stable ICU 2.4 sl@0: */ sl@0: U_STABLE USet* U_EXPORT2 sl@0: uset_open(UChar32 start, UChar32 end); sl@0: sl@0: /** sl@0: * Creates a set from the given pattern. See the UnicodeSet class sl@0: * description for the syntax of the pattern language. sl@0: * @param pattern a string specifying what characters are in the set sl@0: * @param patternLength the length of the pattern, or -1 if null sl@0: * terminated sl@0: * @param ec the error code sl@0: * @stable ICU 2.4 sl@0: */ sl@0: U_STABLE USet* U_EXPORT2 sl@0: uset_openPattern(const UChar* pattern, int32_t patternLength, sl@0: UErrorCode* ec); sl@0: sl@0: /** sl@0: * Creates a set from the given pattern. See the UnicodeSet class sl@0: * description for the syntax of the pattern language. sl@0: * @param pattern a string specifying what characters are in the set sl@0: * @param patternLength the length of the pattern, or -1 if null sl@0: * terminated sl@0: * @param options bitmask for options to apply to the pattern. sl@0: * Valid options are USET_IGNORE_SPACE and USET_CASE_INSENSITIVE. sl@0: * @param ec the error code sl@0: * @stable ICU 2.4 sl@0: */ sl@0: U_STABLE USet* U_EXPORT2 sl@0: uset_openPatternOptions(const UChar* pattern, int32_t patternLength, sl@0: uint32_t options, sl@0: UErrorCode* ec); sl@0: sl@0: /** sl@0: * Disposes of the storage used by a USet object. This function should sl@0: * be called exactly once for objects returned by uset_open(). sl@0: * @param set the object to dispose of sl@0: * @stable ICU 2.4 sl@0: */ sl@0: U_STABLE void U_EXPORT2 sl@0: uset_close(USet* set); sl@0: sl@0: /** sl@0: * Causes the USet object to represent the range start - end. sl@0: * If start > end then this USet is set to an empty range. sl@0: * @param set the object to set to the given range sl@0: * @param start first character in the set, inclusive sl@0: * @param end last character in the set, inclusive sl@0: * @draft ICU 3.2 sl@0: */ sl@0: U_DRAFT void U_EXPORT2 sl@0: uset_set(USet* set, sl@0: UChar32 start, UChar32 end); sl@0: sl@0: /** sl@0: * Modifies the set to represent the set specified by the given sl@0: * pattern. See the UnicodeSet class description for the syntax of sl@0: * the pattern language. See also the User Guide chapter about UnicodeSet. sl@0: * Empties the set passed before applying the pattern. sl@0: * @param set The set to which the pattern is to be applied. sl@0: * @param pattern A pointer to UChar string specifying what characters are in the set. sl@0: * The character at pattern[0] must be a '['. sl@0: * @param patternLength The length of the UChar string. -1 if NUL terminated. sl@0: * @param options A bitmask for options to apply to the pattern. sl@0: * Valid options are USET_IGNORE_SPACE and USET_CASE_INSENSITIVE. sl@0: * @param status Returns an error if the pattern cannot be parsed. sl@0: * @return Upon successful parse, the value is either sl@0: * the index of the character after the closing ']' sl@0: * of the parsed pattern. sl@0: * If the status code indicates failure, then the return value sl@0: * is the index of the error in the source. sl@0: * sl@0: * @stable ICU 2.8 sl@0: */ sl@0: U_STABLE int32_t U_EXPORT2 sl@0: uset_applyPattern(USet *set, sl@0: const UChar *pattern, int32_t patternLength, sl@0: uint32_t options, sl@0: UErrorCode *status); sl@0: sl@0: /** sl@0: * Modifies the set to contain those code points which have the given value sl@0: * for the given binary or enumerated property, as returned by sl@0: * u_getIntPropertyValue. Prior contents of this set are lost. sl@0: * sl@0: * @param set the object to contain the code points defined by the property sl@0: * sl@0: * @param prop a property in the range UCHAR_BIN_START..UCHAR_BIN_LIMIT-1 sl@0: * or UCHAR_INT_START..UCHAR_INT_LIMIT-1 sl@0: * or UCHAR_MASK_START..UCHAR_MASK_LIMIT-1. sl@0: * sl@0: * @param value a value in the range u_getIntPropertyMinValue(prop).. sl@0: * u_getIntPropertyMaxValue(prop), with one exception. If prop is sl@0: * UCHAR_GENERAL_CATEGORY_MASK, then value should not be a UCharCategory, but sl@0: * rather a mask value produced by U_GET_GC_MASK(). This allows grouped sl@0: * categories such as [:L:] to be represented. sl@0: * sl@0: * @param ec error code input/output parameter sl@0: * sl@0: * @draft ICU 3.2 sl@0: */ sl@0: U_DRAFT void U_EXPORT2 sl@0: uset_applyIntPropertyValue(USet* set, sl@0: UProperty prop, int32_t value, UErrorCode* ec); sl@0: sl@0: /** sl@0: * Modifies the set to contain those code points which have the sl@0: * given value for the given property. Prior contents of this sl@0: * set are lost. sl@0: * sl@0: * @param set the object to contain the code points defined by the given sl@0: * property and value alias sl@0: * sl@0: * @param prop a string specifying a property alias, either short or long. sl@0: * The name is matched loosely. See PropertyAliases.txt for names and a sl@0: * description of loose matching. If the value string is empty, then this sl@0: * string is interpreted as either a General_Category value alias, a Script sl@0: * value alias, a binary property alias, or a special ID. Special IDs are sl@0: * matched loosely and correspond to the following sets: sl@0: * sl@0: * "ANY" = [\\u0000-\\U0010FFFF], sl@0: * "ASCII" = [\\u0000-\\u007F], sl@0: * "Assigned" = [:^Cn:]. sl@0: * sl@0: * @param propLength the length of the prop, or -1 if NULL sl@0: * sl@0: * @param value a string specifying a value alias, either short or long. sl@0: * The name is matched loosely. See PropertyValueAliases.txt for names sl@0: * and a description of loose matching. In addition to aliases listed, sl@0: * numeric values and canonical combining classes may be expressed sl@0: * numerically, e.g., ("nv", "0.5") or ("ccc", "220"). The value string sl@0: * may also be empty. sl@0: * sl@0: * @param valueLength the length of the value, or -1 if NULL sl@0: * sl@0: * @param ec error code input/output parameter sl@0: * sl@0: * @draft ICU 3.2 sl@0: */ sl@0: U_DRAFT void U_EXPORT2 sl@0: uset_applyPropertyAlias(USet* set, sl@0: const UChar *prop, int32_t propLength, sl@0: const UChar *value, int32_t valueLength, sl@0: UErrorCode* ec); sl@0: sl@0: /** sl@0: * Return true if the given position, in the given pattern, appears sl@0: * to be the start of a UnicodeSet pattern. sl@0: * sl@0: * @param pattern a string specifying the pattern sl@0: * @param patternLength the length of the pattern, or -1 if NULL sl@0: * @param pos the given position sl@0: * @draft ICU 3.2 sl@0: */ sl@0: U_DRAFT UBool U_EXPORT2 sl@0: uset_resemblesPattern(const UChar *pattern, int32_t patternLength, sl@0: int32_t pos); sl@0: sl@0: /** sl@0: * Returns a string representation of this set. If the result of sl@0: * calling this function is passed to a uset_openPattern(), it sl@0: * will produce another set that is equal to this one. sl@0: * @param set the set sl@0: * @param result the string to receive the rules, may be NULL sl@0: * @param resultCapacity the capacity of result, may be 0 if result is NULL sl@0: * @param escapeUnprintable if TRUE then convert unprintable sl@0: * character to their hex escape representations, \\uxxxx or sl@0: * \\Uxxxxxxxx. Unprintable characters are those other than sl@0: * U+000A, U+0020..U+007E. sl@0: * @param ec error code. sl@0: * @return length of string, possibly larger than resultCapacity sl@0: * @stable ICU 2.4 sl@0: */ sl@0: U_STABLE int32_t U_EXPORT2 sl@0: uset_toPattern(const USet* set, sl@0: UChar* result, int32_t resultCapacity, sl@0: UBool escapeUnprintable, sl@0: UErrorCode* ec); sl@0: sl@0: /** sl@0: * Adds the given character to the given USet. After this call, sl@0: * uset_contains(set, c) will return TRUE. sl@0: * @param set the object to which to add the character sl@0: * @param c the character to add sl@0: * @stable ICU 2.4 sl@0: */ sl@0: U_STABLE void U_EXPORT2 sl@0: uset_add(USet* set, UChar32 c); sl@0: sl@0: /** sl@0: * Adds all of the elements in the specified set to this set if sl@0: * they're not already present. This operation effectively sl@0: * modifies this set so that its value is the union of the two sl@0: * sets. The behavior of this operation is unspecified if the specified sl@0: * collection is modified while the operation is in progress. sl@0: * sl@0: * @param set the object to which to add the set sl@0: * @param additionalSet the source set whose elements are to be added to this set. sl@0: * @stable ICU 2.6 sl@0: */ sl@0: U_STABLE void U_EXPORT2 sl@0: uset_addAll(USet* set, const USet *additionalSet); sl@0: sl@0: /** sl@0: * Adds the given range of characters to the given USet. After this call, sl@0: * uset_contains(set, start, end) will return TRUE. sl@0: * @param set the object to which to add the character sl@0: * @param start the first character of the range to add, inclusive sl@0: * @param end the last character of the range to add, inclusive sl@0: * @stable ICU 2.2 sl@0: */ sl@0: U_STABLE void U_EXPORT2 sl@0: uset_addRange(USet* set, UChar32 start, UChar32 end); sl@0: sl@0: /** sl@0: * Adds the given string to the given USet. After this call, sl@0: * uset_containsString(set, str, strLen) will return TRUE. sl@0: * @param set the object to which to add the character sl@0: * @param str the string to add sl@0: * @param strLen the length of the string or -1 if null terminated. sl@0: * @stable ICU 2.4 sl@0: */ sl@0: U_STABLE void U_EXPORT2 sl@0: uset_addString(USet* set, const UChar* str, int32_t strLen); sl@0: sl@0: /** sl@0: * Adds each of the characters in this string to the set. Thus "ch" => {"c", "h"} sl@0: * If this set already any particular character, it has no effect on that character. sl@0: * @param set the object to which to add the character sl@0: * @param str the source string sl@0: * @param strLen the length of the string or -1 if null terminated. sl@0: * @draft ICU 3.4 sl@0: */ sl@0: U_DRAFT void U_EXPORT2 sl@0: uset_addAllCodePoints(USet* set, const UChar *str, int32_t strLen); sl@0: sl@0: /** sl@0: * Removes the given character from the given USet. After this call, sl@0: * uset_contains(set, c) will return FALSE. sl@0: * @param set the object from which to remove the character sl@0: * @param c the character to remove sl@0: * @stable ICU 2.4 sl@0: */ sl@0: U_STABLE void U_EXPORT2 sl@0: uset_remove(USet* set, UChar32 c); sl@0: sl@0: /** sl@0: * Removes the given range of characters from the given USet. After this call, sl@0: * uset_contains(set, start, end) will return FALSE. sl@0: * @param set the object to which to add the character sl@0: * @param start the first character of the range to remove, inclusive sl@0: * @param end the last character of the range to remove, inclusive sl@0: * @stable ICU 2.2 sl@0: */ sl@0: U_STABLE void U_EXPORT2 sl@0: uset_removeRange(USet* set, UChar32 start, UChar32 end); sl@0: sl@0: /** sl@0: * Removes the given string to the given USet. After this call, sl@0: * uset_containsString(set, str, strLen) will return FALSE. sl@0: * @param set the object to which to add the character sl@0: * @param str the string to remove sl@0: * @param strLen the length of the string or -1 if null terminated. sl@0: * @stable ICU 2.4 sl@0: */ sl@0: U_STABLE void U_EXPORT2 sl@0: uset_removeString(USet* set, const UChar* str, int32_t strLen); sl@0: sl@0: /** sl@0: * Removes from this set all of its elements that are contained in the sl@0: * specified set. This operation effectively modifies this sl@0: * set so that its value is the asymmetric set difference of sl@0: * the two sets. sl@0: * @param set the object from which the elements are to be removed sl@0: * @param removeSet the object that defines which elements will be sl@0: * removed from this set sl@0: * @draft ICU 3.2 sl@0: */ sl@0: U_DRAFT void U_EXPORT2 sl@0: uset_removeAll(USet* set, const USet* removeSet); sl@0: sl@0: /** sl@0: * Retain only the elements in this set that are contained in the sl@0: * specified range. If start > end then an empty range is sl@0: * retained, leaving the set empty. This is equivalent to sl@0: * a boolean logic AND, or a set INTERSECTION. sl@0: * sl@0: * @param set the object for which to retain only the specified range sl@0: * @param start first character, inclusive, of range to be retained sl@0: * to this set. sl@0: * @param end last character, inclusive, of range to be retained sl@0: * to this set. sl@0: * @draft ICU 3.2 sl@0: */ sl@0: U_DRAFT void U_EXPORT2 sl@0: uset_retain(USet* set, UChar32 start, UChar32 end); sl@0: sl@0: /** sl@0: * Retains only the elements in this set that are contained in the sl@0: * specified set. In other words, removes from this set all of sl@0: * its elements that are not contained in the specified set. This sl@0: * operation effectively modifies this set so that its value is sl@0: * the intersection of the two sets. sl@0: * sl@0: * @param set the object on which to perform the retain sl@0: * @param retain set that defines which elements this set will retain sl@0: * @draft ICU 3.2 sl@0: */ sl@0: U_DRAFT void U_EXPORT2 sl@0: uset_retainAll(USet* set, const USet* retain); sl@0: sl@0: /** sl@0: * Reallocate this objects internal structures to take up the least sl@0: * possible space, without changing this object's value. sl@0: * sl@0: * @param set the object on which to perfrom the compact sl@0: * @draft ICU 3.2 sl@0: */ sl@0: U_DRAFT void U_EXPORT2 sl@0: uset_compact(USet* set); sl@0: sl@0: /** sl@0: * Inverts this set. This operation modifies this set so that sl@0: * its value is its complement. This operation does not affect sl@0: * the multicharacter strings, if any. sl@0: * @param set the set sl@0: * @stable ICU 2.4 sl@0: */ sl@0: U_STABLE void U_EXPORT2 sl@0: uset_complement(USet* set); sl@0: sl@0: /** sl@0: * Complements in this set all elements contained in the specified sl@0: * set. Any character in the other set will be removed if it is sl@0: * in this set, or will be added if it is not in this set. sl@0: * sl@0: * @param set the set with which to complement sl@0: * @param complement set that defines which elements will be xor'ed sl@0: * from this set. sl@0: * @draft ICU 3.2 sl@0: */ sl@0: U_DRAFT void U_EXPORT2 sl@0: uset_complementAll(USet* set, const USet* complement); sl@0: sl@0: /** sl@0: * Removes all of the elements from this set. This set will be sl@0: * empty after this call returns. sl@0: * @param set the set sl@0: * @stable ICU 2.4 sl@0: */ sl@0: U_STABLE void U_EXPORT2 sl@0: uset_clear(USet* set); sl@0: sl@0: /** sl@0: * Returns TRUE if the given USet contains no characters and no sl@0: * strings. sl@0: * @param set the set sl@0: * @return true if set is empty sl@0: * @stable ICU 2.4 sl@0: */ sl@0: U_STABLE UBool U_EXPORT2 sl@0: uset_isEmpty(const USet* set); sl@0: sl@0: /** sl@0: * Returns TRUE if the given USet contains the given character. sl@0: * @param set the set sl@0: * @param c The codepoint to check for within the set sl@0: * @return true if set contains c sl@0: * @stable ICU 2.4 sl@0: */ sl@0: U_STABLE UBool U_EXPORT2 sl@0: uset_contains(const USet* set, UChar32 c); sl@0: sl@0: /** sl@0: * Returns TRUE if the given USet contains all characters c sl@0: * where start <= c && c <= end. sl@0: * @param set the set sl@0: * @param start the first character of the range to test, inclusive sl@0: * @param end the last character of the range to test, inclusive sl@0: * @return TRUE if set contains the range sl@0: * @stable ICU 2.2 sl@0: */ sl@0: U_STABLE UBool U_EXPORT2 sl@0: uset_containsRange(const USet* set, UChar32 start, UChar32 end); sl@0: sl@0: /** sl@0: * Returns TRUE if the given USet contains the given string. sl@0: * @param set the set sl@0: * @param str the string sl@0: * @param strLen the length of the string or -1 if null terminated. sl@0: * @return true if set contains str sl@0: * @stable ICU 2.4 sl@0: */ sl@0: U_STABLE UBool U_EXPORT2 sl@0: uset_containsString(const USet* set, const UChar* str, int32_t strLen); sl@0: sl@0: /** sl@0: * Returns the index of the given character within this set, where sl@0: * the set is ordered by ascending code point. If the character sl@0: * is not in this set, return -1. The inverse of this method is sl@0: * charAt(). sl@0: * @param set the set sl@0: * @param c the character to obtain the index for sl@0: * @return an index from 0..size()-1, or -1 sl@0: * @draft ICU 3.2 sl@0: */ sl@0: U_DRAFT int32_t U_EXPORT2 sl@0: uset_indexOf(const USet* set, UChar32 c); sl@0: sl@0: /** sl@0: * Returns the character at the given index within this set, where sl@0: * the set is ordered by ascending code point. If the index is sl@0: * out of range, return (UChar32)-1. The inverse of this method is sl@0: * indexOf(). sl@0: * @param set the set sl@0: * @param index an index from 0..size()-1 to obtain the char for sl@0: * @return the character at the given index, or (UChar32)-1. sl@0: * @draft ICU 3.2 sl@0: */ sl@0: U_DRAFT UChar32 U_EXPORT2 sl@0: uset_charAt(const USet* set, int32_t index); sl@0: sl@0: /** sl@0: * Returns the number of characters and strings contained in the given sl@0: * USet. sl@0: * @param set the set sl@0: * @return a non-negative integer counting the characters and strings sl@0: * contained in set sl@0: * @stable ICU 2.4 sl@0: */ sl@0: U_STABLE int32_t U_EXPORT2 sl@0: uset_size(const USet* set); sl@0: sl@0: /** sl@0: * Returns the number of items in this set. An item is either a range sl@0: * of characters or a single multicharacter string. sl@0: * @param set the set sl@0: * @return a non-negative integer counting the character ranges sl@0: * and/or strings contained in set sl@0: * @stable ICU 2.4 sl@0: */ sl@0: U_STABLE int32_t U_EXPORT2 sl@0: uset_getItemCount(const USet* set); sl@0: sl@0: /** sl@0: * Returns an item of this set. An item is either a range of sl@0: * characters or a single multicharacter string. sl@0: * @param set the set sl@0: * @param itemIndex a non-negative integer in the range 0.. sl@0: * uset_getItemCount(set)-1 sl@0: * @param start pointer to variable to receive first character sl@0: * in range, inclusive sl@0: * @param end pointer to variable to receive last character in range, sl@0: * inclusive sl@0: * @param str buffer to receive the string, may be NULL sl@0: * @param strCapacity capacity of str, or 0 if str is NULL sl@0: * @param ec error code sl@0: * @return the length of the string (>= 2), or 0 if the item is a sl@0: * range, in which case it is the range *start..*end, or -1 if sl@0: * itemIndex is out of range sl@0: * @stable ICU 2.4 sl@0: */ sl@0: U_STABLE int32_t U_EXPORT2 sl@0: uset_getItem(const USet* set, int32_t itemIndex, sl@0: UChar32* start, UChar32* end, sl@0: UChar* str, int32_t strCapacity, sl@0: UErrorCode* ec); sl@0: sl@0: /** sl@0: * Returns true if set1 contains all the characters and strings sl@0: * of set2. It answers the question, 'Is set1 a subset of set2?' sl@0: * @param set1 set to be checked for containment sl@0: * @param set2 set to be checked for containment sl@0: * @return true if the test condition is met sl@0: * @draft ICU 3.2 sl@0: */ sl@0: U_DRAFT UBool U_EXPORT2 sl@0: uset_containsAll(const USet* set1, const USet* set2); sl@0: sl@0: /** sl@0: * Returns true if this set contains all the characters sl@0: * of the given string. This is does not check containment of grapheme sl@0: * clusters, like uset_containsString. sl@0: * @param set set of characters to be checked for containment sl@0: * @param str string containing codepoints to be checked for containment sl@0: * @param strLen the length of the string or -1 if null terminated. sl@0: * @return true if the test condition is met sl@0: * @draft ICU 3.4 sl@0: */ sl@0: U_DRAFT UBool U_EXPORT2 sl@0: uset_containsAllCodePoints(const USet* set, const UChar *str, int32_t strLen); sl@0: sl@0: /** sl@0: * Returns true if set1 contains none of the characters and strings sl@0: * of set2. It answers the question, 'Is set1 a disjoint set of set2?' sl@0: * @param set1 set to be checked for containment sl@0: * @param set2 set to be checked for containment sl@0: * @return true if the test condition is met sl@0: * @draft ICU 3.2 sl@0: */ sl@0: U_DRAFT UBool U_EXPORT2 sl@0: uset_containsNone(const USet* set1, const USet* set2); sl@0: sl@0: /** sl@0: * Returns true if set1 contains some of the characters and strings sl@0: * of set2. It answers the question, 'Does set1 and set2 have an intersection?' sl@0: * @param set1 set to be checked for containment sl@0: * @param set2 set to be checked for containment sl@0: * @return true if the test condition is met sl@0: * @draft ICU 3.2 sl@0: */ sl@0: U_DRAFT UBool U_EXPORT2 sl@0: uset_containsSome(const USet* set1, const USet* set2); sl@0: sl@0: /** sl@0: * Returns true if set1 contains all of the characters and strings sl@0: * of set2, and vis versa. It answers the question, 'Is set1 equal to set2?' sl@0: * @param set1 set to be checked for containment sl@0: * @param set2 set to be checked for containment sl@0: * @return true if the test condition is met sl@0: * @draft ICU 3.2 sl@0: */ sl@0: U_DRAFT UBool U_EXPORT2 sl@0: uset_equals(const USet* set1, const USet* set2); sl@0: sl@0: /********************************************************************* sl@0: * Serialized set API sl@0: *********************************************************************/ sl@0: sl@0: /** sl@0: * Serializes this set into an array of 16-bit integers. Serialization sl@0: * (currently) only records the characters in the set; multicharacter sl@0: * strings are ignored. sl@0: * sl@0: * The array sl@0: * has following format (each line is one 16-bit integer): sl@0: * sl@0: * length = (n+2*m) | (m!=0?0x8000:0) sl@0: * bmpLength = n; present if m!=0 sl@0: * bmp[0] sl@0: * bmp[1] sl@0: * ... sl@0: * bmp[n-1] sl@0: * supp-high[0] sl@0: * supp-low[0] sl@0: * supp-high[1] sl@0: * supp-low[1] sl@0: * ... sl@0: * supp-high[m-1] sl@0: * supp-low[m-1] sl@0: * sl@0: * The array starts with a header. After the header are n bmp sl@0: * code points, then m supplementary code points. Either n or m sl@0: * or both may be zero. n+2*m is always <= 0x7FFF. sl@0: * sl@0: * If there are no supplementary characters (if m==0) then the sl@0: * header is one 16-bit integer, 'length', with value n. sl@0: * sl@0: * If there are supplementary characters (if m!=0) then the header sl@0: * is two 16-bit integers. The first, 'length', has value sl@0: * (n+2*m)|0x8000. The second, 'bmpLength', has value n. sl@0: * sl@0: * After the header the code points are stored in ascending order. sl@0: * Supplementary code points are stored as most significant 16 sl@0: * bits followed by least significant 16 bits. sl@0: * sl@0: * @param set the set sl@0: * @param dest pointer to buffer of destCapacity 16-bit integers. sl@0: * May be NULL only if destCapacity is zero. sl@0: * @param destCapacity size of dest, or zero. Must not be negative. sl@0: * @param pErrorCode pointer to the error code. Will be set to sl@0: * U_INDEX_OUTOFBOUNDS_ERROR if n+2*m > 0x7FFF. Will be set to sl@0: * U_BUFFER_OVERFLOW_ERROR if n+2*m+(m!=0?2:1) > destCapacity. sl@0: * @return the total length of the serialized format, including sl@0: * the header, that is, n+2*m+(m!=0?2:1), or 0 on error other sl@0: * than U_BUFFER_OVERFLOW_ERROR. sl@0: * @stable ICU 2.4 sl@0: */ sl@0: U_STABLE int32_t U_EXPORT2 sl@0: uset_serialize(const USet* set, uint16_t* dest, int32_t destCapacity, UErrorCode* pErrorCode); sl@0: sl@0: /** sl@0: * Given a serialized array, fill in the given serialized set object. sl@0: * @param fillSet pointer to result sl@0: * @param src pointer to start of array sl@0: * @param srcLength length of array sl@0: * @return true if the given array is valid, otherwise false sl@0: * @stable ICU 2.4 sl@0: */ sl@0: U_STABLE UBool U_EXPORT2 sl@0: uset_getSerializedSet(USerializedSet* fillSet, const uint16_t* src, int32_t srcLength); sl@0: sl@0: /** sl@0: * Set the USerializedSet to contain the given character (and nothing sl@0: * else). sl@0: * @param fillSet pointer to result sl@0: * @param c The codepoint to set sl@0: * @stable ICU 2.4 sl@0: */ sl@0: U_STABLE void U_EXPORT2 sl@0: uset_setSerializedToOne(USerializedSet* fillSet, UChar32 c); sl@0: sl@0: /** sl@0: * Returns TRUE if the given USerializedSet contains the given sl@0: * character. sl@0: * @param set the serialized set sl@0: * @param c The codepoint to check for within the set sl@0: * @return true if set contains c sl@0: * @stable ICU 2.4 sl@0: */ sl@0: U_STABLE UBool U_EXPORT2 sl@0: uset_serializedContains(const USerializedSet* set, UChar32 c); sl@0: sl@0: /** sl@0: * Returns the number of disjoint ranges of characters contained in sl@0: * the given serialized set. Ignores any strings contained in the sl@0: * set. sl@0: * @param set the serialized set sl@0: * @return a non-negative integer counting the character ranges sl@0: * contained in set sl@0: * @stable ICU 2.4 sl@0: */ sl@0: U_STABLE int32_t U_EXPORT2 sl@0: uset_getSerializedRangeCount(const USerializedSet* set); sl@0: sl@0: /** sl@0: * Returns a range of characters contained in the given serialized sl@0: * set. sl@0: * @param set the serialized set sl@0: * @param rangeIndex a non-negative integer in the range 0.. sl@0: * uset_getSerializedRangeCount(set)-1 sl@0: * @param pStart pointer to variable to receive first character sl@0: * in range, inclusive sl@0: * @param pEnd pointer to variable to receive last character in range, sl@0: * inclusive sl@0: * @return true if rangeIndex is valid, otherwise false sl@0: * @stable ICU 2.4 sl@0: */ sl@0: U_STABLE UBool U_EXPORT2 sl@0: uset_getSerializedRange(const USerializedSet* set, int32_t rangeIndex, sl@0: UChar32* pStart, UChar32* pEnd); sl@0: sl@0: #endif