xref: /aosp_15_r20/external/icu/libandroidicu/include/unicode/uset.h (revision 0e209d3975ff4a8c132096b14b0e9364a753506e)
1*0e209d39SAndroid Build Coastguard Worker // © 2016 and later: Unicode, Inc. and others.
2*0e209d39SAndroid Build Coastguard Worker // License & terms of use: http://www.unicode.org/copyright.html
3*0e209d39SAndroid Build Coastguard Worker /*
4*0e209d39SAndroid Build Coastguard Worker *******************************************************************************
5*0e209d39SAndroid Build Coastguard Worker *
6*0e209d39SAndroid Build Coastguard Worker *   Copyright (C) 2002-2014, International Business Machines
7*0e209d39SAndroid Build Coastguard Worker *   Corporation and others.  All Rights Reserved.
8*0e209d39SAndroid Build Coastguard Worker *
9*0e209d39SAndroid Build Coastguard Worker *******************************************************************************
10*0e209d39SAndroid Build Coastguard Worker *   file name:  uset.h
11*0e209d39SAndroid Build Coastguard Worker *   encoding:   UTF-8
12*0e209d39SAndroid Build Coastguard Worker *   tab size:   8 (not used)
13*0e209d39SAndroid Build Coastguard Worker *   indentation:4
14*0e209d39SAndroid Build Coastguard Worker *
15*0e209d39SAndroid Build Coastguard Worker *   created on: 2002mar07
16*0e209d39SAndroid Build Coastguard Worker *   created by: Markus W. Scherer
17*0e209d39SAndroid Build Coastguard Worker *
18*0e209d39SAndroid Build Coastguard Worker *   C version of UnicodeSet.
19*0e209d39SAndroid Build Coastguard Worker */
20*0e209d39SAndroid Build Coastguard Worker 
21*0e209d39SAndroid Build Coastguard Worker 
22*0e209d39SAndroid Build Coastguard Worker /**
23*0e209d39SAndroid Build Coastguard Worker  * \file
24*0e209d39SAndroid Build Coastguard Worker  * \brief C API: Unicode Set
25*0e209d39SAndroid Build Coastguard Worker  *
26*0e209d39SAndroid Build Coastguard Worker  * <p>This is a C wrapper around the C++ UnicodeSet class.</p>
27*0e209d39SAndroid Build Coastguard Worker  */
28*0e209d39SAndroid Build Coastguard Worker 
29*0e209d39SAndroid Build Coastguard Worker #ifndef __USET_H__
30*0e209d39SAndroid Build Coastguard Worker #define __USET_H__
31*0e209d39SAndroid Build Coastguard Worker 
32*0e209d39SAndroid Build Coastguard Worker #include "unicode/utypes.h"
33*0e209d39SAndroid Build Coastguard Worker #include "unicode/uchar.h"
34*0e209d39SAndroid Build Coastguard Worker 
35*0e209d39SAndroid Build Coastguard Worker #if U_SHOW_CPLUSPLUS_API
36*0e209d39SAndroid Build Coastguard Worker #include "unicode/localpointer.h"
37*0e209d39SAndroid Build Coastguard Worker #endif   // U_SHOW_CPLUSPLUS_API
38*0e209d39SAndroid Build Coastguard Worker 
39*0e209d39SAndroid Build Coastguard Worker #ifndef USET_DEFINED
40*0e209d39SAndroid Build Coastguard Worker 
41*0e209d39SAndroid Build Coastguard Worker #ifndef U_IN_DOXYGEN
42*0e209d39SAndroid Build Coastguard Worker #define USET_DEFINED
43*0e209d39SAndroid Build Coastguard Worker #endif
44*0e209d39SAndroid Build Coastguard Worker /**
45*0e209d39SAndroid Build Coastguard Worker  * USet is the C API type corresponding to C++ class UnicodeSet.
46*0e209d39SAndroid Build Coastguard Worker  * Use the uset_* API to manipulate.  Create with
47*0e209d39SAndroid Build Coastguard Worker  * uset_open*, and destroy with uset_close.
48*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 2.4
49*0e209d39SAndroid Build Coastguard Worker  */
50*0e209d39SAndroid Build Coastguard Worker typedef struct USet USet;
51*0e209d39SAndroid Build Coastguard Worker #endif
52*0e209d39SAndroid Build Coastguard Worker 
53*0e209d39SAndroid Build Coastguard Worker /**
54*0e209d39SAndroid Build Coastguard Worker  * Bitmask values to be passed to uset_openPatternOptions() or
55*0e209d39SAndroid Build Coastguard Worker  * uset_applyPattern() taking an option parameter.
56*0e209d39SAndroid Build Coastguard Worker  *
57*0e209d39SAndroid Build Coastguard Worker  * Use at most one of USET_CASE_INSENSITIVE, USET_ADD_CASE_MAPPINGS, USET_SIMPLE_CASE_INSENSITIVE.
58*0e209d39SAndroid Build Coastguard Worker  * These case options are mutually exclusive.
59*0e209d39SAndroid Build Coastguard Worker  *
60*0e209d39SAndroid Build Coastguard Worker  * Undefined options bits are ignored, and reserved for future use.
61*0e209d39SAndroid Build Coastguard Worker  *
62*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 2.4
63*0e209d39SAndroid Build Coastguard Worker  */
64*0e209d39SAndroid Build Coastguard Worker enum {
65*0e209d39SAndroid Build Coastguard Worker     /**
66*0e209d39SAndroid Build Coastguard Worker      * Ignore white space within patterns unless quoted or escaped.
67*0e209d39SAndroid Build Coastguard Worker      * @stable ICU 2.4
68*0e209d39SAndroid Build Coastguard Worker      */
69*0e209d39SAndroid Build Coastguard Worker     USET_IGNORE_SPACE = 1,
70*0e209d39SAndroid Build Coastguard Worker 
71*0e209d39SAndroid Build Coastguard Worker     /**
72*0e209d39SAndroid Build Coastguard Worker      * Enable case insensitive matching.  E.g., "[ab]" with this flag
73*0e209d39SAndroid Build Coastguard Worker      * will match 'a', 'A', 'b', and 'B'.  "[^ab]" with this flag will
74*0e209d39SAndroid Build Coastguard Worker      * match all except 'a', 'A', 'b', and 'B'. This performs a full
75*0e209d39SAndroid Build Coastguard Worker      * closure over case mappings, e.g. 'ſ' (U+017F long s) for 's'.
76*0e209d39SAndroid Build Coastguard Worker      *
77*0e209d39SAndroid Build Coastguard Worker      * The resulting set is a superset of the input for the code points but
78*0e209d39SAndroid Build Coastguard Worker      * not for the strings.
79*0e209d39SAndroid Build Coastguard Worker      * It performs a case mapping closure of the code points and adds
80*0e209d39SAndroid Build Coastguard Worker      * full case folding strings for the code points, and reduces strings of
81*0e209d39SAndroid Build Coastguard Worker      * the original set to their full case folding equivalents.
82*0e209d39SAndroid Build Coastguard Worker      *
83*0e209d39SAndroid Build Coastguard Worker      * This is designed for case-insensitive matches, for example
84*0e209d39SAndroid Build Coastguard Worker      * in regular expressions. The full code point case closure allows checking of
85*0e209d39SAndroid Build Coastguard Worker      * an input character directly against the closure set.
86*0e209d39SAndroid Build Coastguard Worker      * Strings are matched by comparing the case-folded form from the closure
87*0e209d39SAndroid Build Coastguard Worker      * set with an incremental case folding of the string in question.
88*0e209d39SAndroid Build Coastguard Worker      *
89*0e209d39SAndroid Build Coastguard Worker      * The closure set will also contain single code points if the original
90*0e209d39SAndroid Build Coastguard Worker      * set contained case-equivalent strings (like U+00DF for "ss" or "Ss" etc.).
91*0e209d39SAndroid Build Coastguard Worker      * This is not necessary (that is, redundant) for the above matching method
92*0e209d39SAndroid Build Coastguard Worker      * but results in the same closure sets regardless of whether the original
93*0e209d39SAndroid Build Coastguard Worker      * set contained the code point or a string.
94*0e209d39SAndroid Build Coastguard Worker      *
95*0e209d39SAndroid Build Coastguard Worker      * @stable ICU 2.4
96*0e209d39SAndroid Build Coastguard Worker      */
97*0e209d39SAndroid Build Coastguard Worker     USET_CASE_INSENSITIVE = 2,
98*0e209d39SAndroid Build Coastguard Worker 
99*0e209d39SAndroid Build Coastguard Worker     /**
100*0e209d39SAndroid Build Coastguard Worker      * Adds all case mappings for each element in the set.
101*0e209d39SAndroid Build Coastguard Worker      * This adds the full lower-, title-, and uppercase mappings as well as the full case folding
102*0e209d39SAndroid Build Coastguard Worker      * of each existing element in the set.
103*0e209d39SAndroid Build Coastguard Worker      *
104*0e209d39SAndroid Build Coastguard Worker      * Unlike the “case insensitive” options, this does not perform a closure.
105*0e209d39SAndroid Build Coastguard Worker      * For example, it does not add 'ſ' (U+017F long s) for 's',
106*0e209d39SAndroid Build Coastguard Worker      * 'K' (U+212A Kelvin sign) for 'k', or replace set strings by their case-folded versions.
107*0e209d39SAndroid Build Coastguard Worker      *
108*0e209d39SAndroid Build Coastguard Worker      * @stable ICU 3.2
109*0e209d39SAndroid Build Coastguard Worker      */
110*0e209d39SAndroid Build Coastguard Worker     USET_ADD_CASE_MAPPINGS = 4,
111*0e209d39SAndroid Build Coastguard Worker 
112*0e209d39SAndroid Build Coastguard Worker     /**
113*0e209d39SAndroid Build Coastguard Worker      * Enable case insensitive matching.
114*0e209d39SAndroid Build Coastguard Worker      * Same as USET_CASE_INSENSITIVE but using only Simple_Case_Folding (scf) mappings,
115*0e209d39SAndroid Build Coastguard Worker      * which map each code point to one code point,
116*0e209d39SAndroid Build Coastguard Worker      * not full Case_Folding (cf) mappings, which map some code points to multiple code points.
117*0e209d39SAndroid Build Coastguard Worker      *
118*0e209d39SAndroid Build Coastguard Worker      * This is designed for case-insensitive matches, for example in certain
119*0e209d39SAndroid Build Coastguard Worker      * regular expression implementations where only Simple_Case_Folding mappings are used,
120*0e209d39SAndroid Build Coastguard Worker      * such as in ECMAScript (JavaScript) regular expressions.
121*0e209d39SAndroid Build Coastguard Worker      *
122*0e209d39SAndroid Build Coastguard Worker      * @stable ICU 73
123*0e209d39SAndroid Build Coastguard Worker      */
124*0e209d39SAndroid Build Coastguard Worker     USET_SIMPLE_CASE_INSENSITIVE = 6
125*0e209d39SAndroid Build Coastguard Worker };
126*0e209d39SAndroid Build Coastguard Worker 
127*0e209d39SAndroid Build Coastguard Worker /**
128*0e209d39SAndroid Build Coastguard Worker  * Argument values for whether span() and similar functions continue while
129*0e209d39SAndroid Build Coastguard Worker  * the current character is contained vs. not contained in the set.
130*0e209d39SAndroid Build Coastguard Worker  *
131*0e209d39SAndroid Build Coastguard Worker  * The functionality is straightforward for sets with only single code points,
132*0e209d39SAndroid Build Coastguard Worker  * without strings (which is the common case):
133*0e209d39SAndroid Build Coastguard Worker  * - USET_SPAN_CONTAINED and USET_SPAN_SIMPLE work the same.
134*0e209d39SAndroid Build Coastguard Worker  * - USET_SPAN_CONTAINED and USET_SPAN_SIMPLE are inverses of USET_SPAN_NOT_CONTAINED.
135*0e209d39SAndroid Build Coastguard Worker  * - span() and spanBack() partition any string the same way when
136*0e209d39SAndroid Build Coastguard Worker  *   alternating between span(USET_SPAN_NOT_CONTAINED) and
137*0e209d39SAndroid Build Coastguard Worker  *   span(either "contained" condition).
138*0e209d39SAndroid Build Coastguard Worker  * - Using a complemented (inverted) set and the opposite span conditions
139*0e209d39SAndroid Build Coastguard Worker  *   yields the same results.
140*0e209d39SAndroid Build Coastguard Worker  *
141*0e209d39SAndroid Build Coastguard Worker  * When a set contains multi-code point strings, then these statements may not
142*0e209d39SAndroid Build Coastguard Worker  * be true, depending on the strings in the set (for example, whether they
143*0e209d39SAndroid Build Coastguard Worker  * overlap with each other) and the string that is processed.
144*0e209d39SAndroid Build Coastguard Worker  * For a set with strings:
145*0e209d39SAndroid Build Coastguard Worker  * - The complement of the set contains the opposite set of code points,
146*0e209d39SAndroid Build Coastguard Worker  *   but the same set of strings.
147*0e209d39SAndroid Build Coastguard Worker  *   Therefore, complementing both the set and the span conditions
148*0e209d39SAndroid Build Coastguard Worker  *   may yield different results.
149*0e209d39SAndroid Build Coastguard Worker  * - When starting spans at different positions in a string
150*0e209d39SAndroid Build Coastguard Worker  *   (span(s, ...) vs. span(s+1, ...)) the ends of the spans may be different
151*0e209d39SAndroid Build Coastguard Worker  *   because a set string may start before the later position.
152*0e209d39SAndroid Build Coastguard Worker  * - span(USET_SPAN_SIMPLE) may be shorter than
153*0e209d39SAndroid Build Coastguard Worker  *   span(USET_SPAN_CONTAINED) because it will not recursively try
154*0e209d39SAndroid Build Coastguard Worker  *   all possible paths.
155*0e209d39SAndroid Build Coastguard Worker  *   For example, with a set which contains the three strings "xy", "xya" and "ax",
156*0e209d39SAndroid Build Coastguard Worker  *   span("xyax", USET_SPAN_CONTAINED) will return 4 but
157*0e209d39SAndroid Build Coastguard Worker  *   span("xyax", USET_SPAN_SIMPLE) will return 3.
158*0e209d39SAndroid Build Coastguard Worker  *   span(USET_SPAN_SIMPLE) will never be longer than
159*0e209d39SAndroid Build Coastguard Worker  *   span(USET_SPAN_CONTAINED).
160*0e209d39SAndroid Build Coastguard Worker  * - With either "contained" condition, span() and spanBack() may partition
161*0e209d39SAndroid Build Coastguard Worker  *   a string in different ways.
162*0e209d39SAndroid Build Coastguard Worker  *   For example, with a set which contains the two strings "ab" and "ba",
163*0e209d39SAndroid Build Coastguard Worker  *   and when processing the string "aba",
164*0e209d39SAndroid Build Coastguard Worker  *   span() will yield contained/not-contained boundaries of { 0, 2, 3 }
165*0e209d39SAndroid Build Coastguard Worker  *   while spanBack() will yield boundaries of { 0, 1, 3 }.
166*0e209d39SAndroid Build Coastguard Worker  *
167*0e209d39SAndroid Build Coastguard Worker  * Note: If it is important to get the same boundaries whether iterating forward
168*0e209d39SAndroid Build Coastguard Worker  * or backward through a string, then either only span() should be used and
169*0e209d39SAndroid Build Coastguard Worker  * the boundaries cached for backward operation, or an ICU BreakIterator
170*0e209d39SAndroid Build Coastguard Worker  * could be used.
171*0e209d39SAndroid Build Coastguard Worker  *
172*0e209d39SAndroid Build Coastguard Worker  * Note: Unpaired surrogates are treated like surrogate code points.
173*0e209d39SAndroid Build Coastguard Worker  * Similarly, set strings match only on code point boundaries,
174*0e209d39SAndroid Build Coastguard Worker  * never in the middle of a surrogate pair.
175*0e209d39SAndroid Build Coastguard Worker  * Illegal UTF-8 sequences are treated like U+FFFD.
176*0e209d39SAndroid Build Coastguard Worker  * When processing UTF-8 strings, malformed set strings
177*0e209d39SAndroid Build Coastguard Worker  * (strings with unpaired surrogates which cannot be converted to UTF-8)
178*0e209d39SAndroid Build Coastguard Worker  * are ignored.
179*0e209d39SAndroid Build Coastguard Worker  *
180*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 3.8
181*0e209d39SAndroid Build Coastguard Worker  */
182*0e209d39SAndroid Build Coastguard Worker typedef enum USetSpanCondition {
183*0e209d39SAndroid Build Coastguard Worker     /**
184*0e209d39SAndroid Build Coastguard Worker      * Continues a span() while there is no set element at the current position.
185*0e209d39SAndroid Build Coastguard Worker      * Increments by one code point at a time.
186*0e209d39SAndroid Build Coastguard Worker      * Stops before the first set element (character or string).
187*0e209d39SAndroid Build Coastguard Worker      * (For code points only, this is like while contains(current)==false).
188*0e209d39SAndroid Build Coastguard Worker      *
189*0e209d39SAndroid Build Coastguard Worker      * When span() returns, the substring between where it started and the position
190*0e209d39SAndroid Build Coastguard Worker      * it returned consists only of characters that are not in the set,
191*0e209d39SAndroid Build Coastguard Worker      * and none of its strings overlap with the span.
192*0e209d39SAndroid Build Coastguard Worker      *
193*0e209d39SAndroid Build Coastguard Worker      * @stable ICU 3.8
194*0e209d39SAndroid Build Coastguard Worker      */
195*0e209d39SAndroid Build Coastguard Worker     USET_SPAN_NOT_CONTAINED = 0,
196*0e209d39SAndroid Build Coastguard Worker     /**
197*0e209d39SAndroid Build Coastguard Worker      * Spans the longest substring that is a concatenation of set elements (characters or strings).
198*0e209d39SAndroid Build Coastguard Worker      * (For characters only, this is like while contains(current)==true).
199*0e209d39SAndroid Build Coastguard Worker      *
200*0e209d39SAndroid Build Coastguard Worker      * When span() returns, the substring between where it started and the position
201*0e209d39SAndroid Build Coastguard Worker      * it returned consists only of set elements (characters or strings) that are in the set.
202*0e209d39SAndroid Build Coastguard Worker      *
203*0e209d39SAndroid Build Coastguard Worker      * If a set contains strings, then the span will be the longest substring for which there
204*0e209d39SAndroid Build Coastguard Worker      * exists at least one non-overlapping concatenation of set elements (characters or strings).
205*0e209d39SAndroid Build Coastguard Worker      * This is equivalent to a POSIX regular expression for <code>(OR of each set element)*</code>.
206*0e209d39SAndroid Build Coastguard Worker      * (Java/ICU/Perl regex stops at the first match of an OR.)
207*0e209d39SAndroid Build Coastguard Worker      *
208*0e209d39SAndroid Build Coastguard Worker      * @stable ICU 3.8
209*0e209d39SAndroid Build Coastguard Worker      */
210*0e209d39SAndroid Build Coastguard Worker     USET_SPAN_CONTAINED = 1,
211*0e209d39SAndroid Build Coastguard Worker     /**
212*0e209d39SAndroid Build Coastguard Worker      * Continues a span() while there is a set element at the current position.
213*0e209d39SAndroid Build Coastguard Worker      * Increments by the longest matching element at each position.
214*0e209d39SAndroid Build Coastguard Worker      * (For characters only, this is like while contains(current)==true).
215*0e209d39SAndroid Build Coastguard Worker      *
216*0e209d39SAndroid Build Coastguard Worker      * When span() returns, the substring between where it started and the position
217*0e209d39SAndroid Build Coastguard Worker      * it returned consists only of set elements (characters or strings) that are in the set.
218*0e209d39SAndroid Build Coastguard Worker      *
219*0e209d39SAndroid Build Coastguard Worker      * If a set only contains single characters, then this is the same
220*0e209d39SAndroid Build Coastguard Worker      * as USET_SPAN_CONTAINED.
221*0e209d39SAndroid Build Coastguard Worker      *
222*0e209d39SAndroid Build Coastguard Worker      * If a set contains strings, then the span will be the longest substring
223*0e209d39SAndroid Build Coastguard Worker      * with a match at each position with the longest single set element (character or string).
224*0e209d39SAndroid Build Coastguard Worker      *
225*0e209d39SAndroid Build Coastguard Worker      * Use this span condition together with other longest-match algorithms,
226*0e209d39SAndroid Build Coastguard Worker      * such as ICU converters (ucnv_getUnicodeSet()).
227*0e209d39SAndroid Build Coastguard Worker      *
228*0e209d39SAndroid Build Coastguard Worker      * @stable ICU 3.8
229*0e209d39SAndroid Build Coastguard Worker      */
230*0e209d39SAndroid Build Coastguard Worker     USET_SPAN_SIMPLE = 2,
231*0e209d39SAndroid Build Coastguard Worker #ifndef U_HIDE_DEPRECATED_API
232*0e209d39SAndroid Build Coastguard Worker     /**
233*0e209d39SAndroid Build Coastguard Worker      * One more than the last span condition.
234*0e209d39SAndroid Build Coastguard Worker      * @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420.
235*0e209d39SAndroid Build Coastguard Worker      */
236*0e209d39SAndroid Build Coastguard Worker     USET_SPAN_CONDITION_COUNT
237*0e209d39SAndroid Build Coastguard Worker #endif  // U_HIDE_DEPRECATED_API
238*0e209d39SAndroid Build Coastguard Worker } USetSpanCondition;
239*0e209d39SAndroid Build Coastguard Worker 
240*0e209d39SAndroid Build Coastguard Worker enum {
241*0e209d39SAndroid Build Coastguard Worker     /**
242*0e209d39SAndroid Build Coastguard Worker      * Capacity of USerializedSet::staticArray.
243*0e209d39SAndroid Build Coastguard Worker      * Enough for any single-code point set.
244*0e209d39SAndroid Build Coastguard Worker      * Also provides padding for nice sizeof(USerializedSet).
245*0e209d39SAndroid Build Coastguard Worker      * @stable ICU 2.4
246*0e209d39SAndroid Build Coastguard Worker      */
247*0e209d39SAndroid Build Coastguard Worker     USET_SERIALIZED_STATIC_ARRAY_CAPACITY=8
248*0e209d39SAndroid Build Coastguard Worker };
249*0e209d39SAndroid Build Coastguard Worker 
250*0e209d39SAndroid Build Coastguard Worker /**
251*0e209d39SAndroid Build Coastguard Worker  * A serialized form of a Unicode set.  Limited manipulations are
252*0e209d39SAndroid Build Coastguard Worker  * possible directly on a serialized set.  See below.
253*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 2.4
254*0e209d39SAndroid Build Coastguard Worker  */
255*0e209d39SAndroid Build Coastguard Worker typedef struct USerializedSet {
256*0e209d39SAndroid Build Coastguard Worker     /**
257*0e209d39SAndroid Build Coastguard Worker      * The serialized Unicode Set.
258*0e209d39SAndroid Build Coastguard Worker      * @stable ICU 2.4
259*0e209d39SAndroid Build Coastguard Worker      */
260*0e209d39SAndroid Build Coastguard Worker     const uint16_t *array;
261*0e209d39SAndroid Build Coastguard Worker     /**
262*0e209d39SAndroid Build Coastguard Worker      * The length of the array that contains BMP characters.
263*0e209d39SAndroid Build Coastguard Worker      * @stable ICU 2.4
264*0e209d39SAndroid Build Coastguard Worker      */
265*0e209d39SAndroid Build Coastguard Worker     int32_t bmpLength;
266*0e209d39SAndroid Build Coastguard Worker     /**
267*0e209d39SAndroid Build Coastguard Worker      * The total length of the array.
268*0e209d39SAndroid Build Coastguard Worker      * @stable ICU 2.4
269*0e209d39SAndroid Build Coastguard Worker      */
270*0e209d39SAndroid Build Coastguard Worker     int32_t length;
271*0e209d39SAndroid Build Coastguard Worker     /**
272*0e209d39SAndroid Build Coastguard Worker      * A small buffer for the array to reduce memory allocations.
273*0e209d39SAndroid Build Coastguard Worker      * @stable ICU 2.4
274*0e209d39SAndroid Build Coastguard Worker      */
275*0e209d39SAndroid Build Coastguard Worker     uint16_t staticArray[USET_SERIALIZED_STATIC_ARRAY_CAPACITY];
276*0e209d39SAndroid Build Coastguard Worker } USerializedSet;
277*0e209d39SAndroid Build Coastguard Worker 
278*0e209d39SAndroid Build Coastguard Worker /*********************************************************************
279*0e209d39SAndroid Build Coastguard Worker  * USet API
280*0e209d39SAndroid Build Coastguard Worker  *********************************************************************/
281*0e209d39SAndroid Build Coastguard Worker 
282*0e209d39SAndroid Build Coastguard Worker /**
283*0e209d39SAndroid Build Coastguard Worker  * Create an empty USet object.
284*0e209d39SAndroid Build Coastguard Worker  * Equivalent to uset_open(1, 0).
285*0e209d39SAndroid Build Coastguard Worker  * @return a newly created USet.  The caller must call uset_close() on
286*0e209d39SAndroid Build Coastguard Worker  * it when done.
287*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 4.2
288*0e209d39SAndroid Build Coastguard Worker  */
289*0e209d39SAndroid Build Coastguard Worker U_CAPI USet* U_EXPORT2
290*0e209d39SAndroid Build Coastguard Worker uset_openEmpty(void);
291*0e209d39SAndroid Build Coastguard Worker 
292*0e209d39SAndroid Build Coastguard Worker /**
293*0e209d39SAndroid Build Coastguard Worker  * Creates a USet object that contains the range of characters
294*0e209d39SAndroid Build Coastguard Worker  * start..end, inclusive.  If <code>start > end</code>
295*0e209d39SAndroid Build Coastguard Worker  * then an empty set is created (same as using uset_openEmpty()).
296*0e209d39SAndroid Build Coastguard Worker  * @param start first character of the range, inclusive
297*0e209d39SAndroid Build Coastguard Worker  * @param end last character of the range, inclusive
298*0e209d39SAndroid Build Coastguard Worker  * @return a newly created USet.  The caller must call uset_close() on
299*0e209d39SAndroid Build Coastguard Worker  * it when done.
300*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 2.4
301*0e209d39SAndroid Build Coastguard Worker  */
302*0e209d39SAndroid Build Coastguard Worker U_CAPI USet* U_EXPORT2
303*0e209d39SAndroid Build Coastguard Worker uset_open(UChar32 start, UChar32 end);
304*0e209d39SAndroid Build Coastguard Worker 
305*0e209d39SAndroid Build Coastguard Worker /**
306*0e209d39SAndroid Build Coastguard Worker  * Creates a set from the given pattern.  See the UnicodeSet class
307*0e209d39SAndroid Build Coastguard Worker  * description for the syntax of the pattern language.
308*0e209d39SAndroid Build Coastguard Worker  * @param pattern a string specifying what characters are in the set
309*0e209d39SAndroid Build Coastguard Worker  * @param patternLength the length of the pattern, or -1 if null
310*0e209d39SAndroid Build Coastguard Worker  * terminated
311*0e209d39SAndroid Build Coastguard Worker  * @param ec the error code
312*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 2.4
313*0e209d39SAndroid Build Coastguard Worker  */
314*0e209d39SAndroid Build Coastguard Worker U_CAPI USet* U_EXPORT2
315*0e209d39SAndroid Build Coastguard Worker uset_openPattern(const UChar* pattern, int32_t patternLength,
316*0e209d39SAndroid Build Coastguard Worker                  UErrorCode* ec);
317*0e209d39SAndroid Build Coastguard Worker 
318*0e209d39SAndroid Build Coastguard Worker /**
319*0e209d39SAndroid Build Coastguard Worker  * Creates a set from the given pattern.  See the UnicodeSet class
320*0e209d39SAndroid Build Coastguard Worker  * description for the syntax of the pattern language.
321*0e209d39SAndroid Build Coastguard Worker  * @param pattern a string specifying what characters are in the set
322*0e209d39SAndroid Build Coastguard Worker  * @param patternLength the length of the pattern, or -1 if null
323*0e209d39SAndroid Build Coastguard Worker  * terminated
324*0e209d39SAndroid Build Coastguard Worker  * @param options bitmask for options to apply to the pattern.
325*0e209d39SAndroid Build Coastguard Worker  * Valid options are USET_IGNORE_SPACE and
326*0e209d39SAndroid Build Coastguard Worker  * at most one of USET_CASE_INSENSITIVE, USET_ADD_CASE_MAPPINGS, USET_SIMPLE_CASE_INSENSITIVE.
327*0e209d39SAndroid Build Coastguard Worker  * These case options are mutually exclusive.
328*0e209d39SAndroid Build Coastguard Worker  * @param ec the error code
329*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 2.4
330*0e209d39SAndroid Build Coastguard Worker  */
331*0e209d39SAndroid Build Coastguard Worker U_CAPI USet* U_EXPORT2
332*0e209d39SAndroid Build Coastguard Worker uset_openPatternOptions(const UChar* pattern, int32_t patternLength,
333*0e209d39SAndroid Build Coastguard Worker                  uint32_t options,
334*0e209d39SAndroid Build Coastguard Worker                  UErrorCode* ec);
335*0e209d39SAndroid Build Coastguard Worker 
336*0e209d39SAndroid Build Coastguard Worker /**
337*0e209d39SAndroid Build Coastguard Worker  * Disposes of the storage used by a USet object.  This function should
338*0e209d39SAndroid Build Coastguard Worker  * be called exactly once for objects returned by uset_open().
339*0e209d39SAndroid Build Coastguard Worker  * @param set the object to dispose of
340*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 2.4
341*0e209d39SAndroid Build Coastguard Worker  */
342*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2
343*0e209d39SAndroid Build Coastguard Worker uset_close(USet* set);
344*0e209d39SAndroid Build Coastguard Worker 
345*0e209d39SAndroid Build Coastguard Worker #if U_SHOW_CPLUSPLUS_API
346*0e209d39SAndroid Build Coastguard Worker 
347*0e209d39SAndroid Build Coastguard Worker U_NAMESPACE_BEGIN
348*0e209d39SAndroid Build Coastguard Worker 
349*0e209d39SAndroid Build Coastguard Worker /**
350*0e209d39SAndroid Build Coastguard Worker  * \class LocalUSetPointer
351*0e209d39SAndroid Build Coastguard Worker  * "Smart pointer" class, closes a USet via uset_close().
352*0e209d39SAndroid Build Coastguard Worker  * For most methods see the LocalPointerBase base class.
353*0e209d39SAndroid Build Coastguard Worker  *
354*0e209d39SAndroid Build Coastguard Worker  * @see LocalPointerBase
355*0e209d39SAndroid Build Coastguard Worker  * @see LocalPointer
356*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 4.4
357*0e209d39SAndroid Build Coastguard Worker  */
358*0e209d39SAndroid Build Coastguard Worker U_DEFINE_LOCAL_OPEN_POINTER(LocalUSetPointer, USet, uset_close);
359*0e209d39SAndroid Build Coastguard Worker 
360*0e209d39SAndroid Build Coastguard Worker U_NAMESPACE_END
361*0e209d39SAndroid Build Coastguard Worker 
362*0e209d39SAndroid Build Coastguard Worker #endif
363*0e209d39SAndroid Build Coastguard Worker 
364*0e209d39SAndroid Build Coastguard Worker /**
365*0e209d39SAndroid Build Coastguard Worker  * Returns a copy of this object.
366*0e209d39SAndroid Build Coastguard Worker  * If this set is frozen, then the clone will be frozen as well.
367*0e209d39SAndroid Build Coastguard Worker  * Use uset_cloneAsThawed() for a mutable clone of a frozen set.
368*0e209d39SAndroid Build Coastguard Worker  * @param set the original set
369*0e209d39SAndroid Build Coastguard Worker  * @return the newly allocated copy of the set
370*0e209d39SAndroid Build Coastguard Worker  * @see uset_cloneAsThawed
371*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 3.8
372*0e209d39SAndroid Build Coastguard Worker  */
373*0e209d39SAndroid Build Coastguard Worker U_CAPI USet * U_EXPORT2
374*0e209d39SAndroid Build Coastguard Worker uset_clone(const USet *set);
375*0e209d39SAndroid Build Coastguard Worker 
376*0e209d39SAndroid Build Coastguard Worker /**
377*0e209d39SAndroid Build Coastguard Worker  * Determines whether the set has been frozen (made immutable) or not.
378*0e209d39SAndroid Build Coastguard Worker  * See the ICU4J Freezable interface for details.
379*0e209d39SAndroid Build Coastguard Worker  * @param set the set
380*0e209d39SAndroid Build Coastguard Worker  * @return true/false for whether the set has been frozen
381*0e209d39SAndroid Build Coastguard Worker  * @see uset_freeze
382*0e209d39SAndroid Build Coastguard Worker  * @see uset_cloneAsThawed
383*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 3.8
384*0e209d39SAndroid Build Coastguard Worker  */
385*0e209d39SAndroid Build Coastguard Worker U_CAPI UBool U_EXPORT2
386*0e209d39SAndroid Build Coastguard Worker uset_isFrozen(const USet *set);
387*0e209d39SAndroid Build Coastguard Worker 
388*0e209d39SAndroid Build Coastguard Worker /**
389*0e209d39SAndroid Build Coastguard Worker  * Freeze the set (make it immutable).
390*0e209d39SAndroid Build Coastguard Worker  * Once frozen, it cannot be unfrozen and is therefore thread-safe
391*0e209d39SAndroid Build Coastguard Worker  * until it is deleted.
392*0e209d39SAndroid Build Coastguard Worker  * See the ICU4J Freezable interface for details.
393*0e209d39SAndroid Build Coastguard Worker  * Freezing the set may also make some operations faster, for example
394*0e209d39SAndroid Build Coastguard Worker  * uset_contains() and uset_span().
395*0e209d39SAndroid Build Coastguard Worker  * A frozen set will not be modified. (It remains frozen.)
396*0e209d39SAndroid Build Coastguard Worker  * @param set the set
397*0e209d39SAndroid Build Coastguard Worker  * @return the same set, now frozen
398*0e209d39SAndroid Build Coastguard Worker  * @see uset_isFrozen
399*0e209d39SAndroid Build Coastguard Worker  * @see uset_cloneAsThawed
400*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 3.8
401*0e209d39SAndroid Build Coastguard Worker  */
402*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2
403*0e209d39SAndroid Build Coastguard Worker uset_freeze(USet *set);
404*0e209d39SAndroid Build Coastguard Worker 
405*0e209d39SAndroid Build Coastguard Worker /**
406*0e209d39SAndroid Build Coastguard Worker  * Clone the set and make the clone mutable.
407*0e209d39SAndroid Build Coastguard Worker  * See the ICU4J Freezable interface for details.
408*0e209d39SAndroid Build Coastguard Worker  * @param set the set
409*0e209d39SAndroid Build Coastguard Worker  * @return the mutable clone
410*0e209d39SAndroid Build Coastguard Worker  * @see uset_freeze
411*0e209d39SAndroid Build Coastguard Worker  * @see uset_isFrozen
412*0e209d39SAndroid Build Coastguard Worker  * @see uset_clone
413*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 3.8
414*0e209d39SAndroid Build Coastguard Worker  */
415*0e209d39SAndroid Build Coastguard Worker U_CAPI USet * U_EXPORT2
416*0e209d39SAndroid Build Coastguard Worker uset_cloneAsThawed(const USet *set);
417*0e209d39SAndroid Build Coastguard Worker 
418*0e209d39SAndroid Build Coastguard Worker /**
419*0e209d39SAndroid Build Coastguard Worker  * Causes the USet object to represent the range <code>start - end</code>.
420*0e209d39SAndroid Build Coastguard Worker  * If <code>start > end</code> then this USet is set to an empty range.
421*0e209d39SAndroid Build Coastguard Worker  * A frozen set will not be modified.
422*0e209d39SAndroid Build Coastguard Worker  * @param set the object to set to the given range
423*0e209d39SAndroid Build Coastguard Worker  * @param start first character in the set, inclusive
424*0e209d39SAndroid Build Coastguard Worker  * @param end last character in the set, inclusive
425*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 3.2
426*0e209d39SAndroid Build Coastguard Worker  */
427*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2
428*0e209d39SAndroid Build Coastguard Worker uset_set(USet* set,
429*0e209d39SAndroid Build Coastguard Worker          UChar32 start, UChar32 end);
430*0e209d39SAndroid Build Coastguard Worker 
431*0e209d39SAndroid Build Coastguard Worker /**
432*0e209d39SAndroid Build Coastguard Worker  * Modifies the set to represent the set specified by the given
433*0e209d39SAndroid Build Coastguard Worker  * pattern. See the UnicodeSet class description for the syntax of
434*0e209d39SAndroid Build Coastguard Worker  * the pattern language. See also the User Guide chapter about UnicodeSet.
435*0e209d39SAndroid Build Coastguard Worker  * <em>Empties the set passed before applying the pattern.</em>
436*0e209d39SAndroid Build Coastguard Worker  * A frozen set will not be modified.
437*0e209d39SAndroid Build Coastguard Worker  * @param set               The set to which the pattern is to be applied.
438*0e209d39SAndroid Build Coastguard Worker  * @param pattern           A pointer to UChar string specifying what characters are in the set.
439*0e209d39SAndroid Build Coastguard Worker  *                          The character at pattern[0] must be a '['.
440*0e209d39SAndroid Build Coastguard Worker  * @param patternLength     The length of the UChar string. -1 if NUL terminated.
441*0e209d39SAndroid Build Coastguard Worker  * @param options           A bitmask for options to apply to the pattern.
442*0e209d39SAndroid Build Coastguard Worker  *                          Valid options are USET_IGNORE_SPACE and
443*0e209d39SAndroid Build Coastguard Worker  *                          at most one of USET_CASE_INSENSITIVE, USET_ADD_CASE_MAPPINGS,
444*0e209d39SAndroid Build Coastguard Worker  *                          USET_SIMPLE_CASE_INSENSITIVE.
445*0e209d39SAndroid Build Coastguard Worker  *                          These case options are mutually exclusive.
446*0e209d39SAndroid Build Coastguard Worker  * @param status            Returns an error if the pattern cannot be parsed.
447*0e209d39SAndroid Build Coastguard Worker  * @return                  Upon successful parse, the value is either
448*0e209d39SAndroid Build Coastguard Worker  *                          the index of the character after the closing ']'
449*0e209d39SAndroid Build Coastguard Worker  *                          of the parsed pattern.
450*0e209d39SAndroid Build Coastguard Worker  *                          If the status code indicates failure, then the return value
451*0e209d39SAndroid Build Coastguard Worker  *                          is the index of the error in the source.
452*0e209d39SAndroid Build Coastguard Worker  *
453*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 2.8
454*0e209d39SAndroid Build Coastguard Worker  */
455*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2
456*0e209d39SAndroid Build Coastguard Worker uset_applyPattern(USet *set,
457*0e209d39SAndroid Build Coastguard Worker                   const UChar *pattern, int32_t patternLength,
458*0e209d39SAndroid Build Coastguard Worker                   uint32_t options,
459*0e209d39SAndroid Build Coastguard Worker                   UErrorCode *status);
460*0e209d39SAndroid Build Coastguard Worker 
461*0e209d39SAndroid Build Coastguard Worker /**
462*0e209d39SAndroid Build Coastguard Worker  * Modifies the set to contain those code points which have the given value
463*0e209d39SAndroid Build Coastguard Worker  * for the given binary or enumerated property, as returned by
464*0e209d39SAndroid Build Coastguard Worker  * u_getIntPropertyValue.  Prior contents of this set are lost.
465*0e209d39SAndroid Build Coastguard Worker  * A frozen set will not be modified.
466*0e209d39SAndroid Build Coastguard Worker  *
467*0e209d39SAndroid Build Coastguard Worker  * @param set the object to contain the code points defined by the property
468*0e209d39SAndroid Build Coastguard Worker  *
469*0e209d39SAndroid Build Coastguard Worker  * @param prop a property in the range UCHAR_BIN_START..UCHAR_BIN_LIMIT-1
470*0e209d39SAndroid Build Coastguard Worker  * or UCHAR_INT_START..UCHAR_INT_LIMIT-1
471*0e209d39SAndroid Build Coastguard Worker  * or UCHAR_MASK_START..UCHAR_MASK_LIMIT-1.
472*0e209d39SAndroid Build Coastguard Worker  *
473*0e209d39SAndroid Build Coastguard Worker  * @param value a value in the range u_getIntPropertyMinValue(prop)..
474*0e209d39SAndroid Build Coastguard Worker  * u_getIntPropertyMaxValue(prop), with one exception.  If prop is
475*0e209d39SAndroid Build Coastguard Worker  * UCHAR_GENERAL_CATEGORY_MASK, then value should not be a UCharCategory, but
476*0e209d39SAndroid Build Coastguard Worker  * rather a mask value produced by U_GET_GC_MASK().  This allows grouped
477*0e209d39SAndroid Build Coastguard Worker  * categories such as [:L:] to be represented.
478*0e209d39SAndroid Build Coastguard Worker  *
479*0e209d39SAndroid Build Coastguard Worker  * @param ec error code input/output parameter
480*0e209d39SAndroid Build Coastguard Worker  *
481*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 3.2
482*0e209d39SAndroid Build Coastguard Worker  */
483*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2
484*0e209d39SAndroid Build Coastguard Worker uset_applyIntPropertyValue(USet* set,
485*0e209d39SAndroid Build Coastguard Worker                            UProperty prop, int32_t value, UErrorCode* ec);
486*0e209d39SAndroid Build Coastguard Worker 
487*0e209d39SAndroid Build Coastguard Worker /**
488*0e209d39SAndroid Build Coastguard Worker  * Modifies the set to contain those code points which have the
489*0e209d39SAndroid Build Coastguard Worker  * given value for the given property.  Prior contents of this
490*0e209d39SAndroid Build Coastguard Worker  * set are lost.
491*0e209d39SAndroid Build Coastguard Worker  * A frozen set will not be modified.
492*0e209d39SAndroid Build Coastguard Worker  *
493*0e209d39SAndroid Build Coastguard Worker  * @param set the object to contain the code points defined by the given
494*0e209d39SAndroid Build Coastguard Worker  * property and value alias
495*0e209d39SAndroid Build Coastguard Worker  *
496*0e209d39SAndroid Build Coastguard Worker  * @param prop a string specifying a property alias, either short or long.
497*0e209d39SAndroid Build Coastguard Worker  * The name is matched loosely.  See PropertyAliases.txt for names and a
498*0e209d39SAndroid Build Coastguard Worker  * description of loose matching.  If the value string is empty, then this
499*0e209d39SAndroid Build Coastguard Worker  * string is interpreted as either a General_Category value alias, a Script
500*0e209d39SAndroid Build Coastguard Worker  * value alias, a binary property alias, or a special ID.  Special IDs are
501*0e209d39SAndroid Build Coastguard Worker  * matched loosely and correspond to the following sets:
502*0e209d39SAndroid Build Coastguard Worker  *
503*0e209d39SAndroid Build Coastguard Worker  * "ANY" = [\\u0000-\\U0010FFFF],
504*0e209d39SAndroid Build Coastguard Worker  * "ASCII" = [\\u0000-\\u007F],
505*0e209d39SAndroid Build Coastguard Worker  * "Assigned" = [:^Cn:].
506*0e209d39SAndroid Build Coastguard Worker  *
507*0e209d39SAndroid Build Coastguard Worker  * @param propLength the length of the prop, or -1 if NULL
508*0e209d39SAndroid Build Coastguard Worker  *
509*0e209d39SAndroid Build Coastguard Worker  * @param value a string specifying a value alias, either short or long.
510*0e209d39SAndroid Build Coastguard Worker  * The name is matched loosely.  See PropertyValueAliases.txt for names
511*0e209d39SAndroid Build Coastguard Worker  * and a description of loose matching.  In addition to aliases listed,
512*0e209d39SAndroid Build Coastguard Worker  * numeric values and canonical combining classes may be expressed
513*0e209d39SAndroid Build Coastguard Worker  * numerically, e.g., ("nv", "0.5") or ("ccc", "220").  The value string
514*0e209d39SAndroid Build Coastguard Worker  * may also be empty.
515*0e209d39SAndroid Build Coastguard Worker  *
516*0e209d39SAndroid Build Coastguard Worker  * @param valueLength the length of the value, or -1 if NULL
517*0e209d39SAndroid Build Coastguard Worker  *
518*0e209d39SAndroid Build Coastguard Worker  * @param ec error code input/output parameter
519*0e209d39SAndroid Build Coastguard Worker  *
520*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 3.2
521*0e209d39SAndroid Build Coastguard Worker  */
522*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2
523*0e209d39SAndroid Build Coastguard Worker uset_applyPropertyAlias(USet* set,
524*0e209d39SAndroid Build Coastguard Worker                         const UChar *prop, int32_t propLength,
525*0e209d39SAndroid Build Coastguard Worker                         const UChar *value, int32_t valueLength,
526*0e209d39SAndroid Build Coastguard Worker                         UErrorCode* ec);
527*0e209d39SAndroid Build Coastguard Worker 
528*0e209d39SAndroid Build Coastguard Worker /**
529*0e209d39SAndroid Build Coastguard Worker  * Return true if the given position, in the given pattern, appears
530*0e209d39SAndroid Build Coastguard Worker  * to be the start of a UnicodeSet pattern.
531*0e209d39SAndroid Build Coastguard Worker  *
532*0e209d39SAndroid Build Coastguard Worker  * @param pattern a string specifying the pattern
533*0e209d39SAndroid Build Coastguard Worker  * @param patternLength the length of the pattern, or -1 if NULL
534*0e209d39SAndroid Build Coastguard Worker  * @param pos the given position
535*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 3.2
536*0e209d39SAndroid Build Coastguard Worker  */
537*0e209d39SAndroid Build Coastguard Worker U_CAPI UBool U_EXPORT2
538*0e209d39SAndroid Build Coastguard Worker uset_resemblesPattern(const UChar *pattern, int32_t patternLength,
539*0e209d39SAndroid Build Coastguard Worker                       int32_t pos);
540*0e209d39SAndroid Build Coastguard Worker 
541*0e209d39SAndroid Build Coastguard Worker /**
542*0e209d39SAndroid Build Coastguard Worker  * Returns a string representation of this set.  If the result of
543*0e209d39SAndroid Build Coastguard Worker  * calling this function is passed to a uset_openPattern(), it
544*0e209d39SAndroid Build Coastguard Worker  * will produce another set that is equal to this one.
545*0e209d39SAndroid Build Coastguard Worker  * @param set the set
546*0e209d39SAndroid Build Coastguard Worker  * @param result the string to receive the rules, may be NULL
547*0e209d39SAndroid Build Coastguard Worker  * @param resultCapacity the capacity of result, may be 0 if result is NULL
548*0e209d39SAndroid Build Coastguard Worker  * @param escapeUnprintable if true then convert unprintable
549*0e209d39SAndroid Build Coastguard Worker  * character to their hex escape representations, \\uxxxx or
550*0e209d39SAndroid Build Coastguard Worker  * \\Uxxxxxxxx.  Unprintable characters are those other than
551*0e209d39SAndroid Build Coastguard Worker  * U+000A, U+0020..U+007E.
552*0e209d39SAndroid Build Coastguard Worker  * @param ec error code.
553*0e209d39SAndroid Build Coastguard Worker  * @return length of string, possibly larger than resultCapacity
554*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 2.4
555*0e209d39SAndroid Build Coastguard Worker  */
556*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2
557*0e209d39SAndroid Build Coastguard Worker uset_toPattern(const USet* set,
558*0e209d39SAndroid Build Coastguard Worker                UChar* result, int32_t resultCapacity,
559*0e209d39SAndroid Build Coastguard Worker                UBool escapeUnprintable,
560*0e209d39SAndroid Build Coastguard Worker                UErrorCode* ec);
561*0e209d39SAndroid Build Coastguard Worker 
562*0e209d39SAndroid Build Coastguard Worker /**
563*0e209d39SAndroid Build Coastguard Worker  * Adds the given character to the given USet.  After this call,
564*0e209d39SAndroid Build Coastguard Worker  * uset_contains(set, c) will return true.
565*0e209d39SAndroid Build Coastguard Worker  * A frozen set will not be modified.
566*0e209d39SAndroid Build Coastguard Worker  * @param set the object to which to add the character
567*0e209d39SAndroid Build Coastguard Worker  * @param c the character to add
568*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 2.4
569*0e209d39SAndroid Build Coastguard Worker  */
570*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2
571*0e209d39SAndroid Build Coastguard Worker uset_add(USet* set, UChar32 c);
572*0e209d39SAndroid Build Coastguard Worker 
573*0e209d39SAndroid Build Coastguard Worker /**
574*0e209d39SAndroid Build Coastguard Worker  * Adds all of the elements in the specified set to this set if
575*0e209d39SAndroid Build Coastguard Worker  * they're not already present.  This operation effectively
576*0e209d39SAndroid Build Coastguard Worker  * modifies this set so that its value is the <i>union</i> of the two
577*0e209d39SAndroid Build Coastguard Worker  * sets.  The behavior of this operation is unspecified if the specified
578*0e209d39SAndroid Build Coastguard Worker  * collection is modified while the operation is in progress.
579*0e209d39SAndroid Build Coastguard Worker  * A frozen set will not be modified.
580*0e209d39SAndroid Build Coastguard Worker  *
581*0e209d39SAndroid Build Coastguard Worker  * @param set the object to which to add the set
582*0e209d39SAndroid Build Coastguard Worker  * @param additionalSet the source set whose elements are to be added to this set.
583*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 2.6
584*0e209d39SAndroid Build Coastguard Worker  */
585*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2
586*0e209d39SAndroid Build Coastguard Worker uset_addAll(USet* set, const USet *additionalSet);
587*0e209d39SAndroid Build Coastguard Worker 
588*0e209d39SAndroid Build Coastguard Worker /**
589*0e209d39SAndroid Build Coastguard Worker  * Adds the given range of characters to the given USet.  After this call,
590*0e209d39SAndroid Build Coastguard Worker  * uset_contains(set, start, end) will return true.
591*0e209d39SAndroid Build Coastguard Worker  * A frozen set will not be modified.
592*0e209d39SAndroid Build Coastguard Worker  * @param set the object to which to add the character
593*0e209d39SAndroid Build Coastguard Worker  * @param start the first character of the range to add, inclusive
594*0e209d39SAndroid Build Coastguard Worker  * @param end the last character of the range to add, inclusive
595*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 2.2
596*0e209d39SAndroid Build Coastguard Worker  */
597*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2
598*0e209d39SAndroid Build Coastguard Worker uset_addRange(USet* set, UChar32 start, UChar32 end);
599*0e209d39SAndroid Build Coastguard Worker 
600*0e209d39SAndroid Build Coastguard Worker /**
601*0e209d39SAndroid Build Coastguard Worker  * Adds the given string to the given USet.  After this call,
602*0e209d39SAndroid Build Coastguard Worker  * uset_containsString(set, str, strLen) will return true.
603*0e209d39SAndroid Build Coastguard Worker  * A frozen set will not be modified.
604*0e209d39SAndroid Build Coastguard Worker  * @param set the object to which to add the character
605*0e209d39SAndroid Build Coastguard Worker  * @param str the string to add
606*0e209d39SAndroid Build Coastguard Worker  * @param strLen the length of the string or -1 if null terminated.
607*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 2.4
608*0e209d39SAndroid Build Coastguard Worker  */
609*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2
610*0e209d39SAndroid Build Coastguard Worker uset_addString(USet* set, const UChar* str, int32_t strLen);
611*0e209d39SAndroid Build Coastguard Worker 
612*0e209d39SAndroid Build Coastguard Worker /**
613*0e209d39SAndroid Build Coastguard Worker  * Adds each of the characters in this string to the set. Note: "ch" => {"c", "h"}
614*0e209d39SAndroid Build Coastguard Worker  * If this set already contains any particular character, it has no effect on that character.
615*0e209d39SAndroid Build Coastguard Worker  * A frozen set will not be modified.
616*0e209d39SAndroid Build Coastguard Worker  * @param set the object to which to add the character
617*0e209d39SAndroid Build Coastguard Worker  * @param str the source string
618*0e209d39SAndroid Build Coastguard Worker  * @param strLen the length of the string or -1 if null terminated.
619*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 3.4
620*0e209d39SAndroid Build Coastguard Worker  */
621*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2
622*0e209d39SAndroid Build Coastguard Worker uset_addAllCodePoints(USet* set, const UChar *str, int32_t strLen);
623*0e209d39SAndroid Build Coastguard Worker 
624*0e209d39SAndroid Build Coastguard Worker /**
625*0e209d39SAndroid Build Coastguard Worker  * Removes the given character from the given USet.  After this call,
626*0e209d39SAndroid Build Coastguard Worker  * uset_contains(set, c) will return false.
627*0e209d39SAndroid Build Coastguard Worker  * A frozen set will not be modified.
628*0e209d39SAndroid Build Coastguard Worker  * @param set the object from which to remove the character
629*0e209d39SAndroid Build Coastguard Worker  * @param c the character to remove
630*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 2.4
631*0e209d39SAndroid Build Coastguard Worker  */
632*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2
633*0e209d39SAndroid Build Coastguard Worker uset_remove(USet* set, UChar32 c);
634*0e209d39SAndroid Build Coastguard Worker 
635*0e209d39SAndroid Build Coastguard Worker /**
636*0e209d39SAndroid Build Coastguard Worker  * Removes the given range of characters from the given USet.  After this call,
637*0e209d39SAndroid Build Coastguard Worker  * uset_contains(set, start, end) will return false.
638*0e209d39SAndroid Build Coastguard Worker  * A frozen set will not be modified.
639*0e209d39SAndroid Build Coastguard Worker  * @param set the object to which to add the character
640*0e209d39SAndroid Build Coastguard Worker  * @param start the first character of the range to remove, inclusive
641*0e209d39SAndroid Build Coastguard Worker  * @param end the last character of the range to remove, inclusive
642*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 2.2
643*0e209d39SAndroid Build Coastguard Worker  */
644*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2
645*0e209d39SAndroid Build Coastguard Worker uset_removeRange(USet* set, UChar32 start, UChar32 end);
646*0e209d39SAndroid Build Coastguard Worker 
647*0e209d39SAndroid Build Coastguard Worker /**
648*0e209d39SAndroid Build Coastguard Worker  * Removes the given string to the given USet.  After this call,
649*0e209d39SAndroid Build Coastguard Worker  * uset_containsString(set, str, strLen) will return false.
650*0e209d39SAndroid Build Coastguard Worker  * A frozen set will not be modified.
651*0e209d39SAndroid Build Coastguard Worker  * @param set the object to which to add the character
652*0e209d39SAndroid Build Coastguard Worker  * @param str the string to remove
653*0e209d39SAndroid Build Coastguard Worker  * @param strLen the length of the string or -1 if null terminated.
654*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 2.4
655*0e209d39SAndroid Build Coastguard Worker  */
656*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2
657*0e209d39SAndroid Build Coastguard Worker uset_removeString(USet* set, const UChar* str, int32_t strLen);
658*0e209d39SAndroid Build Coastguard Worker 
659*0e209d39SAndroid Build Coastguard Worker /**
660*0e209d39SAndroid Build Coastguard Worker  * Removes EACH of the characters in this string. Note: "ch" == {"c", "h"}
661*0e209d39SAndroid Build Coastguard Worker  * A frozen set will not be modified.
662*0e209d39SAndroid Build Coastguard Worker  *
663*0e209d39SAndroid Build Coastguard Worker  * @param set the object to be modified
664*0e209d39SAndroid Build Coastguard Worker  * @param str the string
665*0e209d39SAndroid Build Coastguard Worker  * @param length the length of the string, or -1 if NUL-terminated
666*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 69
667*0e209d39SAndroid Build Coastguard Worker  */
668*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2
669*0e209d39SAndroid Build Coastguard Worker uset_removeAllCodePoints(USet *set, const UChar *str, int32_t length);
670*0e209d39SAndroid Build Coastguard Worker 
671*0e209d39SAndroid Build Coastguard Worker /**
672*0e209d39SAndroid Build Coastguard Worker  * Removes from this set all of its elements that are contained in the
673*0e209d39SAndroid Build Coastguard Worker  * specified set.  This operation effectively modifies this
674*0e209d39SAndroid Build Coastguard Worker  * set so that its value is the <i>asymmetric set difference</i> of
675*0e209d39SAndroid Build Coastguard Worker  * the two sets.
676*0e209d39SAndroid Build Coastguard Worker  * A frozen set will not be modified.
677*0e209d39SAndroid Build Coastguard Worker  * @param set the object from which the elements are to be removed
678*0e209d39SAndroid Build Coastguard Worker  * @param removeSet the object that defines which elements will be
679*0e209d39SAndroid Build Coastguard Worker  * removed from this set
680*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 3.2
681*0e209d39SAndroid Build Coastguard Worker  */
682*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2
683*0e209d39SAndroid Build Coastguard Worker uset_removeAll(USet* set, const USet* removeSet);
684*0e209d39SAndroid Build Coastguard Worker 
685*0e209d39SAndroid Build Coastguard Worker /**
686*0e209d39SAndroid Build Coastguard Worker  * Retain only the elements in this set that are contained in the
687*0e209d39SAndroid Build Coastguard Worker  * specified range.  If <code>start > end</code> then an empty range is
688*0e209d39SAndroid Build Coastguard Worker  * retained, leaving the set empty.  This is equivalent to
689*0e209d39SAndroid Build Coastguard Worker  * a boolean logic AND, or a set INTERSECTION.
690*0e209d39SAndroid Build Coastguard Worker  * A frozen set will not be modified.
691*0e209d39SAndroid Build Coastguard Worker  *
692*0e209d39SAndroid Build Coastguard Worker  * @param set the object for which to retain only the specified range
693*0e209d39SAndroid Build Coastguard Worker  * @param start first character, inclusive, of range
694*0e209d39SAndroid Build Coastguard Worker  * @param end last character, inclusive, of range
695*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 3.2
696*0e209d39SAndroid Build Coastguard Worker  */
697*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2
698*0e209d39SAndroid Build Coastguard Worker uset_retain(USet* set, UChar32 start, UChar32 end);
699*0e209d39SAndroid Build Coastguard Worker 
700*0e209d39SAndroid Build Coastguard Worker /**
701*0e209d39SAndroid Build Coastguard Worker  * Retains only the specified string from this set if it is present.
702*0e209d39SAndroid Build Coastguard Worker  * Upon return this set will be empty if it did not contain s, or
703*0e209d39SAndroid Build Coastguard Worker  * will only contain s if it did contain s.
704*0e209d39SAndroid Build Coastguard Worker  * A frozen set will not be modified.
705*0e209d39SAndroid Build Coastguard Worker  *
706*0e209d39SAndroid Build Coastguard Worker  * @param set the object to be modified
707*0e209d39SAndroid Build Coastguard Worker  * @param str the string
708*0e209d39SAndroid Build Coastguard Worker  * @param length the length of the string, or -1 if NUL-terminated
709*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 69
710*0e209d39SAndroid Build Coastguard Worker  */
711*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2
712*0e209d39SAndroid Build Coastguard Worker uset_retainString(USet *set, const UChar *str, int32_t length);
713*0e209d39SAndroid Build Coastguard Worker 
714*0e209d39SAndroid Build Coastguard Worker /**
715*0e209d39SAndroid Build Coastguard Worker  * Retains EACH of the characters in this string. Note: "ch" == {"c", "h"}
716*0e209d39SAndroid Build Coastguard Worker  * A frozen set will not be modified.
717*0e209d39SAndroid Build Coastguard Worker  *
718*0e209d39SAndroid Build Coastguard Worker  * @param set the object to be modified
719*0e209d39SAndroid Build Coastguard Worker  * @param str the string
720*0e209d39SAndroid Build Coastguard Worker  * @param length the length of the string, or -1 if NUL-terminated
721*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 69
722*0e209d39SAndroid Build Coastguard Worker  */
723*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2
724*0e209d39SAndroid Build Coastguard Worker uset_retainAllCodePoints(USet *set, const UChar *str, int32_t length);
725*0e209d39SAndroid Build Coastguard Worker 
726*0e209d39SAndroid Build Coastguard Worker /**
727*0e209d39SAndroid Build Coastguard Worker  * Retains only the elements in this set that are contained in the
728*0e209d39SAndroid Build Coastguard Worker  * specified set.  In other words, removes from this set all of
729*0e209d39SAndroid Build Coastguard Worker  * its elements that are not contained in the specified set.  This
730*0e209d39SAndroid Build Coastguard Worker  * operation effectively modifies this set so that its value is
731*0e209d39SAndroid Build Coastguard Worker  * the <i>intersection</i> of the two sets.
732*0e209d39SAndroid Build Coastguard Worker  * A frozen set will not be modified.
733*0e209d39SAndroid Build Coastguard Worker  *
734*0e209d39SAndroid Build Coastguard Worker  * @param set the object on which to perform the retain
735*0e209d39SAndroid Build Coastguard Worker  * @param retain set that defines which elements this set will retain
736*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 3.2
737*0e209d39SAndroid Build Coastguard Worker  */
738*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2
739*0e209d39SAndroid Build Coastguard Worker uset_retainAll(USet* set, const USet* retain);
740*0e209d39SAndroid Build Coastguard Worker 
741*0e209d39SAndroid Build Coastguard Worker /**
742*0e209d39SAndroid Build Coastguard Worker  * Reallocate this objects internal structures to take up the least
743*0e209d39SAndroid Build Coastguard Worker  * possible space, without changing this object's value.
744*0e209d39SAndroid Build Coastguard Worker  * A frozen set will not be modified.
745*0e209d39SAndroid Build Coastguard Worker  *
746*0e209d39SAndroid Build Coastguard Worker  * @param set the object on which to perform the compact
747*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 3.2
748*0e209d39SAndroid Build Coastguard Worker  */
749*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2
750*0e209d39SAndroid Build Coastguard Worker uset_compact(USet* set);
751*0e209d39SAndroid Build Coastguard Worker 
752*0e209d39SAndroid Build Coastguard Worker /**
753*0e209d39SAndroid Build Coastguard Worker  * This is equivalent to
754*0e209d39SAndroid Build Coastguard Worker  * <code>uset_complementRange(set, 0, 0x10FFFF)</code>.
755*0e209d39SAndroid Build Coastguard Worker  *
756*0e209d39SAndroid Build Coastguard Worker  * <strong>Note:</strong> This performs a symmetric difference with all code points
757*0e209d39SAndroid Build Coastguard Worker  * <em>and thus retains all multicharacter strings</em>.
758*0e209d39SAndroid Build Coastguard Worker  * In order to achieve a “code point complement” (all code points minus this set),
759*0e209d39SAndroid Build Coastguard Worker  * the easiest is to <code>uset_complement(set); uset_removeAllStrings(set);</code>.
760*0e209d39SAndroid Build Coastguard Worker  *
761*0e209d39SAndroid Build Coastguard Worker  * A frozen set will not be modified.
762*0e209d39SAndroid Build Coastguard Worker  * @param set the set
763*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 2.4
764*0e209d39SAndroid Build Coastguard Worker  */
765*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2
766*0e209d39SAndroid Build Coastguard Worker uset_complement(USet* set);
767*0e209d39SAndroid Build Coastguard Worker 
768*0e209d39SAndroid Build Coastguard Worker /**
769*0e209d39SAndroid Build Coastguard Worker  * Complements the specified range in this set.  Any character in
770*0e209d39SAndroid Build Coastguard Worker  * the range will be removed if it is in this set, or will be
771*0e209d39SAndroid Build Coastguard Worker  * added if it is not in this set.  If <code>start > end</code>
772*0e209d39SAndroid Build Coastguard Worker  * then an empty range is complemented, leaving the set unchanged.
773*0e209d39SAndroid Build Coastguard Worker  * This is equivalent to a boolean logic XOR.
774*0e209d39SAndroid Build Coastguard Worker  * A frozen set will not be modified.
775*0e209d39SAndroid Build Coastguard Worker  *
776*0e209d39SAndroid Build Coastguard Worker  * @param set the object to be modified
777*0e209d39SAndroid Build Coastguard Worker  * @param start first character, inclusive, of range
778*0e209d39SAndroid Build Coastguard Worker  * @param end last character, inclusive, of range
779*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 69
780*0e209d39SAndroid Build Coastguard Worker  */
781*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2
782*0e209d39SAndroid Build Coastguard Worker uset_complementRange(USet *set, UChar32 start, UChar32 end);
783*0e209d39SAndroid Build Coastguard Worker 
784*0e209d39SAndroid Build Coastguard Worker /**
785*0e209d39SAndroid Build Coastguard Worker  * Complements the specified string in this set.
786*0e209d39SAndroid Build Coastguard Worker  * The string will be removed if it is in this set, or will be added if it is not in this set.
787*0e209d39SAndroid Build Coastguard Worker  * A frozen set will not be modified.
788*0e209d39SAndroid Build Coastguard Worker  *
789*0e209d39SAndroid Build Coastguard Worker  * @param set the object to be modified
790*0e209d39SAndroid Build Coastguard Worker  * @param str the string
791*0e209d39SAndroid Build Coastguard Worker  * @param length the length of the string, or -1 if NUL-terminated
792*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 69
793*0e209d39SAndroid Build Coastguard Worker  */
794*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2
795*0e209d39SAndroid Build Coastguard Worker uset_complementString(USet *set, const UChar *str, int32_t length);
796*0e209d39SAndroid Build Coastguard Worker 
797*0e209d39SAndroid Build Coastguard Worker /**
798*0e209d39SAndroid Build Coastguard Worker  * Complements EACH of the characters in this string. Note: "ch" == {"c", "h"}
799*0e209d39SAndroid Build Coastguard Worker  * A frozen set will not be modified.
800*0e209d39SAndroid Build Coastguard Worker  *
801*0e209d39SAndroid Build Coastguard Worker  * @param set the object to be modified
802*0e209d39SAndroid Build Coastguard Worker  * @param str the string
803*0e209d39SAndroid Build Coastguard Worker  * @param length the length of the string, or -1 if NUL-terminated
804*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 69
805*0e209d39SAndroid Build Coastguard Worker  */
806*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2
807*0e209d39SAndroid Build Coastguard Worker uset_complementAllCodePoints(USet *set, const UChar *str, int32_t length);
808*0e209d39SAndroid Build Coastguard Worker 
809*0e209d39SAndroid Build Coastguard Worker /**
810*0e209d39SAndroid Build Coastguard Worker  * Complements in this set all elements contained in the specified
811*0e209d39SAndroid Build Coastguard Worker  * set.  Any character in the other set will be removed if it is
812*0e209d39SAndroid Build Coastguard Worker  * in this set, or will be added if it is not in this set.
813*0e209d39SAndroid Build Coastguard Worker  * A frozen set will not be modified.
814*0e209d39SAndroid Build Coastguard Worker  *
815*0e209d39SAndroid Build Coastguard Worker  * @param set the set with which to complement
816*0e209d39SAndroid Build Coastguard Worker  * @param complement set that defines which elements will be xor'ed
817*0e209d39SAndroid Build Coastguard Worker  * from this set.
818*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 3.2
819*0e209d39SAndroid Build Coastguard Worker  */
820*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2
821*0e209d39SAndroid Build Coastguard Worker uset_complementAll(USet* set, const USet* complement);
822*0e209d39SAndroid Build Coastguard Worker 
823*0e209d39SAndroid Build Coastguard Worker /**
824*0e209d39SAndroid Build Coastguard Worker  * Removes all of the elements from this set.  This set will be
825*0e209d39SAndroid Build Coastguard Worker  * empty after this call returns.
826*0e209d39SAndroid Build Coastguard Worker  * A frozen set will not be modified.
827*0e209d39SAndroid Build Coastguard Worker  * @param set the set
828*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 2.4
829*0e209d39SAndroid Build Coastguard Worker  */
830*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2
831*0e209d39SAndroid Build Coastguard Worker uset_clear(USet* set);
832*0e209d39SAndroid Build Coastguard Worker 
833*0e209d39SAndroid Build Coastguard Worker /**
834*0e209d39SAndroid Build Coastguard Worker  * Close this set over the given attribute.  For the attribute
835*0e209d39SAndroid Build Coastguard Worker  * USET_CASE_INSENSITIVE, the result is to modify this set so that:
836*0e209d39SAndroid Build Coastguard Worker  *
837*0e209d39SAndroid Build Coastguard Worker  * 1. For each character or string 'a' in this set, all strings or
838*0e209d39SAndroid Build Coastguard Worker  * characters 'b' such that foldCase(a) == foldCase(b) are added
839*0e209d39SAndroid Build Coastguard Worker  * to this set.
840*0e209d39SAndroid Build Coastguard Worker  *
841*0e209d39SAndroid Build Coastguard Worker  * 2. For each string 'e' in the resulting set, if e !=
842*0e209d39SAndroid Build Coastguard Worker  * foldCase(e), 'e' will be removed.
843*0e209d39SAndroid Build Coastguard Worker  *
844*0e209d39SAndroid Build Coastguard Worker  * Example: [aq\\u00DF{Bc}{bC}{Fi}] => [aAqQ\\u00DF\\uFB01{ss}{bc}{fi}]
845*0e209d39SAndroid Build Coastguard Worker  *
846*0e209d39SAndroid Build Coastguard Worker  * (Here foldCase(x) refers to the operation u_strFoldCase, and a
847*0e209d39SAndroid Build Coastguard Worker  * == b denotes that the contents are the same, not pointer
848*0e209d39SAndroid Build Coastguard Worker  * comparison.)
849*0e209d39SAndroid Build Coastguard Worker  *
850*0e209d39SAndroid Build Coastguard Worker  * A frozen set will not be modified.
851*0e209d39SAndroid Build Coastguard Worker  *
852*0e209d39SAndroid Build Coastguard Worker  * @param set the set
853*0e209d39SAndroid Build Coastguard Worker  *
854*0e209d39SAndroid Build Coastguard Worker  * @param attributes bitmask for attributes to close over.
855*0e209d39SAndroid Build Coastguard Worker  * Valid options:
856*0e209d39SAndroid Build Coastguard Worker  * At most one of USET_CASE_INSENSITIVE, USET_ADD_CASE_MAPPINGS, USET_SIMPLE_CASE_INSENSITIVE.
857*0e209d39SAndroid Build Coastguard Worker  * These case options are mutually exclusive.
858*0e209d39SAndroid Build Coastguard Worker  * Unrelated options bits are ignored.
859*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 4.2
860*0e209d39SAndroid Build Coastguard Worker  */
861*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2
862*0e209d39SAndroid Build Coastguard Worker uset_closeOver(USet* set, int32_t attributes);
863*0e209d39SAndroid Build Coastguard Worker 
864*0e209d39SAndroid Build Coastguard Worker /**
865*0e209d39SAndroid Build Coastguard Worker  * Remove all strings from this set.
866*0e209d39SAndroid Build Coastguard Worker  *
867*0e209d39SAndroid Build Coastguard Worker  * @param set the set
868*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 4.2
869*0e209d39SAndroid Build Coastguard Worker  */
870*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2
871*0e209d39SAndroid Build Coastguard Worker uset_removeAllStrings(USet* set);
872*0e209d39SAndroid Build Coastguard Worker 
873*0e209d39SAndroid Build Coastguard Worker /**
874*0e209d39SAndroid Build Coastguard Worker  * Returns true if the given USet contains no characters and no
875*0e209d39SAndroid Build Coastguard Worker  * strings.
876*0e209d39SAndroid Build Coastguard Worker  * @param set the set
877*0e209d39SAndroid Build Coastguard Worker  * @return true if set is empty
878*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 2.4
879*0e209d39SAndroid Build Coastguard Worker  */
880*0e209d39SAndroid Build Coastguard Worker U_CAPI UBool U_EXPORT2
881*0e209d39SAndroid Build Coastguard Worker uset_isEmpty(const USet* set);
882*0e209d39SAndroid Build Coastguard Worker 
883*0e209d39SAndroid Build Coastguard Worker /**
884*0e209d39SAndroid Build Coastguard Worker  * @param set the set
885*0e209d39SAndroid Build Coastguard Worker  * @return true if this set contains multi-character strings or the empty string.
886*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 70
887*0e209d39SAndroid Build Coastguard Worker  */
888*0e209d39SAndroid Build Coastguard Worker U_CAPI UBool U_EXPORT2
889*0e209d39SAndroid Build Coastguard Worker uset_hasStrings(const USet *set);
890*0e209d39SAndroid Build Coastguard Worker 
891*0e209d39SAndroid Build Coastguard Worker /**
892*0e209d39SAndroid Build Coastguard Worker  * Returns true if the given USet contains the given character.
893*0e209d39SAndroid Build Coastguard Worker  * This function works faster with a frozen set.
894*0e209d39SAndroid Build Coastguard Worker  * @param set the set
895*0e209d39SAndroid Build Coastguard Worker  * @param c The codepoint to check for within the set
896*0e209d39SAndroid Build Coastguard Worker  * @return true if set contains c
897*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 2.4
898*0e209d39SAndroid Build Coastguard Worker  */
899*0e209d39SAndroid Build Coastguard Worker U_CAPI UBool U_EXPORT2
900*0e209d39SAndroid Build Coastguard Worker uset_contains(const USet* set, UChar32 c);
901*0e209d39SAndroid Build Coastguard Worker 
902*0e209d39SAndroid Build Coastguard Worker /**
903*0e209d39SAndroid Build Coastguard Worker  * Returns true if the given USet contains all characters c
904*0e209d39SAndroid Build Coastguard Worker  * where start <= c && c <= end.
905*0e209d39SAndroid Build Coastguard Worker  * @param set the set
906*0e209d39SAndroid Build Coastguard Worker  * @param start the first character of the range to test, inclusive
907*0e209d39SAndroid Build Coastguard Worker  * @param end the last character of the range to test, inclusive
908*0e209d39SAndroid Build Coastguard Worker  * @return true if set contains the range
909*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 2.2
910*0e209d39SAndroid Build Coastguard Worker  */
911*0e209d39SAndroid Build Coastguard Worker U_CAPI UBool U_EXPORT2
912*0e209d39SAndroid Build Coastguard Worker uset_containsRange(const USet* set, UChar32 start, UChar32 end);
913*0e209d39SAndroid Build Coastguard Worker 
914*0e209d39SAndroid Build Coastguard Worker /**
915*0e209d39SAndroid Build Coastguard Worker  * Returns true if the given USet contains the given string.
916*0e209d39SAndroid Build Coastguard Worker  * @param set the set
917*0e209d39SAndroid Build Coastguard Worker  * @param str the string
918*0e209d39SAndroid Build Coastguard Worker  * @param strLen the length of the string or -1 if null terminated.
919*0e209d39SAndroid Build Coastguard Worker  * @return true if set contains str
920*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 2.4
921*0e209d39SAndroid Build Coastguard Worker  */
922*0e209d39SAndroid Build Coastguard Worker U_CAPI UBool U_EXPORT2
923*0e209d39SAndroid Build Coastguard Worker uset_containsString(const USet* set, const UChar* str, int32_t strLen);
924*0e209d39SAndroid Build Coastguard Worker 
925*0e209d39SAndroid Build Coastguard Worker /**
926*0e209d39SAndroid Build Coastguard Worker  * Returns the index of the given character within this set, where
927*0e209d39SAndroid Build Coastguard Worker  * the set is ordered by ascending code point.  If the character
928*0e209d39SAndroid Build Coastguard Worker  * is not in this set, return -1.  The inverse of this method is
929*0e209d39SAndroid Build Coastguard Worker  * <code>charAt()</code>.
930*0e209d39SAndroid Build Coastguard Worker  * @param set the set
931*0e209d39SAndroid Build Coastguard Worker  * @param c the character to obtain the index for
932*0e209d39SAndroid Build Coastguard Worker  * @return an index from 0..size()-1, or -1
933*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 3.2
934*0e209d39SAndroid Build Coastguard Worker  */
935*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2
936*0e209d39SAndroid Build Coastguard Worker uset_indexOf(const USet* set, UChar32 c);
937*0e209d39SAndroid Build Coastguard Worker 
938*0e209d39SAndroid Build Coastguard Worker /**
939*0e209d39SAndroid Build Coastguard Worker  * Returns the character at the given index within this set, where
940*0e209d39SAndroid Build Coastguard Worker  * the set is ordered by ascending code point.  If the index is
941*0e209d39SAndroid Build Coastguard Worker  * out of range for characters, returns (UChar32)-1.
942*0e209d39SAndroid Build Coastguard Worker  * The inverse of this method is <code>indexOf()</code>.
943*0e209d39SAndroid Build Coastguard Worker  *
944*0e209d39SAndroid Build Coastguard Worker  * For iteration, this is slower than uset_getRangeCount()/uset_getItemCount()
945*0e209d39SAndroid Build Coastguard Worker  * with uset_getItem(), because for each call it skips linearly over <code>index</code>
946*0e209d39SAndroid Build Coastguard Worker  * characters in the ranges.
947*0e209d39SAndroid Build Coastguard Worker  *
948*0e209d39SAndroid Build Coastguard Worker  * @param set the set
949*0e209d39SAndroid Build Coastguard Worker  * @param charIndex an index from 0..size()-1 to obtain the char for
950*0e209d39SAndroid Build Coastguard Worker  * @return the character at the given index, or (UChar32)-1.
951*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 3.2
952*0e209d39SAndroid Build Coastguard Worker  */
953*0e209d39SAndroid Build Coastguard Worker U_CAPI UChar32 U_EXPORT2
954*0e209d39SAndroid Build Coastguard Worker uset_charAt(const USet* set, int32_t charIndex);
955*0e209d39SAndroid Build Coastguard Worker 
956*0e209d39SAndroid Build Coastguard Worker /**
957*0e209d39SAndroid Build Coastguard Worker  * Returns the number of characters and strings contained in this set.
958*0e209d39SAndroid Build Coastguard Worker  * The last (uset_getItemCount() - uset_getRangeCount()) items are strings.
959*0e209d39SAndroid Build Coastguard Worker  *
960*0e209d39SAndroid Build Coastguard Worker  * This is slower than uset_getRangeCount() and uset_getItemCount() because
961*0e209d39SAndroid Build Coastguard Worker  * it counts the code points of all ranges.
962*0e209d39SAndroid Build Coastguard Worker  *
963*0e209d39SAndroid Build Coastguard Worker  * @param set the set
964*0e209d39SAndroid Build Coastguard Worker  * @return a non-negative integer counting the characters and strings
965*0e209d39SAndroid Build Coastguard Worker  * contained in set
966*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 2.4
967*0e209d39SAndroid Build Coastguard Worker  * @see uset_getRangeCount
968*0e209d39SAndroid Build Coastguard Worker  */
969*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2
970*0e209d39SAndroid Build Coastguard Worker uset_size(const USet* set);
971*0e209d39SAndroid Build Coastguard Worker 
972*0e209d39SAndroid Build Coastguard Worker /**
973*0e209d39SAndroid Build Coastguard Worker  * @param set the set
974*0e209d39SAndroid Build Coastguard Worker  * @return the number of ranges in this set.
975*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 70
976*0e209d39SAndroid Build Coastguard Worker  * @see uset_getItemCount
977*0e209d39SAndroid Build Coastguard Worker  * @see uset_getItem
978*0e209d39SAndroid Build Coastguard Worker  * @see uset_size
979*0e209d39SAndroid Build Coastguard Worker  */
980*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2
981*0e209d39SAndroid Build Coastguard Worker uset_getRangeCount(const USet *set);
982*0e209d39SAndroid Build Coastguard Worker 
983*0e209d39SAndroid Build Coastguard Worker /**
984*0e209d39SAndroid Build Coastguard Worker  * Returns the number of items in this set.  An item is either a range
985*0e209d39SAndroid Build Coastguard Worker  * of characters or a single multicharacter string.
986*0e209d39SAndroid Build Coastguard Worker  * @param set the set
987*0e209d39SAndroid Build Coastguard Worker  * @return a non-negative integer counting the character ranges
988*0e209d39SAndroid Build Coastguard Worker  * and/or strings contained in set
989*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 2.4
990*0e209d39SAndroid Build Coastguard Worker  */
991*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2
992*0e209d39SAndroid Build Coastguard Worker uset_getItemCount(const USet* set);
993*0e209d39SAndroid Build Coastguard Worker 
994*0e209d39SAndroid Build Coastguard Worker /**
995*0e209d39SAndroid Build Coastguard Worker  * Returns an item of this set.  An item is either a range of
996*0e209d39SAndroid Build Coastguard Worker  * characters or a single multicharacter string (which can be the empty string).
997*0e209d39SAndroid Build Coastguard Worker  *
998*0e209d39SAndroid Build Coastguard Worker  * If <code>itemIndex</code> is less than uset_getRangeCount(), then this function returns 0,
999*0e209d39SAndroid Build Coastguard Worker  * and the range is <code>*start</code>..<code>*end</code>.
1000*0e209d39SAndroid Build Coastguard Worker  *
1001*0e209d39SAndroid Build Coastguard Worker  * If <code>itemIndex</code> is at least uset_getRangeCount() and less than uset_getItemCount(), then
1002*0e209d39SAndroid Build Coastguard Worker  * this function copies the string into <code>str[strCapacity]</code> and
1003*0e209d39SAndroid Build Coastguard Worker  * returns the length of the string (0 for the empty string).
1004*0e209d39SAndroid Build Coastguard Worker  *
1005*0e209d39SAndroid Build Coastguard Worker  * If <code>itemIndex</code> is out of range, then this function returns -1.
1006*0e209d39SAndroid Build Coastguard Worker  *
1007*0e209d39SAndroid Build Coastguard Worker  * Note that 0 is returned for each range as well as for the empty string.
1008*0e209d39SAndroid Build Coastguard Worker  *
1009*0e209d39SAndroid Build Coastguard Worker  * @param set the set
1010*0e209d39SAndroid Build Coastguard Worker  * @param itemIndex a non-negative integer in the range 0..uset_getItemCount(set)-1
1011*0e209d39SAndroid Build Coastguard Worker  * @param start pointer to variable to receive first character in range, inclusive;
1012*0e209d39SAndroid Build Coastguard Worker  *              can be NULL for a string item
1013*0e209d39SAndroid Build Coastguard Worker  * @param end pointer to variable to receive last character in range, inclusive;
1014*0e209d39SAndroid Build Coastguard Worker  *            can be NULL for a string item
1015*0e209d39SAndroid Build Coastguard Worker  * @param str buffer to receive the string, may be NULL
1016*0e209d39SAndroid Build Coastguard Worker  * @param strCapacity capacity of str, or 0 if str is NULL
1017*0e209d39SAndroid Build Coastguard Worker  * @param ec error code; U_INDEX_OUTOFBOUNDS_ERROR if the itemIndex is out of range
1018*0e209d39SAndroid Build Coastguard Worker  * @return the length of the string (0 or >= 2), or 0 if the item is a range,
1019*0e209d39SAndroid Build Coastguard Worker  *         or -1 if the itemIndex is out of range
1020*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 2.4
1021*0e209d39SAndroid Build Coastguard Worker  */
1022*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2
1023*0e209d39SAndroid Build Coastguard Worker uset_getItem(const USet* set, int32_t itemIndex,
1024*0e209d39SAndroid Build Coastguard Worker              UChar32* start, UChar32* end,
1025*0e209d39SAndroid Build Coastguard Worker              UChar* str, int32_t strCapacity,
1026*0e209d39SAndroid Build Coastguard Worker              UErrorCode* ec);
1027*0e209d39SAndroid Build Coastguard Worker 
1028*0e209d39SAndroid Build Coastguard Worker /**
1029*0e209d39SAndroid Build Coastguard Worker  * Returns true if set1 contains all the characters and strings
1030*0e209d39SAndroid Build Coastguard Worker  * of set2. It answers the question, 'Is set1 a superset of set2?'
1031*0e209d39SAndroid Build Coastguard Worker  * @param set1 set to be checked for containment
1032*0e209d39SAndroid Build Coastguard Worker  * @param set2 set to be checked for containment
1033*0e209d39SAndroid Build Coastguard Worker  * @return true if the test condition is met
1034*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 3.2
1035*0e209d39SAndroid Build Coastguard Worker  */
1036*0e209d39SAndroid Build Coastguard Worker U_CAPI UBool U_EXPORT2
1037*0e209d39SAndroid Build Coastguard Worker uset_containsAll(const USet* set1, const USet* set2);
1038*0e209d39SAndroid Build Coastguard Worker 
1039*0e209d39SAndroid Build Coastguard Worker /**
1040*0e209d39SAndroid Build Coastguard Worker  * Returns true if this set contains all the characters
1041*0e209d39SAndroid Build Coastguard Worker  * of the given string. This is does not check containment of grapheme
1042*0e209d39SAndroid Build Coastguard Worker  * clusters, like uset_containsString.
1043*0e209d39SAndroid Build Coastguard Worker  * @param set set of characters to be checked for containment
1044*0e209d39SAndroid Build Coastguard Worker  * @param str string containing codepoints to be checked for containment
1045*0e209d39SAndroid Build Coastguard Worker  * @param strLen the length of the string or -1 if null terminated.
1046*0e209d39SAndroid Build Coastguard Worker  * @return true if the test condition is met
1047*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 3.4
1048*0e209d39SAndroid Build Coastguard Worker  */
1049*0e209d39SAndroid Build Coastguard Worker U_CAPI UBool U_EXPORT2
1050*0e209d39SAndroid Build Coastguard Worker uset_containsAllCodePoints(const USet* set, const UChar *str, int32_t strLen);
1051*0e209d39SAndroid Build Coastguard Worker 
1052*0e209d39SAndroid Build Coastguard Worker /**
1053*0e209d39SAndroid Build Coastguard Worker  * Returns true if set1 contains none of the characters and strings
1054*0e209d39SAndroid Build Coastguard Worker  * of set2. It answers the question, 'Is set1 a disjoint set of set2?'
1055*0e209d39SAndroid Build Coastguard Worker  * @param set1 set to be checked for containment
1056*0e209d39SAndroid Build Coastguard Worker  * @param set2 set to be checked for containment
1057*0e209d39SAndroid Build Coastguard Worker  * @return true if the test condition is met
1058*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 3.2
1059*0e209d39SAndroid Build Coastguard Worker  */
1060*0e209d39SAndroid Build Coastguard Worker U_CAPI UBool U_EXPORT2
1061*0e209d39SAndroid Build Coastguard Worker uset_containsNone(const USet* set1, const USet* set2);
1062*0e209d39SAndroid Build Coastguard Worker 
1063*0e209d39SAndroid Build Coastguard Worker /**
1064*0e209d39SAndroid Build Coastguard Worker  * Returns true if set1 contains some of the characters and strings
1065*0e209d39SAndroid Build Coastguard Worker  * of set2. It answers the question, 'Does set1 and set2 have an intersection?'
1066*0e209d39SAndroid Build Coastguard Worker  * @param set1 set to be checked for containment
1067*0e209d39SAndroid Build Coastguard Worker  * @param set2 set to be checked for containment
1068*0e209d39SAndroid Build Coastguard Worker  * @return true if the test condition is met
1069*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 3.2
1070*0e209d39SAndroid Build Coastguard Worker  */
1071*0e209d39SAndroid Build Coastguard Worker U_CAPI UBool U_EXPORT2
1072*0e209d39SAndroid Build Coastguard Worker uset_containsSome(const USet* set1, const USet* set2);
1073*0e209d39SAndroid Build Coastguard Worker 
1074*0e209d39SAndroid Build Coastguard Worker /**
1075*0e209d39SAndroid Build Coastguard Worker  * Returns the length of the initial substring of the input string which
1076*0e209d39SAndroid Build Coastguard Worker  * consists only of characters and strings that are contained in this set
1077*0e209d39SAndroid Build Coastguard Worker  * (USET_SPAN_CONTAINED, USET_SPAN_SIMPLE),
1078*0e209d39SAndroid Build Coastguard Worker  * or only of characters and strings that are not contained
1079*0e209d39SAndroid Build Coastguard Worker  * in this set (USET_SPAN_NOT_CONTAINED).
1080*0e209d39SAndroid Build Coastguard Worker  * See USetSpanCondition for details.
1081*0e209d39SAndroid Build Coastguard Worker  * Similar to the strspn() C library function.
1082*0e209d39SAndroid Build Coastguard Worker  * Unpaired surrogates are treated according to contains() of their surrogate code points.
1083*0e209d39SAndroid Build Coastguard Worker  * This function works faster with a frozen set and with a non-negative string length argument.
1084*0e209d39SAndroid Build Coastguard Worker  * @param set the set
1085*0e209d39SAndroid Build Coastguard Worker  * @param s start of the string
1086*0e209d39SAndroid Build Coastguard Worker  * @param length of the string; can be -1 for NUL-terminated
1087*0e209d39SAndroid Build Coastguard Worker  * @param spanCondition specifies the containment condition
1088*0e209d39SAndroid Build Coastguard Worker  * @return the length of the initial substring according to the spanCondition;
1089*0e209d39SAndroid Build Coastguard Worker  *         0 if the start of the string does not fit the spanCondition
1090*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 3.8
1091*0e209d39SAndroid Build Coastguard Worker  * @see USetSpanCondition
1092*0e209d39SAndroid Build Coastguard Worker  */
1093*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2
1094*0e209d39SAndroid Build Coastguard Worker uset_span(const USet *set, const UChar *s, int32_t length, USetSpanCondition spanCondition);
1095*0e209d39SAndroid Build Coastguard Worker 
1096*0e209d39SAndroid Build Coastguard Worker /**
1097*0e209d39SAndroid Build Coastguard Worker  * Returns the start of the trailing substring of the input string which
1098*0e209d39SAndroid Build Coastguard Worker  * consists only of characters and strings that are contained in this set
1099*0e209d39SAndroid Build Coastguard Worker  * (USET_SPAN_CONTAINED, USET_SPAN_SIMPLE),
1100*0e209d39SAndroid Build Coastguard Worker  * or only of characters and strings that are not contained
1101*0e209d39SAndroid Build Coastguard Worker  * in this set (USET_SPAN_NOT_CONTAINED).
1102*0e209d39SAndroid Build Coastguard Worker  * See USetSpanCondition for details.
1103*0e209d39SAndroid Build Coastguard Worker  * Unpaired surrogates are treated according to contains() of their surrogate code points.
1104*0e209d39SAndroid Build Coastguard Worker  * This function works faster with a frozen set and with a non-negative string length argument.
1105*0e209d39SAndroid Build Coastguard Worker  * @param set the set
1106*0e209d39SAndroid Build Coastguard Worker  * @param s start of the string
1107*0e209d39SAndroid Build Coastguard Worker  * @param length of the string; can be -1 for NUL-terminated
1108*0e209d39SAndroid Build Coastguard Worker  * @param spanCondition specifies the containment condition
1109*0e209d39SAndroid Build Coastguard Worker  * @return the start of the trailing substring according to the spanCondition;
1110*0e209d39SAndroid Build Coastguard Worker  *         the string length if the end of the string does not fit the spanCondition
1111*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 3.8
1112*0e209d39SAndroid Build Coastguard Worker  * @see USetSpanCondition
1113*0e209d39SAndroid Build Coastguard Worker  */
1114*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2
1115*0e209d39SAndroid Build Coastguard Worker uset_spanBack(const USet *set, const UChar *s, int32_t length, USetSpanCondition spanCondition);
1116*0e209d39SAndroid Build Coastguard Worker 
1117*0e209d39SAndroid Build Coastguard Worker /**
1118*0e209d39SAndroid Build Coastguard Worker  * Returns the length of the initial substring of the input string which
1119*0e209d39SAndroid Build Coastguard Worker  * consists only of characters and strings that are contained in this set
1120*0e209d39SAndroid Build Coastguard Worker  * (USET_SPAN_CONTAINED, USET_SPAN_SIMPLE),
1121*0e209d39SAndroid Build Coastguard Worker  * or only of characters and strings that are not contained
1122*0e209d39SAndroid Build Coastguard Worker  * in this set (USET_SPAN_NOT_CONTAINED).
1123*0e209d39SAndroid Build Coastguard Worker  * See USetSpanCondition for details.
1124*0e209d39SAndroid Build Coastguard Worker  * Similar to the strspn() C library function.
1125*0e209d39SAndroid Build Coastguard Worker  * Malformed byte sequences are treated according to contains(0xfffd).
1126*0e209d39SAndroid Build Coastguard Worker  * This function works faster with a frozen set and with a non-negative string length argument.
1127*0e209d39SAndroid Build Coastguard Worker  * @param set the set
1128*0e209d39SAndroid Build Coastguard Worker  * @param s start of the string (UTF-8)
1129*0e209d39SAndroid Build Coastguard Worker  * @param length of the string; can be -1 for NUL-terminated
1130*0e209d39SAndroid Build Coastguard Worker  * @param spanCondition specifies the containment condition
1131*0e209d39SAndroid Build Coastguard Worker  * @return the length of the initial substring according to the spanCondition;
1132*0e209d39SAndroid Build Coastguard Worker  *         0 if the start of the string does not fit the spanCondition
1133*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 3.8
1134*0e209d39SAndroid Build Coastguard Worker  * @see USetSpanCondition
1135*0e209d39SAndroid Build Coastguard Worker  */
1136*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2
1137*0e209d39SAndroid Build Coastguard Worker uset_spanUTF8(const USet *set, const char *s, int32_t length, USetSpanCondition spanCondition);
1138*0e209d39SAndroid Build Coastguard Worker 
1139*0e209d39SAndroid Build Coastguard Worker /**
1140*0e209d39SAndroid Build Coastguard Worker  * Returns the start of the trailing substring of the input string which
1141*0e209d39SAndroid Build Coastguard Worker  * consists only of characters and strings that are contained in this set
1142*0e209d39SAndroid Build Coastguard Worker  * (USET_SPAN_CONTAINED, USET_SPAN_SIMPLE),
1143*0e209d39SAndroid Build Coastguard Worker  * or only of characters and strings that are not contained
1144*0e209d39SAndroid Build Coastguard Worker  * in this set (USET_SPAN_NOT_CONTAINED).
1145*0e209d39SAndroid Build Coastguard Worker  * See USetSpanCondition for details.
1146*0e209d39SAndroid Build Coastguard Worker  * Malformed byte sequences are treated according to contains(0xfffd).
1147*0e209d39SAndroid Build Coastguard Worker  * This function works faster with a frozen set and with a non-negative string length argument.
1148*0e209d39SAndroid Build Coastguard Worker  * @param set the set
1149*0e209d39SAndroid Build Coastguard Worker  * @param s start of the string (UTF-8)
1150*0e209d39SAndroid Build Coastguard Worker  * @param length of the string; can be -1 for NUL-terminated
1151*0e209d39SAndroid Build Coastguard Worker  * @param spanCondition specifies the containment condition
1152*0e209d39SAndroid Build Coastguard Worker  * @return the start of the trailing substring according to the spanCondition;
1153*0e209d39SAndroid Build Coastguard Worker  *         the string length if the end of the string does not fit the spanCondition
1154*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 3.8
1155*0e209d39SAndroid Build Coastguard Worker  * @see USetSpanCondition
1156*0e209d39SAndroid Build Coastguard Worker  */
1157*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2
1158*0e209d39SAndroid Build Coastguard Worker uset_spanBackUTF8(const USet *set, const char *s, int32_t length, USetSpanCondition spanCondition);
1159*0e209d39SAndroid Build Coastguard Worker 
1160*0e209d39SAndroid Build Coastguard Worker /**
1161*0e209d39SAndroid Build Coastguard Worker  * Returns true if set1 contains all of the characters and strings
1162*0e209d39SAndroid Build Coastguard Worker  * of set2, and vis versa. It answers the question, 'Is set1 equal to set2?'
1163*0e209d39SAndroid Build Coastguard Worker  * @param set1 set to be checked for containment
1164*0e209d39SAndroid Build Coastguard Worker  * @param set2 set to be checked for containment
1165*0e209d39SAndroid Build Coastguard Worker  * @return true if the test condition is met
1166*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 3.2
1167*0e209d39SAndroid Build Coastguard Worker  */
1168*0e209d39SAndroid Build Coastguard Worker U_CAPI UBool U_EXPORT2
1169*0e209d39SAndroid Build Coastguard Worker uset_equals(const USet* set1, const USet* set2);
1170*0e209d39SAndroid Build Coastguard Worker 
1171*0e209d39SAndroid Build Coastguard Worker /*********************************************************************
1172*0e209d39SAndroid Build Coastguard Worker  * Serialized set API
1173*0e209d39SAndroid Build Coastguard Worker  *********************************************************************/
1174*0e209d39SAndroid Build Coastguard Worker 
1175*0e209d39SAndroid Build Coastguard Worker /**
1176*0e209d39SAndroid Build Coastguard Worker  * Serializes this set into an array of 16-bit integers.  Serialization
1177*0e209d39SAndroid Build Coastguard Worker  * (currently) only records the characters in the set; multicharacter
1178*0e209d39SAndroid Build Coastguard Worker  * strings are ignored.
1179*0e209d39SAndroid Build Coastguard Worker  *
1180*0e209d39SAndroid Build Coastguard Worker  * The array
1181*0e209d39SAndroid Build Coastguard Worker  * has following format (each line is one 16-bit integer):
1182*0e209d39SAndroid Build Coastguard Worker  *
1183*0e209d39SAndroid Build Coastguard Worker  *  length     = (n+2*m) | (m!=0?0x8000:0)
1184*0e209d39SAndroid Build Coastguard Worker  *  bmpLength  = n; present if m!=0
1185*0e209d39SAndroid Build Coastguard Worker  *  bmp[0]
1186*0e209d39SAndroid Build Coastguard Worker  *  bmp[1]
1187*0e209d39SAndroid Build Coastguard Worker  *  ...
1188*0e209d39SAndroid Build Coastguard Worker  *  bmp[n-1]
1189*0e209d39SAndroid Build Coastguard Worker  *  supp-high[0]
1190*0e209d39SAndroid Build Coastguard Worker  *  supp-low[0]
1191*0e209d39SAndroid Build Coastguard Worker  *  supp-high[1]
1192*0e209d39SAndroid Build Coastguard Worker  *  supp-low[1]
1193*0e209d39SAndroid Build Coastguard Worker  *  ...
1194*0e209d39SAndroid Build Coastguard Worker  *  supp-high[m-1]
1195*0e209d39SAndroid Build Coastguard Worker  *  supp-low[m-1]
1196*0e209d39SAndroid Build Coastguard Worker  *
1197*0e209d39SAndroid Build Coastguard Worker  * The array starts with a header.  After the header are n bmp
1198*0e209d39SAndroid Build Coastguard Worker  * code points, then m supplementary code points.  Either n or m
1199*0e209d39SAndroid Build Coastguard Worker  * or both may be zero.  n+2*m is always <= 0x7FFF.
1200*0e209d39SAndroid Build Coastguard Worker  *
1201*0e209d39SAndroid Build Coastguard Worker  * If there are no supplementary characters (if m==0) then the
1202*0e209d39SAndroid Build Coastguard Worker  * header is one 16-bit integer, 'length', with value n.
1203*0e209d39SAndroid Build Coastguard Worker  *
1204*0e209d39SAndroid Build Coastguard Worker  * If there are supplementary characters (if m!=0) then the header
1205*0e209d39SAndroid Build Coastguard Worker  * is two 16-bit integers.  The first, 'length', has value
1206*0e209d39SAndroid Build Coastguard Worker  * (n+2*m)|0x8000.  The second, 'bmpLength', has value n.
1207*0e209d39SAndroid Build Coastguard Worker  *
1208*0e209d39SAndroid Build Coastguard Worker  * After the header the code points are stored in ascending order.
1209*0e209d39SAndroid Build Coastguard Worker  * Supplementary code points are stored as most significant 16
1210*0e209d39SAndroid Build Coastguard Worker  * bits followed by least significant 16 bits.
1211*0e209d39SAndroid Build Coastguard Worker  *
1212*0e209d39SAndroid Build Coastguard Worker  * @param set the set
1213*0e209d39SAndroid Build Coastguard Worker  * @param dest pointer to buffer of destCapacity 16-bit integers.
1214*0e209d39SAndroid Build Coastguard Worker  * May be NULL only if destCapacity is zero.
1215*0e209d39SAndroid Build Coastguard Worker  * @param destCapacity size of dest, or zero.  Must not be negative.
1216*0e209d39SAndroid Build Coastguard Worker  * @param pErrorCode pointer to the error code.  Will be set to
1217*0e209d39SAndroid Build Coastguard Worker  * U_INDEX_OUTOFBOUNDS_ERROR if n+2*m > 0x7FFF.  Will be set to
1218*0e209d39SAndroid Build Coastguard Worker  * U_BUFFER_OVERFLOW_ERROR if n+2*m+(m!=0?2:1) > destCapacity.
1219*0e209d39SAndroid Build Coastguard Worker  * @return the total length of the serialized format, including
1220*0e209d39SAndroid Build Coastguard Worker  * the header, that is, n+2*m+(m!=0?2:1), or 0 on error other
1221*0e209d39SAndroid Build Coastguard Worker  * than U_BUFFER_OVERFLOW_ERROR.
1222*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 2.4
1223*0e209d39SAndroid Build Coastguard Worker  */
1224*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2
1225*0e209d39SAndroid Build Coastguard Worker uset_serialize(const USet* set, uint16_t* dest, int32_t destCapacity, UErrorCode* pErrorCode);
1226*0e209d39SAndroid Build Coastguard Worker 
1227*0e209d39SAndroid Build Coastguard Worker /**
1228*0e209d39SAndroid Build Coastguard Worker  * Given a serialized array, fill in the given serialized set object.
1229*0e209d39SAndroid Build Coastguard Worker  * @param fillSet pointer to result
1230*0e209d39SAndroid Build Coastguard Worker  * @param src pointer to start of array
1231*0e209d39SAndroid Build Coastguard Worker  * @param srcLength length of array
1232*0e209d39SAndroid Build Coastguard Worker  * @return true if the given array is valid, otherwise false
1233*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 2.4
1234*0e209d39SAndroid Build Coastguard Worker  */
1235*0e209d39SAndroid Build Coastguard Worker U_CAPI UBool U_EXPORT2
1236*0e209d39SAndroid Build Coastguard Worker uset_getSerializedSet(USerializedSet* fillSet, const uint16_t* src, int32_t srcLength);
1237*0e209d39SAndroid Build Coastguard Worker 
1238*0e209d39SAndroid Build Coastguard Worker /**
1239*0e209d39SAndroid Build Coastguard Worker  * Set the USerializedSet to contain the given character (and nothing
1240*0e209d39SAndroid Build Coastguard Worker  * else).
1241*0e209d39SAndroid Build Coastguard Worker  * @param fillSet pointer to result
1242*0e209d39SAndroid Build Coastguard Worker  * @param c The codepoint to set
1243*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 2.4
1244*0e209d39SAndroid Build Coastguard Worker  */
1245*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2
1246*0e209d39SAndroid Build Coastguard Worker uset_setSerializedToOne(USerializedSet* fillSet, UChar32 c);
1247*0e209d39SAndroid Build Coastguard Worker 
1248*0e209d39SAndroid Build Coastguard Worker /**
1249*0e209d39SAndroid Build Coastguard Worker  * Returns true if the given USerializedSet contains the given
1250*0e209d39SAndroid Build Coastguard Worker  * character.
1251*0e209d39SAndroid Build Coastguard Worker  * @param set the serialized set
1252*0e209d39SAndroid Build Coastguard Worker  * @param c The codepoint to check for within the set
1253*0e209d39SAndroid Build Coastguard Worker  * @return true if set contains c
1254*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 2.4
1255*0e209d39SAndroid Build Coastguard Worker  */
1256*0e209d39SAndroid Build Coastguard Worker U_CAPI UBool U_EXPORT2
1257*0e209d39SAndroid Build Coastguard Worker uset_serializedContains(const USerializedSet* set, UChar32 c);
1258*0e209d39SAndroid Build Coastguard Worker 
1259*0e209d39SAndroid Build Coastguard Worker /**
1260*0e209d39SAndroid Build Coastguard Worker  * Returns the number of disjoint ranges of characters contained in
1261*0e209d39SAndroid Build Coastguard Worker  * the given serialized set.  Ignores any strings contained in the
1262*0e209d39SAndroid Build Coastguard Worker  * set.
1263*0e209d39SAndroid Build Coastguard Worker  * @param set the serialized set
1264*0e209d39SAndroid Build Coastguard Worker  * @return a non-negative integer counting the character ranges
1265*0e209d39SAndroid Build Coastguard Worker  * contained in set
1266*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 2.4
1267*0e209d39SAndroid Build Coastguard Worker  */
1268*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2
1269*0e209d39SAndroid Build Coastguard Worker uset_getSerializedRangeCount(const USerializedSet* set);
1270*0e209d39SAndroid Build Coastguard Worker 
1271*0e209d39SAndroid Build Coastguard Worker /**
1272*0e209d39SAndroid Build Coastguard Worker  * Returns a range of characters contained in the given serialized
1273*0e209d39SAndroid Build Coastguard Worker  * set.
1274*0e209d39SAndroid Build Coastguard Worker  * @param set the serialized set
1275*0e209d39SAndroid Build Coastguard Worker  * @param rangeIndex a non-negative integer in the range 0..
1276*0e209d39SAndroid Build Coastguard Worker  * uset_getSerializedRangeCount(set)-1
1277*0e209d39SAndroid Build Coastguard Worker  * @param pStart pointer to variable to receive first character
1278*0e209d39SAndroid Build Coastguard Worker  * in range, inclusive
1279*0e209d39SAndroid Build Coastguard Worker  * @param pEnd pointer to variable to receive last character in range,
1280*0e209d39SAndroid Build Coastguard Worker  * inclusive
1281*0e209d39SAndroid Build Coastguard Worker  * @return true if rangeIndex is valid, otherwise false
1282*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 2.4
1283*0e209d39SAndroid Build Coastguard Worker  */
1284*0e209d39SAndroid Build Coastguard Worker U_CAPI UBool U_EXPORT2
1285*0e209d39SAndroid Build Coastguard Worker uset_getSerializedRange(const USerializedSet* set, int32_t rangeIndex,
1286*0e209d39SAndroid Build Coastguard Worker                         UChar32* pStart, UChar32* pEnd);
1287*0e209d39SAndroid Build Coastguard Worker 
1288*0e209d39SAndroid Build Coastguard Worker #endif
1289