jpayne@69
|
1 // © 2016 and later: Unicode, Inc. and others.
|
jpayne@69
|
2 // License & terms of use: http://www.unicode.org/copyright.html
|
jpayne@69
|
3 /*
|
jpayne@69
|
4 **********************************************************************
|
jpayne@69
|
5 * Copyright (C) 1998-2016, International Business Machines
|
jpayne@69
|
6 * Corporation and others. All Rights Reserved.
|
jpayne@69
|
7 **********************************************************************
|
jpayne@69
|
8 *
|
jpayne@69
|
9 * File unistr.h
|
jpayne@69
|
10 *
|
jpayne@69
|
11 * Modification History:
|
jpayne@69
|
12 *
|
jpayne@69
|
13 * Date Name Description
|
jpayne@69
|
14 * 09/25/98 stephen Creation.
|
jpayne@69
|
15 * 11/11/98 stephen Changed per 11/9 code review.
|
jpayne@69
|
16 * 04/20/99 stephen Overhauled per 4/16 code review.
|
jpayne@69
|
17 * 11/18/99 aliu Made to inherit from Replaceable. Added method
|
jpayne@69
|
18 * handleReplaceBetween(); other methods unchanged.
|
jpayne@69
|
19 * 06/25/01 grhoten Remove dependency on iostream.
|
jpayne@69
|
20 ******************************************************************************
|
jpayne@69
|
21 */
|
jpayne@69
|
22
|
jpayne@69
|
23 #ifndef UNISTR_H
|
jpayne@69
|
24 #define UNISTR_H
|
jpayne@69
|
25
|
jpayne@69
|
26 /**
|
jpayne@69
|
27 * \file
|
jpayne@69
|
28 * \brief C++ API: Unicode String
|
jpayne@69
|
29 */
|
jpayne@69
|
30
|
jpayne@69
|
31 #include "unicode/utypes.h"
|
jpayne@69
|
32
|
jpayne@69
|
33 #if U_SHOW_CPLUSPLUS_API
|
jpayne@69
|
34
|
jpayne@69
|
35 #include <cstddef>
|
jpayne@69
|
36 #include "unicode/char16ptr.h"
|
jpayne@69
|
37 #include "unicode/rep.h"
|
jpayne@69
|
38 #include "unicode/std_string.h"
|
jpayne@69
|
39 #include "unicode/stringpiece.h"
|
jpayne@69
|
40 #include "unicode/bytestream.h"
|
jpayne@69
|
41
|
jpayne@69
|
42 struct UConverter; // unicode/ucnv.h
|
jpayne@69
|
43
|
jpayne@69
|
44 #ifndef USTRING_H
|
jpayne@69
|
45 /**
|
jpayne@69
|
46 * \ingroup ustring_ustrlen
|
jpayne@69
|
47 */
|
jpayne@69
|
48 U_STABLE int32_t U_EXPORT2
|
jpayne@69
|
49 u_strlen(const UChar *s);
|
jpayne@69
|
50 #endif
|
jpayne@69
|
51
|
jpayne@69
|
52 U_NAMESPACE_BEGIN
|
jpayne@69
|
53
|
jpayne@69
|
54 #if !UCONFIG_NO_BREAK_ITERATION
|
jpayne@69
|
55 class BreakIterator; // unicode/brkiter.h
|
jpayne@69
|
56 #endif
|
jpayne@69
|
57 class Edits;
|
jpayne@69
|
58
|
jpayne@69
|
59 U_NAMESPACE_END
|
jpayne@69
|
60
|
jpayne@69
|
61 // Not #ifndef U_HIDE_INTERNAL_API because UnicodeString needs the UStringCaseMapper.
|
jpayne@69
|
62 /**
|
jpayne@69
|
63 * Internal string case mapping function type.
|
jpayne@69
|
64 * All error checking must be done.
|
jpayne@69
|
65 * src and dest must not overlap.
|
jpayne@69
|
66 * @internal
|
jpayne@69
|
67 */
|
jpayne@69
|
68 typedef int32_t U_CALLCONV
|
jpayne@69
|
69 UStringCaseMapper(int32_t caseLocale, uint32_t options,
|
jpayne@69
|
70 #if !UCONFIG_NO_BREAK_ITERATION
|
jpayne@69
|
71 icu::BreakIterator *iter,
|
jpayne@69
|
72 #endif
|
jpayne@69
|
73 char16_t *dest, int32_t destCapacity,
|
jpayne@69
|
74 const char16_t *src, int32_t srcLength,
|
jpayne@69
|
75 icu::Edits *edits,
|
jpayne@69
|
76 UErrorCode &errorCode);
|
jpayne@69
|
77
|
jpayne@69
|
78 U_NAMESPACE_BEGIN
|
jpayne@69
|
79
|
jpayne@69
|
80 class Locale; // unicode/locid.h
|
jpayne@69
|
81 class StringCharacterIterator;
|
jpayne@69
|
82 class UnicodeStringAppendable; // unicode/appendable.h
|
jpayne@69
|
83
|
jpayne@69
|
84 /* The <iostream> include has been moved to unicode/ustream.h */
|
jpayne@69
|
85
|
jpayne@69
|
86 /**
|
jpayne@69
|
87 * Constant to be used in the UnicodeString(char *, int32_t, EInvariant) constructor
|
jpayne@69
|
88 * which constructs a Unicode string from an invariant-character char * string.
|
jpayne@69
|
89 * About invariant characters see utypes.h.
|
jpayne@69
|
90 * This constructor has no runtime dependency on conversion code and is
|
jpayne@69
|
91 * therefore recommended over ones taking a charset name string
|
jpayne@69
|
92 * (where the empty string "" indicates invariant-character conversion).
|
jpayne@69
|
93 *
|
jpayne@69
|
94 * @stable ICU 3.2
|
jpayne@69
|
95 */
|
jpayne@69
|
96 #define US_INV icu::UnicodeString::kInvariant
|
jpayne@69
|
97
|
jpayne@69
|
98 /**
|
jpayne@69
|
99 * Unicode String literals in C++.
|
jpayne@69
|
100 *
|
jpayne@69
|
101 * Note: these macros are not recommended for new code.
|
jpayne@69
|
102 * Prior to the availability of C++11 and u"unicode string literals",
|
jpayne@69
|
103 * these macros were provided for portability and efficiency when
|
jpayne@69
|
104 * initializing UnicodeStrings from literals.
|
jpayne@69
|
105 *
|
jpayne@69
|
106 * They work only for strings that contain "invariant characters", i.e.,
|
jpayne@69
|
107 * only latin letters, digits, and some punctuation.
|
jpayne@69
|
108 * See utypes.h for details.
|
jpayne@69
|
109 *
|
jpayne@69
|
110 * The string parameter must be a C string literal.
|
jpayne@69
|
111 * The length of the string, not including the terminating
|
jpayne@69
|
112 * `NUL`, must be specified as a constant.
|
jpayne@69
|
113 * @stable ICU 2.0
|
jpayne@69
|
114 */
|
jpayne@69
|
115 #if !U_CHAR16_IS_TYPEDEF
|
jpayne@69
|
116 # define UNICODE_STRING(cs, _length) icu::UnicodeString(TRUE, u ## cs, _length)
|
jpayne@69
|
117 #else
|
jpayne@69
|
118 # define UNICODE_STRING(cs, _length) icu::UnicodeString(TRUE, (const char16_t*)u ## cs, _length)
|
jpayne@69
|
119 #endif
|
jpayne@69
|
120
|
jpayne@69
|
121 /**
|
jpayne@69
|
122 * Unicode String literals in C++.
|
jpayne@69
|
123 * Dependent on the platform properties, different UnicodeString
|
jpayne@69
|
124 * constructors should be used to create a UnicodeString object from
|
jpayne@69
|
125 * a string literal.
|
jpayne@69
|
126 * The macros are defined for improved performance.
|
jpayne@69
|
127 * They work only for strings that contain "invariant characters", i.e.,
|
jpayne@69
|
128 * only latin letters, digits, and some punctuation.
|
jpayne@69
|
129 * See utypes.h for details.
|
jpayne@69
|
130 *
|
jpayne@69
|
131 * The string parameter must be a C string literal.
|
jpayne@69
|
132 * @stable ICU 2.0
|
jpayne@69
|
133 */
|
jpayne@69
|
134 #define UNICODE_STRING_SIMPLE(cs) UNICODE_STRING(cs, -1)
|
jpayne@69
|
135
|
jpayne@69
|
136 /**
|
jpayne@69
|
137 * \def UNISTR_FROM_CHAR_EXPLICIT
|
jpayne@69
|
138 * This can be defined to be empty or "explicit".
|
jpayne@69
|
139 * If explicit, then the UnicodeString(char16_t) and UnicodeString(UChar32)
|
jpayne@69
|
140 * constructors are marked as explicit, preventing their inadvertent use.
|
jpayne@69
|
141 * @stable ICU 49
|
jpayne@69
|
142 */
|
jpayne@69
|
143 #ifndef UNISTR_FROM_CHAR_EXPLICIT
|
jpayne@69
|
144 # if defined(U_COMBINED_IMPLEMENTATION) || defined(U_COMMON_IMPLEMENTATION) || defined(U_I18N_IMPLEMENTATION) || defined(U_IO_IMPLEMENTATION)
|
jpayne@69
|
145 // Auto-"explicit" in ICU library code.
|
jpayne@69
|
146 # define UNISTR_FROM_CHAR_EXPLICIT explicit
|
jpayne@69
|
147 # else
|
jpayne@69
|
148 // Empty by default for source code compatibility.
|
jpayne@69
|
149 # define UNISTR_FROM_CHAR_EXPLICIT
|
jpayne@69
|
150 # endif
|
jpayne@69
|
151 #endif
|
jpayne@69
|
152
|
jpayne@69
|
153 /**
|
jpayne@69
|
154 * \def UNISTR_FROM_STRING_EXPLICIT
|
jpayne@69
|
155 * This can be defined to be empty or "explicit".
|
jpayne@69
|
156 * If explicit, then the UnicodeString(const char *) and UnicodeString(const char16_t *)
|
jpayne@69
|
157 * constructors are marked as explicit, preventing their inadvertent use.
|
jpayne@69
|
158 *
|
jpayne@69
|
159 * In particular, this helps prevent accidentally depending on ICU conversion code
|
jpayne@69
|
160 * by passing a string literal into an API with a const UnicodeString & parameter.
|
jpayne@69
|
161 * @stable ICU 49
|
jpayne@69
|
162 */
|
jpayne@69
|
163 #ifndef UNISTR_FROM_STRING_EXPLICIT
|
jpayne@69
|
164 # if defined(U_COMBINED_IMPLEMENTATION) || defined(U_COMMON_IMPLEMENTATION) || defined(U_I18N_IMPLEMENTATION) || defined(U_IO_IMPLEMENTATION)
|
jpayne@69
|
165 // Auto-"explicit" in ICU library code.
|
jpayne@69
|
166 # define UNISTR_FROM_STRING_EXPLICIT explicit
|
jpayne@69
|
167 # else
|
jpayne@69
|
168 // Empty by default for source code compatibility.
|
jpayne@69
|
169 # define UNISTR_FROM_STRING_EXPLICIT
|
jpayne@69
|
170 # endif
|
jpayne@69
|
171 #endif
|
jpayne@69
|
172
|
jpayne@69
|
173 /**
|
jpayne@69
|
174 * \def UNISTR_OBJECT_SIZE
|
jpayne@69
|
175 * Desired sizeof(UnicodeString) in bytes.
|
jpayne@69
|
176 * It should be a multiple of sizeof(pointer) to avoid unusable space for padding.
|
jpayne@69
|
177 * The object size may want to be a multiple of 16 bytes,
|
jpayne@69
|
178 * which is a common granularity for heap allocation.
|
jpayne@69
|
179 *
|
jpayne@69
|
180 * Any space inside the object beyond sizeof(vtable pointer) + 2
|
jpayne@69
|
181 * is available for storing short strings inside the object.
|
jpayne@69
|
182 * The bigger the object, the longer a string that can be stored inside the object,
|
jpayne@69
|
183 * without additional heap allocation.
|
jpayne@69
|
184 *
|
jpayne@69
|
185 * Depending on a platform's pointer size, pointer alignment requirements,
|
jpayne@69
|
186 * and struct padding, the compiler will usually round up sizeof(UnicodeString)
|
jpayne@69
|
187 * to 4 * sizeof(pointer) (or 3 * sizeof(pointer) for P128 data models),
|
jpayne@69
|
188 * to hold the fields for heap-allocated strings.
|
jpayne@69
|
189 * Such a minimum size also ensures that the object is easily large enough
|
jpayne@69
|
190 * to hold at least 2 char16_ts, for one supplementary code point (U16_MAX_LENGTH).
|
jpayne@69
|
191 *
|
jpayne@69
|
192 * sizeof(UnicodeString) >= 48 should work for all known platforms.
|
jpayne@69
|
193 *
|
jpayne@69
|
194 * For example, on a 64-bit machine where sizeof(vtable pointer) is 8,
|
jpayne@69
|
195 * sizeof(UnicodeString) = 64 would leave space for
|
jpayne@69
|
196 * (64 - sizeof(vtable pointer) - 2) / U_SIZEOF_UCHAR = (64 - 8 - 2) / 2 = 27
|
jpayne@69
|
197 * char16_ts stored inside the object.
|
jpayne@69
|
198 *
|
jpayne@69
|
199 * The minimum object size on a 64-bit machine would be
|
jpayne@69
|
200 * 4 * sizeof(pointer) = 4 * 8 = 32 bytes,
|
jpayne@69
|
201 * and the internal buffer would hold up to 11 char16_ts in that case.
|
jpayne@69
|
202 *
|
jpayne@69
|
203 * @see U16_MAX_LENGTH
|
jpayne@69
|
204 * @stable ICU 56
|
jpayne@69
|
205 */
|
jpayne@69
|
206 #ifndef UNISTR_OBJECT_SIZE
|
jpayne@69
|
207 # define UNISTR_OBJECT_SIZE 64
|
jpayne@69
|
208 #endif
|
jpayne@69
|
209
|
jpayne@69
|
210 /**
|
jpayne@69
|
211 * UnicodeString is a string class that stores Unicode characters directly and provides
|
jpayne@69
|
212 * similar functionality as the Java String and StringBuffer/StringBuilder classes.
|
jpayne@69
|
213 * It is a concrete implementation of the abstract class Replaceable (for transliteration).
|
jpayne@69
|
214 *
|
jpayne@69
|
215 * The UnicodeString equivalent of std::string’s clear() is remove().
|
jpayne@69
|
216 *
|
jpayne@69
|
217 * A UnicodeString may "alias" an external array of characters
|
jpayne@69
|
218 * (that is, point to it, rather than own the array)
|
jpayne@69
|
219 * whose lifetime must then at least match the lifetime of the aliasing object.
|
jpayne@69
|
220 * This aliasing may be preserved when returning a UnicodeString by value,
|
jpayne@69
|
221 * depending on the compiler and the function implementation,
|
jpayne@69
|
222 * via Return Value Optimization (RVO) or the move assignment operator.
|
jpayne@69
|
223 * (However, the copy assignment operator does not preserve aliasing.)
|
jpayne@69
|
224 * For details see the description of storage models at the end of the class API docs
|
jpayne@69
|
225 * and in the User Guide chapter linked from there.
|
jpayne@69
|
226 *
|
jpayne@69
|
227 * The UnicodeString class is not suitable for subclassing.
|
jpayne@69
|
228 *
|
jpayne@69
|
229 * For an overview of Unicode strings in C and C++ see the
|
jpayne@69
|
230 * [User Guide Strings chapter](http://userguide.icu-project.org/strings#TOC-Strings-in-C-C-).
|
jpayne@69
|
231 *
|
jpayne@69
|
232 * In ICU, a Unicode string consists of 16-bit Unicode *code units*.
|
jpayne@69
|
233 * A Unicode character may be stored with either one code unit
|
jpayne@69
|
234 * (the most common case) or with a matched pair of special code units
|
jpayne@69
|
235 * ("surrogates"). The data type for code units is char16_t.
|
jpayne@69
|
236 * For single-character handling, a Unicode character code *point* is a value
|
jpayne@69
|
237 * in the range 0..0x10ffff. ICU uses the UChar32 type for code points.
|
jpayne@69
|
238 *
|
jpayne@69
|
239 * Indexes and offsets into and lengths of strings always count code units, not code points.
|
jpayne@69
|
240 * This is the same as with multi-byte char* strings in traditional string handling.
|
jpayne@69
|
241 * Operations on partial strings typically do not test for code point boundaries.
|
jpayne@69
|
242 * If necessary, the user needs to take care of such boundaries by testing for the code unit
|
jpayne@69
|
243 * values or by using functions like
|
jpayne@69
|
244 * UnicodeString::getChar32Start() and UnicodeString::getChar32Limit()
|
jpayne@69
|
245 * (or, in C, the equivalent macros U16_SET_CP_START() and U16_SET_CP_LIMIT(), see utf.h).
|
jpayne@69
|
246 *
|
jpayne@69
|
247 * UnicodeString methods are more lenient with regard to input parameter values
|
jpayne@69
|
248 * than other ICU APIs. In particular:
|
jpayne@69
|
249 * - If indexes are out of bounds for a UnicodeString object
|
jpayne@69
|
250 * (< 0 or > length()) then they are "pinned" to the nearest boundary.
|
jpayne@69
|
251 * - If the buffer passed to an insert/append/replace operation is owned by the
|
jpayne@69
|
252 * target object, e.g., calling str.append(str), an extra copy may take place
|
jpayne@69
|
253 * to ensure safety.
|
jpayne@69
|
254 * - If primitive string pointer values (e.g., const char16_t * or char *)
|
jpayne@69
|
255 * for input strings are NULL, then those input string parameters are treated
|
jpayne@69
|
256 * as if they pointed to an empty string.
|
jpayne@69
|
257 * However, this is *not* the case for char * parameters for charset names
|
jpayne@69
|
258 * or other IDs.
|
jpayne@69
|
259 * - Most UnicodeString methods do not take a UErrorCode parameter because
|
jpayne@69
|
260 * there are usually very few opportunities for failure other than a shortage
|
jpayne@69
|
261 * of memory, error codes in low-level C++ string methods would be inconvenient,
|
jpayne@69
|
262 * and the error code as the last parameter (ICU convention) would prevent
|
jpayne@69
|
263 * the use of default parameter values.
|
jpayne@69
|
264 * Instead, such methods set the UnicodeString into a "bogus" state
|
jpayne@69
|
265 * (see isBogus()) if an error occurs.
|
jpayne@69
|
266 *
|
jpayne@69
|
267 * In string comparisons, two UnicodeString objects that are both "bogus"
|
jpayne@69
|
268 * compare equal (to be transitive and prevent endless loops in sorting),
|
jpayne@69
|
269 * and a "bogus" string compares less than any non-"bogus" one.
|
jpayne@69
|
270 *
|
jpayne@69
|
271 * Const UnicodeString methods are thread-safe. Multiple threads can use
|
jpayne@69
|
272 * const methods on the same UnicodeString object simultaneously,
|
jpayne@69
|
273 * but non-const methods must not be called concurrently (in multiple threads)
|
jpayne@69
|
274 * with any other (const or non-const) methods.
|
jpayne@69
|
275 *
|
jpayne@69
|
276 * Similarly, const UnicodeString & parameters are thread-safe.
|
jpayne@69
|
277 * One object may be passed in as such a parameter concurrently in multiple threads.
|
jpayne@69
|
278 * This includes the const UnicodeString & parameters for
|
jpayne@69
|
279 * copy construction, assignment, and cloning.
|
jpayne@69
|
280 *
|
jpayne@69
|
281 * UnicodeString uses several storage methods.
|
jpayne@69
|
282 * String contents can be stored inside the UnicodeString object itself,
|
jpayne@69
|
283 * in an allocated and shared buffer, or in an outside buffer that is "aliased".
|
jpayne@69
|
284 * Most of this is done transparently, but careful aliasing in particular provides
|
jpayne@69
|
285 * significant performance improvements.
|
jpayne@69
|
286 * Also, the internal buffer is accessible via special functions.
|
jpayne@69
|
287 * For details see the
|
jpayne@69
|
288 * [User Guide Strings chapter](http://userguide.icu-project.org/strings#TOC-Maximizing-Performance-with-the-UnicodeString-Storage-Model).
|
jpayne@69
|
289 *
|
jpayne@69
|
290 * @see utf.h
|
jpayne@69
|
291 * @see CharacterIterator
|
jpayne@69
|
292 * @stable ICU 2.0
|
jpayne@69
|
293 */
|
jpayne@69
|
294 class U_COMMON_API UnicodeString : public Replaceable
|
jpayne@69
|
295 {
|
jpayne@69
|
296 public:
|
jpayne@69
|
297
|
jpayne@69
|
298 /**
|
jpayne@69
|
299 * Constant to be used in the UnicodeString(char *, int32_t, EInvariant) constructor
|
jpayne@69
|
300 * which constructs a Unicode string from an invariant-character char * string.
|
jpayne@69
|
301 * Use the macro US_INV instead of the full qualification for this value.
|
jpayne@69
|
302 *
|
jpayne@69
|
303 * @see US_INV
|
jpayne@69
|
304 * @stable ICU 3.2
|
jpayne@69
|
305 */
|
jpayne@69
|
306 enum EInvariant {
|
jpayne@69
|
307 /**
|
jpayne@69
|
308 * @see EInvariant
|
jpayne@69
|
309 * @stable ICU 3.2
|
jpayne@69
|
310 */
|
jpayne@69
|
311 kInvariant
|
jpayne@69
|
312 };
|
jpayne@69
|
313
|
jpayne@69
|
314 //========================================
|
jpayne@69
|
315 // Read-only operations
|
jpayne@69
|
316 //========================================
|
jpayne@69
|
317
|
jpayne@69
|
318 /* Comparison - bitwise only - for international comparison use collation */
|
jpayne@69
|
319
|
jpayne@69
|
320 /**
|
jpayne@69
|
321 * Equality operator. Performs only bitwise comparison.
|
jpayne@69
|
322 * @param text The UnicodeString to compare to this one.
|
jpayne@69
|
323 * @return TRUE if `text` contains the same characters as this one,
|
jpayne@69
|
324 * FALSE otherwise.
|
jpayne@69
|
325 * @stable ICU 2.0
|
jpayne@69
|
326 */
|
jpayne@69
|
327 inline UBool operator== (const UnicodeString& text) const;
|
jpayne@69
|
328
|
jpayne@69
|
329 /**
|
jpayne@69
|
330 * Inequality operator. Performs only bitwise comparison.
|
jpayne@69
|
331 * @param text The UnicodeString to compare to this one.
|
jpayne@69
|
332 * @return FALSE if `text` contains the same characters as this one,
|
jpayne@69
|
333 * TRUE otherwise.
|
jpayne@69
|
334 * @stable ICU 2.0
|
jpayne@69
|
335 */
|
jpayne@69
|
336 inline UBool operator!= (const UnicodeString& text) const;
|
jpayne@69
|
337
|
jpayne@69
|
338 /**
|
jpayne@69
|
339 * Greater than operator. Performs only bitwise comparison.
|
jpayne@69
|
340 * @param text The UnicodeString to compare to this one.
|
jpayne@69
|
341 * @return TRUE if the characters in this are bitwise
|
jpayne@69
|
342 * greater than the characters in `text`, FALSE otherwise
|
jpayne@69
|
343 * @stable ICU 2.0
|
jpayne@69
|
344 */
|
jpayne@69
|
345 inline UBool operator> (const UnicodeString& text) const;
|
jpayne@69
|
346
|
jpayne@69
|
347 /**
|
jpayne@69
|
348 * Less than operator. Performs only bitwise comparison.
|
jpayne@69
|
349 * @param text The UnicodeString to compare to this one.
|
jpayne@69
|
350 * @return TRUE if the characters in this are bitwise
|
jpayne@69
|
351 * less than the characters in `text`, FALSE otherwise
|
jpayne@69
|
352 * @stable ICU 2.0
|
jpayne@69
|
353 */
|
jpayne@69
|
354 inline UBool operator< (const UnicodeString& text) const;
|
jpayne@69
|
355
|
jpayne@69
|
356 /**
|
jpayne@69
|
357 * Greater than or equal operator. Performs only bitwise comparison.
|
jpayne@69
|
358 * @param text The UnicodeString to compare to this one.
|
jpayne@69
|
359 * @return TRUE if the characters in this are bitwise
|
jpayne@69
|
360 * greater than or equal to the characters in `text`, FALSE otherwise
|
jpayne@69
|
361 * @stable ICU 2.0
|
jpayne@69
|
362 */
|
jpayne@69
|
363 inline UBool operator>= (const UnicodeString& text) const;
|
jpayne@69
|
364
|
jpayne@69
|
365 /**
|
jpayne@69
|
366 * Less than or equal operator. Performs only bitwise comparison.
|
jpayne@69
|
367 * @param text The UnicodeString to compare to this one.
|
jpayne@69
|
368 * @return TRUE if the characters in this are bitwise
|
jpayne@69
|
369 * less than or equal to the characters in `text`, FALSE otherwise
|
jpayne@69
|
370 * @stable ICU 2.0
|
jpayne@69
|
371 */
|
jpayne@69
|
372 inline UBool operator<= (const UnicodeString& text) const;
|
jpayne@69
|
373
|
jpayne@69
|
374 /**
|
jpayne@69
|
375 * Compare the characters bitwise in this UnicodeString to
|
jpayne@69
|
376 * the characters in `text`.
|
jpayne@69
|
377 * @param text The UnicodeString to compare to this one.
|
jpayne@69
|
378 * @return The result of bitwise character comparison: 0 if this
|
jpayne@69
|
379 * contains the same characters as `text`, -1 if the characters in
|
jpayne@69
|
380 * this are bitwise less than the characters in `text`, +1 if the
|
jpayne@69
|
381 * characters in this are bitwise greater than the characters
|
jpayne@69
|
382 * in `text`.
|
jpayne@69
|
383 * @stable ICU 2.0
|
jpayne@69
|
384 */
|
jpayne@69
|
385 inline int8_t compare(const UnicodeString& text) const;
|
jpayne@69
|
386
|
jpayne@69
|
387 /**
|
jpayne@69
|
388 * Compare the characters bitwise in the range
|
jpayne@69
|
389 * [`start`, `start + length`) with the characters
|
jpayne@69
|
390 * in the **entire string** `text`.
|
jpayne@69
|
391 * (The parameters "start" and "length" are not applied to the other text "text".)
|
jpayne@69
|
392 * @param start the offset at which the compare operation begins
|
jpayne@69
|
393 * @param length the number of characters of text to compare.
|
jpayne@69
|
394 * @param text the other text to be compared against this string.
|
jpayne@69
|
395 * @return The result of bitwise character comparison: 0 if this
|
jpayne@69
|
396 * contains the same characters as `text`, -1 if the characters in
|
jpayne@69
|
397 * this are bitwise less than the characters in `text`, +1 if the
|
jpayne@69
|
398 * characters in this are bitwise greater than the characters
|
jpayne@69
|
399 * in `text`.
|
jpayne@69
|
400 * @stable ICU 2.0
|
jpayne@69
|
401 */
|
jpayne@69
|
402 inline int8_t compare(int32_t start,
|
jpayne@69
|
403 int32_t length,
|
jpayne@69
|
404 const UnicodeString& text) const;
|
jpayne@69
|
405
|
jpayne@69
|
406 /**
|
jpayne@69
|
407 * Compare the characters bitwise in the range
|
jpayne@69
|
408 * [`start`, `start + length`) with the characters
|
jpayne@69
|
409 * in `srcText` in the range
|
jpayne@69
|
410 * [`srcStart`, `srcStart + srcLength`).
|
jpayne@69
|
411 * @param start the offset at which the compare operation begins
|
jpayne@69
|
412 * @param length the number of characters in this to compare.
|
jpayne@69
|
413 * @param srcText the text to be compared
|
jpayne@69
|
414 * @param srcStart the offset into `srcText` to start comparison
|
jpayne@69
|
415 * @param srcLength the number of characters in `src` to compare
|
jpayne@69
|
416 * @return The result of bitwise character comparison: 0 if this
|
jpayne@69
|
417 * contains the same characters as `srcText`, -1 if the characters in
|
jpayne@69
|
418 * this are bitwise less than the characters in `srcText`, +1 if the
|
jpayne@69
|
419 * characters in this are bitwise greater than the characters
|
jpayne@69
|
420 * in `srcText`.
|
jpayne@69
|
421 * @stable ICU 2.0
|
jpayne@69
|
422 */
|
jpayne@69
|
423 inline int8_t compare(int32_t start,
|
jpayne@69
|
424 int32_t length,
|
jpayne@69
|
425 const UnicodeString& srcText,
|
jpayne@69
|
426 int32_t srcStart,
|
jpayne@69
|
427 int32_t srcLength) const;
|
jpayne@69
|
428
|
jpayne@69
|
429 /**
|
jpayne@69
|
430 * Compare the characters bitwise in this UnicodeString with the first
|
jpayne@69
|
431 * `srcLength` characters in `srcChars`.
|
jpayne@69
|
432 * @param srcChars The characters to compare to this UnicodeString.
|
jpayne@69
|
433 * @param srcLength the number of characters in `srcChars` to compare
|
jpayne@69
|
434 * @return The result of bitwise character comparison: 0 if this
|
jpayne@69
|
435 * contains the same characters as `srcChars`, -1 if the characters in
|
jpayne@69
|
436 * this are bitwise less than the characters in `srcChars`, +1 if the
|
jpayne@69
|
437 * characters in this are bitwise greater than the characters
|
jpayne@69
|
438 * in `srcChars`.
|
jpayne@69
|
439 * @stable ICU 2.0
|
jpayne@69
|
440 */
|
jpayne@69
|
441 inline int8_t compare(ConstChar16Ptr srcChars,
|
jpayne@69
|
442 int32_t srcLength) const;
|
jpayne@69
|
443
|
jpayne@69
|
444 /**
|
jpayne@69
|
445 * Compare the characters bitwise in the range
|
jpayne@69
|
446 * [`start`, `start + length`) with the first
|
jpayne@69
|
447 * `length` characters in `srcChars`
|
jpayne@69
|
448 * @param start the offset at which the compare operation begins
|
jpayne@69
|
449 * @param length the number of characters to compare.
|
jpayne@69
|
450 * @param srcChars the characters to be compared
|
jpayne@69
|
451 * @return The result of bitwise character comparison: 0 if this
|
jpayne@69
|
452 * contains the same characters as `srcChars`, -1 if the characters in
|
jpayne@69
|
453 * this are bitwise less than the characters in `srcChars`, +1 if the
|
jpayne@69
|
454 * characters in this are bitwise greater than the characters
|
jpayne@69
|
455 * in `srcChars`.
|
jpayne@69
|
456 * @stable ICU 2.0
|
jpayne@69
|
457 */
|
jpayne@69
|
458 inline int8_t compare(int32_t start,
|
jpayne@69
|
459 int32_t length,
|
jpayne@69
|
460 const char16_t *srcChars) const;
|
jpayne@69
|
461
|
jpayne@69
|
462 /**
|
jpayne@69
|
463 * Compare the characters bitwise in the range
|
jpayne@69
|
464 * [`start`, `start + length`) with the characters
|
jpayne@69
|
465 * in `srcChars` in the range
|
jpayne@69
|
466 * [`srcStart`, `srcStart + srcLength`).
|
jpayne@69
|
467 * @param start the offset at which the compare operation begins
|
jpayne@69
|
468 * @param length the number of characters in this to compare
|
jpayne@69
|
469 * @param srcChars the characters to be compared
|
jpayne@69
|
470 * @param srcStart the offset into `srcChars` to start comparison
|
jpayne@69
|
471 * @param srcLength the number of characters in `srcChars` to compare
|
jpayne@69
|
472 * @return The result of bitwise character comparison: 0 if this
|
jpayne@69
|
473 * contains the same characters as `srcChars`, -1 if the characters in
|
jpayne@69
|
474 * this are bitwise less than the characters in `srcChars`, +1 if the
|
jpayne@69
|
475 * characters in this are bitwise greater than the characters
|
jpayne@69
|
476 * in `srcChars`.
|
jpayne@69
|
477 * @stable ICU 2.0
|
jpayne@69
|
478 */
|
jpayne@69
|
479 inline int8_t compare(int32_t start,
|
jpayne@69
|
480 int32_t length,
|
jpayne@69
|
481 const char16_t *srcChars,
|
jpayne@69
|
482 int32_t srcStart,
|
jpayne@69
|
483 int32_t srcLength) const;
|
jpayne@69
|
484
|
jpayne@69
|
485 /**
|
jpayne@69
|
486 * Compare the characters bitwise in the range
|
jpayne@69
|
487 * [`start`, `limit`) with the characters
|
jpayne@69
|
488 * in `srcText` in the range
|
jpayne@69
|
489 * [`srcStart`, `srcLimit`).
|
jpayne@69
|
490 * @param start the offset at which the compare operation begins
|
jpayne@69
|
491 * @param limit the offset immediately following the compare operation
|
jpayne@69
|
492 * @param srcText the text to be compared
|
jpayne@69
|
493 * @param srcStart the offset into `srcText` to start comparison
|
jpayne@69
|
494 * @param srcLimit the offset into `srcText` to limit comparison
|
jpayne@69
|
495 * @return The result of bitwise character comparison: 0 if this
|
jpayne@69
|
496 * contains the same characters as `srcText`, -1 if the characters in
|
jpayne@69
|
497 * this are bitwise less than the characters in `srcText`, +1 if the
|
jpayne@69
|
498 * characters in this are bitwise greater than the characters
|
jpayne@69
|
499 * in `srcText`.
|
jpayne@69
|
500 * @stable ICU 2.0
|
jpayne@69
|
501 */
|
jpayne@69
|
502 inline int8_t compareBetween(int32_t start,
|
jpayne@69
|
503 int32_t limit,
|
jpayne@69
|
504 const UnicodeString& srcText,
|
jpayne@69
|
505 int32_t srcStart,
|
jpayne@69
|
506 int32_t srcLimit) const;
|
jpayne@69
|
507
|
jpayne@69
|
508 /**
|
jpayne@69
|
509 * Compare two Unicode strings in code point order.
|
jpayne@69
|
510 * The result may be different from the results of compare(), operator<, etc.
|
jpayne@69
|
511 * if supplementary characters are present:
|
jpayne@69
|
512 *
|
jpayne@69
|
513 * In UTF-16, supplementary characters (with code points U+10000 and above) are
|
jpayne@69
|
514 * stored with pairs of surrogate code units. These have values from 0xd800 to 0xdfff,
|
jpayne@69
|
515 * which means that they compare as less than some other BMP characters like U+feff.
|
jpayne@69
|
516 * This function compares Unicode strings in code point order.
|
jpayne@69
|
517 * If either of the UTF-16 strings is malformed (i.e., it contains unpaired surrogates), then the result is not defined.
|
jpayne@69
|
518 *
|
jpayne@69
|
519 * @param text Another string to compare this one to.
|
jpayne@69
|
520 * @return a negative/zero/positive integer corresponding to whether
|
jpayne@69
|
521 * this string is less than/equal to/greater than the second one
|
jpayne@69
|
522 * in code point order
|
jpayne@69
|
523 * @stable ICU 2.0
|
jpayne@69
|
524 */
|
jpayne@69
|
525 inline int8_t compareCodePointOrder(const UnicodeString& text) const;
|
jpayne@69
|
526
|
jpayne@69
|
527 /**
|
jpayne@69
|
528 * Compare two Unicode strings in code point order.
|
jpayne@69
|
529 * The result may be different from the results of compare(), operator<, etc.
|
jpayne@69
|
530 * if supplementary characters are present:
|
jpayne@69
|
531 *
|
jpayne@69
|
532 * In UTF-16, supplementary characters (with code points U+10000 and above) are
|
jpayne@69
|
533 * stored with pairs of surrogate code units. These have values from 0xd800 to 0xdfff,
|
jpayne@69
|
534 * which means that they compare as less than some other BMP characters like U+feff.
|
jpayne@69
|
535 * This function compares Unicode strings in code point order.
|
jpayne@69
|
536 * If either of the UTF-16 strings is malformed (i.e., it contains unpaired surrogates), then the result is not defined.
|
jpayne@69
|
537 *
|
jpayne@69
|
538 * @param start The start offset in this string at which the compare operation begins.
|
jpayne@69
|
539 * @param length The number of code units from this string to compare.
|
jpayne@69
|
540 * @param srcText Another string to compare this one to.
|
jpayne@69
|
541 * @return a negative/zero/positive integer corresponding to whether
|
jpayne@69
|
542 * this string is less than/equal to/greater than the second one
|
jpayne@69
|
543 * in code point order
|
jpayne@69
|
544 * @stable ICU 2.0
|
jpayne@69
|
545 */
|
jpayne@69
|
546 inline int8_t compareCodePointOrder(int32_t start,
|
jpayne@69
|
547 int32_t length,
|
jpayne@69
|
548 const UnicodeString& srcText) const;
|
jpayne@69
|
549
|
jpayne@69
|
550 /**
|
jpayne@69
|
551 * Compare two Unicode strings in code point order.
|
jpayne@69
|
552 * The result may be different from the results of compare(), operator<, etc.
|
jpayne@69
|
553 * if supplementary characters are present:
|
jpayne@69
|
554 *
|
jpayne@69
|
555 * In UTF-16, supplementary characters (with code points U+10000 and above) are
|
jpayne@69
|
556 * stored with pairs of surrogate code units. These have values from 0xd800 to 0xdfff,
|
jpayne@69
|
557 * which means that they compare as less than some other BMP characters like U+feff.
|
jpayne@69
|
558 * This function compares Unicode strings in code point order.
|
jpayne@69
|
559 * If either of the UTF-16 strings is malformed (i.e., it contains unpaired surrogates), then the result is not defined.
|
jpayne@69
|
560 *
|
jpayne@69
|
561 * @param start The start offset in this string at which the compare operation begins.
|
jpayne@69
|
562 * @param length The number of code units from this string to compare.
|
jpayne@69
|
563 * @param srcText Another string to compare this one to.
|
jpayne@69
|
564 * @param srcStart The start offset in that string at which the compare operation begins.
|
jpayne@69
|
565 * @param srcLength The number of code units from that string to compare.
|
jpayne@69
|
566 * @return a negative/zero/positive integer corresponding to whether
|
jpayne@69
|
567 * this string is less than/equal to/greater than the second one
|
jpayne@69
|
568 * in code point order
|
jpayne@69
|
569 * @stable ICU 2.0
|
jpayne@69
|
570 */
|
jpayne@69
|
571 inline int8_t compareCodePointOrder(int32_t start,
|
jpayne@69
|
572 int32_t length,
|
jpayne@69
|
573 const UnicodeString& srcText,
|
jpayne@69
|
574 int32_t srcStart,
|
jpayne@69
|
575 int32_t srcLength) const;
|
jpayne@69
|
576
|
jpayne@69
|
577 /**
|
jpayne@69
|
578 * Compare two Unicode strings in code point order.
|
jpayne@69
|
579 * The result may be different from the results of compare(), operator<, etc.
|
jpayne@69
|
580 * if supplementary characters are present:
|
jpayne@69
|
581 *
|
jpayne@69
|
582 * In UTF-16, supplementary characters (with code points U+10000 and above) are
|
jpayne@69
|
583 * stored with pairs of surrogate code units. These have values from 0xd800 to 0xdfff,
|
jpayne@69
|
584 * which means that they compare as less than some other BMP characters like U+feff.
|
jpayne@69
|
585 * This function compares Unicode strings in code point order.
|
jpayne@69
|
586 * If either of the UTF-16 strings is malformed (i.e., it contains unpaired surrogates), then the result is not defined.
|
jpayne@69
|
587 *
|
jpayne@69
|
588 * @param srcChars A pointer to another string to compare this one to.
|
jpayne@69
|
589 * @param srcLength The number of code units from that string to compare.
|
jpayne@69
|
590 * @return a negative/zero/positive integer corresponding to whether
|
jpayne@69
|
591 * this string is less than/equal to/greater than the second one
|
jpayne@69
|
592 * in code point order
|
jpayne@69
|
593 * @stable ICU 2.0
|
jpayne@69
|
594 */
|
jpayne@69
|
595 inline int8_t compareCodePointOrder(ConstChar16Ptr srcChars,
|
jpayne@69
|
596 int32_t srcLength) const;
|
jpayne@69
|
597
|
jpayne@69
|
598 /**
|
jpayne@69
|
599 * Compare two Unicode strings in code point order.
|
jpayne@69
|
600 * The result may be different from the results of compare(), operator<, etc.
|
jpayne@69
|
601 * if supplementary characters are present:
|
jpayne@69
|
602 *
|
jpayne@69
|
603 * In UTF-16, supplementary characters (with code points U+10000 and above) are
|
jpayne@69
|
604 * stored with pairs of surrogate code units. These have values from 0xd800 to 0xdfff,
|
jpayne@69
|
605 * which means that they compare as less than some other BMP characters like U+feff.
|
jpayne@69
|
606 * This function compares Unicode strings in code point order.
|
jpayne@69
|
607 * If either of the UTF-16 strings is malformed (i.e., it contains unpaired surrogates), then the result is not defined.
|
jpayne@69
|
608 *
|
jpayne@69
|
609 * @param start The start offset in this string at which the compare operation begins.
|
jpayne@69
|
610 * @param length The number of code units from this string to compare.
|
jpayne@69
|
611 * @param srcChars A pointer to another string to compare this one to.
|
jpayne@69
|
612 * @return a negative/zero/positive integer corresponding to whether
|
jpayne@69
|
613 * this string is less than/equal to/greater than the second one
|
jpayne@69
|
614 * in code point order
|
jpayne@69
|
615 * @stable ICU 2.0
|
jpayne@69
|
616 */
|
jpayne@69
|
617 inline int8_t compareCodePointOrder(int32_t start,
|
jpayne@69
|
618 int32_t length,
|
jpayne@69
|
619 const char16_t *srcChars) const;
|
jpayne@69
|
620
|
jpayne@69
|
621 /**
|
jpayne@69
|
622 * Compare two Unicode strings in code point order.
|
jpayne@69
|
623 * The result may be different from the results of compare(), operator<, etc.
|
jpayne@69
|
624 * if supplementary characters are present:
|
jpayne@69
|
625 *
|
jpayne@69
|
626 * In UTF-16, supplementary characters (with code points U+10000 and above) are
|
jpayne@69
|
627 * stored with pairs of surrogate code units. These have values from 0xd800 to 0xdfff,
|
jpayne@69
|
628 * which means that they compare as less than some other BMP characters like U+feff.
|
jpayne@69
|
629 * This function compares Unicode strings in code point order.
|
jpayne@69
|
630 * If either of the UTF-16 strings is malformed (i.e., it contains unpaired surrogates), then the result is not defined.
|
jpayne@69
|
631 *
|
jpayne@69
|
632 * @param start The start offset in this string at which the compare operation begins.
|
jpayne@69
|
633 * @param length The number of code units from this string to compare.
|
jpayne@69
|
634 * @param srcChars A pointer to another string to compare this one to.
|
jpayne@69
|
635 * @param srcStart The start offset in that string at which the compare operation begins.
|
jpayne@69
|
636 * @param srcLength The number of code units from that string to compare.
|
jpayne@69
|
637 * @return a negative/zero/positive integer corresponding to whether
|
jpayne@69
|
638 * this string is less than/equal to/greater than the second one
|
jpayne@69
|
639 * in code point order
|
jpayne@69
|
640 * @stable ICU 2.0
|
jpayne@69
|
641 */
|
jpayne@69
|
642 inline int8_t compareCodePointOrder(int32_t start,
|
jpayne@69
|
643 int32_t length,
|
jpayne@69
|
644 const char16_t *srcChars,
|
jpayne@69
|
645 int32_t srcStart,
|
jpayne@69
|
646 int32_t srcLength) const;
|
jpayne@69
|
647
|
jpayne@69
|
648 /**
|
jpayne@69
|
649 * Compare two Unicode strings in code point order.
|
jpayne@69
|
650 * The result may be different from the results of compare(), operator<, etc.
|
jpayne@69
|
651 * if supplementary characters are present:
|
jpayne@69
|
652 *
|
jpayne@69
|
653 * In UTF-16, supplementary characters (with code points U+10000 and above) are
|
jpayne@69
|
654 * stored with pairs of surrogate code units. These have values from 0xd800 to 0xdfff,
|
jpayne@69
|
655 * which means that they compare as less than some other BMP characters like U+feff.
|
jpayne@69
|
656 * This function compares Unicode strings in code point order.
|
jpayne@69
|
657 * If either of the UTF-16 strings is malformed (i.e., it contains unpaired surrogates), then the result is not defined.
|
jpayne@69
|
658 *
|
jpayne@69
|
659 * @param start The start offset in this string at which the compare operation begins.
|
jpayne@69
|
660 * @param limit The offset after the last code unit from this string to compare.
|
jpayne@69
|
661 * @param srcText Another string to compare this one to.
|
jpayne@69
|
662 * @param srcStart The start offset in that string at which the compare operation begins.
|
jpayne@69
|
663 * @param srcLimit The offset after the last code unit from that string to compare.
|
jpayne@69
|
664 * @return a negative/zero/positive integer corresponding to whether
|
jpayne@69
|
665 * this string is less than/equal to/greater than the second one
|
jpayne@69
|
666 * in code point order
|
jpayne@69
|
667 * @stable ICU 2.0
|
jpayne@69
|
668 */
|
jpayne@69
|
669 inline int8_t compareCodePointOrderBetween(int32_t start,
|
jpayne@69
|
670 int32_t limit,
|
jpayne@69
|
671 const UnicodeString& srcText,
|
jpayne@69
|
672 int32_t srcStart,
|
jpayne@69
|
673 int32_t srcLimit) const;
|
jpayne@69
|
674
|
jpayne@69
|
675 /**
|
jpayne@69
|
676 * Compare two strings case-insensitively using full case folding.
|
jpayne@69
|
677 * This is equivalent to this->foldCase(options).compare(text.foldCase(options)).
|
jpayne@69
|
678 *
|
jpayne@69
|
679 * @param text Another string to compare this one to.
|
jpayne@69
|
680 * @param options A bit set of options:
|
jpayne@69
|
681 * - U_FOLD_CASE_DEFAULT or 0 is used for default options:
|
jpayne@69
|
682 * Comparison in code unit order with default case folding.
|
jpayne@69
|
683 *
|
jpayne@69
|
684 * - U_COMPARE_CODE_POINT_ORDER
|
jpayne@69
|
685 * Set to choose code point order instead of code unit order
|
jpayne@69
|
686 * (see u_strCompare for details).
|
jpayne@69
|
687 *
|
jpayne@69
|
688 * - U_FOLD_CASE_EXCLUDE_SPECIAL_I
|
jpayne@69
|
689 *
|
jpayne@69
|
690 * @return A negative, zero, or positive integer indicating the comparison result.
|
jpayne@69
|
691 * @stable ICU 2.0
|
jpayne@69
|
692 */
|
jpayne@69
|
693 inline int8_t caseCompare(const UnicodeString& text, uint32_t options) const;
|
jpayne@69
|
694
|
jpayne@69
|
695 /**
|
jpayne@69
|
696 * Compare two strings case-insensitively using full case folding.
|
jpayne@69
|
697 * This is equivalent to this->foldCase(options).compare(srcText.foldCase(options)).
|
jpayne@69
|
698 *
|
jpayne@69
|
699 * @param start The start offset in this string at which the compare operation begins.
|
jpayne@69
|
700 * @param length The number of code units from this string to compare.
|
jpayne@69
|
701 * @param srcText Another string to compare this one to.
|
jpayne@69
|
702 * @param options A bit set of options:
|
jpayne@69
|
703 * - U_FOLD_CASE_DEFAULT or 0 is used for default options:
|
jpayne@69
|
704 * Comparison in code unit order with default case folding.
|
jpayne@69
|
705 *
|
jpayne@69
|
706 * - U_COMPARE_CODE_POINT_ORDER
|
jpayne@69
|
707 * Set to choose code point order instead of code unit order
|
jpayne@69
|
708 * (see u_strCompare for details).
|
jpayne@69
|
709 *
|
jpayne@69
|
710 * - U_FOLD_CASE_EXCLUDE_SPECIAL_I
|
jpayne@69
|
711 *
|
jpayne@69
|
712 * @return A negative, zero, or positive integer indicating the comparison result.
|
jpayne@69
|
713 * @stable ICU 2.0
|
jpayne@69
|
714 */
|
jpayne@69
|
715 inline int8_t caseCompare(int32_t start,
|
jpayne@69
|
716 int32_t length,
|
jpayne@69
|
717 const UnicodeString& srcText,
|
jpayne@69
|
718 uint32_t options) const;
|
jpayne@69
|
719
|
jpayne@69
|
720 /**
|
jpayne@69
|
721 * Compare two strings case-insensitively using full case folding.
|
jpayne@69
|
722 * This is equivalent to this->foldCase(options).compare(srcText.foldCase(options)).
|
jpayne@69
|
723 *
|
jpayne@69
|
724 * @param start The start offset in this string at which the compare operation begins.
|
jpayne@69
|
725 * @param length The number of code units from this string to compare.
|
jpayne@69
|
726 * @param srcText Another string to compare this one to.
|
jpayne@69
|
727 * @param srcStart The start offset in that string at which the compare operation begins.
|
jpayne@69
|
728 * @param srcLength The number of code units from that string to compare.
|
jpayne@69
|
729 * @param options A bit set of options:
|
jpayne@69
|
730 * - U_FOLD_CASE_DEFAULT or 0 is used for default options:
|
jpayne@69
|
731 * Comparison in code unit order with default case folding.
|
jpayne@69
|
732 *
|
jpayne@69
|
733 * - U_COMPARE_CODE_POINT_ORDER
|
jpayne@69
|
734 * Set to choose code point order instead of code unit order
|
jpayne@69
|
735 * (see u_strCompare for details).
|
jpayne@69
|
736 *
|
jpayne@69
|
737 * - U_FOLD_CASE_EXCLUDE_SPECIAL_I
|
jpayne@69
|
738 *
|
jpayne@69
|
739 * @return A negative, zero, or positive integer indicating the comparison result.
|
jpayne@69
|
740 * @stable ICU 2.0
|
jpayne@69
|
741 */
|
jpayne@69
|
742 inline int8_t caseCompare(int32_t start,
|
jpayne@69
|
743 int32_t length,
|
jpayne@69
|
744 const UnicodeString& srcText,
|
jpayne@69
|
745 int32_t srcStart,
|
jpayne@69
|
746 int32_t srcLength,
|
jpayne@69
|
747 uint32_t options) const;
|
jpayne@69
|
748
|
jpayne@69
|
749 /**
|
jpayne@69
|
750 * Compare two strings case-insensitively using full case folding.
|
jpayne@69
|
751 * This is equivalent to this->foldCase(options).compare(srcChars.foldCase(options)).
|
jpayne@69
|
752 *
|
jpayne@69
|
753 * @param srcChars A pointer to another string to compare this one to.
|
jpayne@69
|
754 * @param srcLength The number of code units from that string to compare.
|
jpayne@69
|
755 * @param options A bit set of options:
|
jpayne@69
|
756 * - U_FOLD_CASE_DEFAULT or 0 is used for default options:
|
jpayne@69
|
757 * Comparison in code unit order with default case folding.
|
jpayne@69
|
758 *
|
jpayne@69
|
759 * - U_COMPARE_CODE_POINT_ORDER
|
jpayne@69
|
760 * Set to choose code point order instead of code unit order
|
jpayne@69
|
761 * (see u_strCompare for details).
|
jpayne@69
|
762 *
|
jpayne@69
|
763 * - U_FOLD_CASE_EXCLUDE_SPECIAL_I
|
jpayne@69
|
764 *
|
jpayne@69
|
765 * @return A negative, zero, or positive integer indicating the comparison result.
|
jpayne@69
|
766 * @stable ICU 2.0
|
jpayne@69
|
767 */
|
jpayne@69
|
768 inline int8_t caseCompare(ConstChar16Ptr srcChars,
|
jpayne@69
|
769 int32_t srcLength,
|
jpayne@69
|
770 uint32_t options) const;
|
jpayne@69
|
771
|
jpayne@69
|
772 /**
|
jpayne@69
|
773 * Compare two strings case-insensitively using full case folding.
|
jpayne@69
|
774 * This is equivalent to this->foldCase(options).compare(srcChars.foldCase(options)).
|
jpayne@69
|
775 *
|
jpayne@69
|
776 * @param start The start offset in this string at which the compare operation begins.
|
jpayne@69
|
777 * @param length The number of code units from this string to compare.
|
jpayne@69
|
778 * @param srcChars A pointer to another string to compare this one to.
|
jpayne@69
|
779 * @param options A bit set of options:
|
jpayne@69
|
780 * - U_FOLD_CASE_DEFAULT or 0 is used for default options:
|
jpayne@69
|
781 * Comparison in code unit order with default case folding.
|
jpayne@69
|
782 *
|
jpayne@69
|
783 * - U_COMPARE_CODE_POINT_ORDER
|
jpayne@69
|
784 * Set to choose code point order instead of code unit order
|
jpayne@69
|
785 * (see u_strCompare for details).
|
jpayne@69
|
786 *
|
jpayne@69
|
787 * - U_FOLD_CASE_EXCLUDE_SPECIAL_I
|
jpayne@69
|
788 *
|
jpayne@69
|
789 * @return A negative, zero, or positive integer indicating the comparison result.
|
jpayne@69
|
790 * @stable ICU 2.0
|
jpayne@69
|
791 */
|
jpayne@69
|
792 inline int8_t caseCompare(int32_t start,
|
jpayne@69
|
793 int32_t length,
|
jpayne@69
|
794 const char16_t *srcChars,
|
jpayne@69
|
795 uint32_t options) const;
|
jpayne@69
|
796
|
jpayne@69
|
797 /**
|
jpayne@69
|
798 * Compare two strings case-insensitively using full case folding.
|
jpayne@69
|
799 * This is equivalent to this->foldCase(options).compare(srcChars.foldCase(options)).
|
jpayne@69
|
800 *
|
jpayne@69
|
801 * @param start The start offset in this string at which the compare operation begins.
|
jpayne@69
|
802 * @param length The number of code units from this string to compare.
|
jpayne@69
|
803 * @param srcChars A pointer to another string to compare this one to.
|
jpayne@69
|
804 * @param srcStart The start offset in that string at which the compare operation begins.
|
jpayne@69
|
805 * @param srcLength The number of code units from that string to compare.
|
jpayne@69
|
806 * @param options A bit set of options:
|
jpayne@69
|
807 * - U_FOLD_CASE_DEFAULT or 0 is used for default options:
|
jpayne@69
|
808 * Comparison in code unit order with default case folding.
|
jpayne@69
|
809 *
|
jpayne@69
|
810 * - U_COMPARE_CODE_POINT_ORDER
|
jpayne@69
|
811 * Set to choose code point order instead of code unit order
|
jpayne@69
|
812 * (see u_strCompare for details).
|
jpayne@69
|
813 *
|
jpayne@69
|
814 * - U_FOLD_CASE_EXCLUDE_SPECIAL_I
|
jpayne@69
|
815 *
|
jpayne@69
|
816 * @return A negative, zero, or positive integer indicating the comparison result.
|
jpayne@69
|
817 * @stable ICU 2.0
|
jpayne@69
|
818 */
|
jpayne@69
|
819 inline int8_t caseCompare(int32_t start,
|
jpayne@69
|
820 int32_t length,
|
jpayne@69
|
821 const char16_t *srcChars,
|
jpayne@69
|
822 int32_t srcStart,
|
jpayne@69
|
823 int32_t srcLength,
|
jpayne@69
|
824 uint32_t options) const;
|
jpayne@69
|
825
|
jpayne@69
|
826 /**
|
jpayne@69
|
827 * Compare two strings case-insensitively using full case folding.
|
jpayne@69
|
828 * This is equivalent to this->foldCase(options).compareBetween(text.foldCase(options)).
|
jpayne@69
|
829 *
|
jpayne@69
|
830 * @param start The start offset in this string at which the compare operation begins.
|
jpayne@69
|
831 * @param limit The offset after the last code unit from this string to compare.
|
jpayne@69
|
832 * @param srcText Another string to compare this one to.
|
jpayne@69
|
833 * @param srcStart The start offset in that string at which the compare operation begins.
|
jpayne@69
|
834 * @param srcLimit The offset after the last code unit from that string to compare.
|
jpayne@69
|
835 * @param options A bit set of options:
|
jpayne@69
|
836 * - U_FOLD_CASE_DEFAULT or 0 is used for default options:
|
jpayne@69
|
837 * Comparison in code unit order with default case folding.
|
jpayne@69
|
838 *
|
jpayne@69
|
839 * - U_COMPARE_CODE_POINT_ORDER
|
jpayne@69
|
840 * Set to choose code point order instead of code unit order
|
jpayne@69
|
841 * (see u_strCompare for details).
|
jpayne@69
|
842 *
|
jpayne@69
|
843 * - U_FOLD_CASE_EXCLUDE_SPECIAL_I
|
jpayne@69
|
844 *
|
jpayne@69
|
845 * @return A negative, zero, or positive integer indicating the comparison result.
|
jpayne@69
|
846 * @stable ICU 2.0
|
jpayne@69
|
847 */
|
jpayne@69
|
848 inline int8_t caseCompareBetween(int32_t start,
|
jpayne@69
|
849 int32_t limit,
|
jpayne@69
|
850 const UnicodeString& srcText,
|
jpayne@69
|
851 int32_t srcStart,
|
jpayne@69
|
852 int32_t srcLimit,
|
jpayne@69
|
853 uint32_t options) const;
|
jpayne@69
|
854
|
jpayne@69
|
855 /**
|
jpayne@69
|
856 * Determine if this starts with the characters in `text`
|
jpayne@69
|
857 * @param text The text to match.
|
jpayne@69
|
858 * @return TRUE if this starts with the characters in `text`,
|
jpayne@69
|
859 * FALSE otherwise
|
jpayne@69
|
860 * @stable ICU 2.0
|
jpayne@69
|
861 */
|
jpayne@69
|
862 inline UBool startsWith(const UnicodeString& text) const;
|
jpayne@69
|
863
|
jpayne@69
|
864 /**
|
jpayne@69
|
865 * Determine if this starts with the characters in `srcText`
|
jpayne@69
|
866 * in the range [`srcStart`, `srcStart + srcLength`).
|
jpayne@69
|
867 * @param srcText The text to match.
|
jpayne@69
|
868 * @param srcStart the offset into `srcText` to start matching
|
jpayne@69
|
869 * @param srcLength the number of characters in `srcText` to match
|
jpayne@69
|
870 * @return TRUE if this starts with the characters in `text`,
|
jpayne@69
|
871 * FALSE otherwise
|
jpayne@69
|
872 * @stable ICU 2.0
|
jpayne@69
|
873 */
|
jpayne@69
|
874 inline UBool startsWith(const UnicodeString& srcText,
|
jpayne@69
|
875 int32_t srcStart,
|
jpayne@69
|
876 int32_t srcLength) const;
|
jpayne@69
|
877
|
jpayne@69
|
878 /**
|
jpayne@69
|
879 * Determine if this starts with the characters in `srcChars`
|
jpayne@69
|
880 * @param srcChars The characters to match.
|
jpayne@69
|
881 * @param srcLength the number of characters in `srcChars`
|
jpayne@69
|
882 * @return TRUE if this starts with the characters in `srcChars`,
|
jpayne@69
|
883 * FALSE otherwise
|
jpayne@69
|
884 * @stable ICU 2.0
|
jpayne@69
|
885 */
|
jpayne@69
|
886 inline UBool startsWith(ConstChar16Ptr srcChars,
|
jpayne@69
|
887 int32_t srcLength) const;
|
jpayne@69
|
888
|
jpayne@69
|
889 /**
|
jpayne@69
|
890 * Determine if this ends with the characters in `srcChars`
|
jpayne@69
|
891 * in the range [`srcStart`, `srcStart + srcLength`).
|
jpayne@69
|
892 * @param srcChars The characters to match.
|
jpayne@69
|
893 * @param srcStart the offset into `srcText` to start matching
|
jpayne@69
|
894 * @param srcLength the number of characters in `srcChars` to match
|
jpayne@69
|
895 * @return TRUE if this ends with the characters in `srcChars`, FALSE otherwise
|
jpayne@69
|
896 * @stable ICU 2.0
|
jpayne@69
|
897 */
|
jpayne@69
|
898 inline UBool startsWith(const char16_t *srcChars,
|
jpayne@69
|
899 int32_t srcStart,
|
jpayne@69
|
900 int32_t srcLength) const;
|
jpayne@69
|
901
|
jpayne@69
|
902 /**
|
jpayne@69
|
903 * Determine if this ends with the characters in `text`
|
jpayne@69
|
904 * @param text The text to match.
|
jpayne@69
|
905 * @return TRUE if this ends with the characters in `text`,
|
jpayne@69
|
906 * FALSE otherwise
|
jpayne@69
|
907 * @stable ICU 2.0
|
jpayne@69
|
908 */
|
jpayne@69
|
909 inline UBool endsWith(const UnicodeString& text) const;
|
jpayne@69
|
910
|
jpayne@69
|
911 /**
|
jpayne@69
|
912 * Determine if this ends with the characters in `srcText`
|
jpayne@69
|
913 * in the range [`srcStart`, `srcStart + srcLength`).
|
jpayne@69
|
914 * @param srcText The text to match.
|
jpayne@69
|
915 * @param srcStart the offset into `srcText` to start matching
|
jpayne@69
|
916 * @param srcLength the number of characters in `srcText` to match
|
jpayne@69
|
917 * @return TRUE if this ends with the characters in `text`,
|
jpayne@69
|
918 * FALSE otherwise
|
jpayne@69
|
919 * @stable ICU 2.0
|
jpayne@69
|
920 */
|
jpayne@69
|
921 inline UBool endsWith(const UnicodeString& srcText,
|
jpayne@69
|
922 int32_t srcStart,
|
jpayne@69
|
923 int32_t srcLength) const;
|
jpayne@69
|
924
|
jpayne@69
|
925 /**
|
jpayne@69
|
926 * Determine if this ends with the characters in `srcChars`
|
jpayne@69
|
927 * @param srcChars The characters to match.
|
jpayne@69
|
928 * @param srcLength the number of characters in `srcChars`
|
jpayne@69
|
929 * @return TRUE if this ends with the characters in `srcChars`,
|
jpayne@69
|
930 * FALSE otherwise
|
jpayne@69
|
931 * @stable ICU 2.0
|
jpayne@69
|
932 */
|
jpayne@69
|
933 inline UBool endsWith(ConstChar16Ptr srcChars,
|
jpayne@69
|
934 int32_t srcLength) const;
|
jpayne@69
|
935
|
jpayne@69
|
936 /**
|
jpayne@69
|
937 * Determine if this ends with the characters in `srcChars`
|
jpayne@69
|
938 * in the range [`srcStart`, `srcStart + srcLength`).
|
jpayne@69
|
939 * @param srcChars The characters to match.
|
jpayne@69
|
940 * @param srcStart the offset into `srcText` to start matching
|
jpayne@69
|
941 * @param srcLength the number of characters in `srcChars` to match
|
jpayne@69
|
942 * @return TRUE if this ends with the characters in `srcChars`,
|
jpayne@69
|
943 * FALSE otherwise
|
jpayne@69
|
944 * @stable ICU 2.0
|
jpayne@69
|
945 */
|
jpayne@69
|
946 inline UBool endsWith(const char16_t *srcChars,
|
jpayne@69
|
947 int32_t srcStart,
|
jpayne@69
|
948 int32_t srcLength) const;
|
jpayne@69
|
949
|
jpayne@69
|
950
|
jpayne@69
|
951 /* Searching - bitwise only */
|
jpayne@69
|
952
|
jpayne@69
|
953 /**
|
jpayne@69
|
954 * Locate in this the first occurrence of the characters in `text`,
|
jpayne@69
|
955 * using bitwise comparison.
|
jpayne@69
|
956 * @param text The text to search for.
|
jpayne@69
|
957 * @return The offset into this of the start of `text`,
|
jpayne@69
|
958 * or -1 if not found.
|
jpayne@69
|
959 * @stable ICU 2.0
|
jpayne@69
|
960 */
|
jpayne@69
|
961 inline int32_t indexOf(const UnicodeString& text) const;
|
jpayne@69
|
962
|
jpayne@69
|
963 /**
|
jpayne@69
|
964 * Locate in this the first occurrence of the characters in `text`
|
jpayne@69
|
965 * starting at offset `start`, using bitwise comparison.
|
jpayne@69
|
966 * @param text The text to search for.
|
jpayne@69
|
967 * @param start The offset at which searching will start.
|
jpayne@69
|
968 * @return The offset into this of the start of `text`,
|
jpayne@69
|
969 * or -1 if not found.
|
jpayne@69
|
970 * @stable ICU 2.0
|
jpayne@69
|
971 */
|
jpayne@69
|
972 inline int32_t indexOf(const UnicodeString& text,
|
jpayne@69
|
973 int32_t start) const;
|
jpayne@69
|
974
|
jpayne@69
|
975 /**
|
jpayne@69
|
976 * Locate in this the first occurrence in the range
|
jpayne@69
|
977 * [`start`, `start + length`) of the characters
|
jpayne@69
|
978 * in `text`, using bitwise comparison.
|
jpayne@69
|
979 * @param text The text to search for.
|
jpayne@69
|
980 * @param start The offset at which searching will start.
|
jpayne@69
|
981 * @param length The number of characters to search
|
jpayne@69
|
982 * @return The offset into this of the start of `text`,
|
jpayne@69
|
983 * or -1 if not found.
|
jpayne@69
|
984 * @stable ICU 2.0
|
jpayne@69
|
985 */
|
|