os/textandloc/fontservices/textshaperplugin/IcuSource/common/unicode/unistr.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
/*
sl@0
     2
**********************************************************************
sl@0
     3
*   Copyright (C) 1998-2005, International Business Machines
sl@0
     4
*   Corporation and others.  All Rights Reserved.
sl@0
     5
**********************************************************************
sl@0
     6
*
sl@0
     7
* File unistr.h
sl@0
     8
*
sl@0
     9
* Modification History:
sl@0
    10
*
sl@0
    11
*   Date        Name        Description
sl@0
    12
*   09/25/98    stephen     Creation.
sl@0
    13
*   11/11/98    stephen     Changed per 11/9 code review.
sl@0
    14
*   04/20/99    stephen     Overhauled per 4/16 code review.
sl@0
    15
*   11/18/99    aliu        Made to inherit from Replaceable.  Added method
sl@0
    16
*                           handleReplaceBetween(); other methods unchanged.
sl@0
    17
*   06/25/01    grhoten     Remove dependency on iostream.
sl@0
    18
******************************************************************************
sl@0
    19
*/
sl@0
    20
sl@0
    21
#ifndef UNISTR_H
sl@0
    22
#define UNISTR_H
sl@0
    23
sl@0
    24
/**
sl@0
    25
 * \file 
sl@0
    26
 * \brief C++ API: Unicode String 
sl@0
    27
 */
sl@0
    28
sl@0
    29
#include "unicode/rep.h"
sl@0
    30
sl@0
    31
struct UConverter;          // unicode/ucnv.h
sl@0
    32
class  StringThreadTest;
sl@0
    33
sl@0
    34
#ifndef U_COMPARE_CODE_POINT_ORDER
sl@0
    35
/* see also ustring.h and unorm.h */
sl@0
    36
/**
sl@0
    37
 * Option bit for u_strCaseCompare, u_strcasecmp, unorm_compare, etc:
sl@0
    38
 * Compare strings in code point order instead of code unit order.
sl@0
    39
 * @stable ICU 2.2
sl@0
    40
 */
sl@0
    41
#define U_COMPARE_CODE_POINT_ORDER  0x8000
sl@0
    42
#endif
sl@0
    43
sl@0
    44
#ifndef USTRING_H
sl@0
    45
/* see ustring.h */
sl@0
    46
U_STABLE int32_t U_EXPORT2
sl@0
    47
u_strlen(const UChar *s);
sl@0
    48
#endif
sl@0
    49
sl@0
    50
U_NAMESPACE_BEGIN
sl@0
    51
sl@0
    52
class Locale;               // unicode/locid.h
sl@0
    53
class StringCharacterIterator;
sl@0
    54
class BreakIterator;        // unicode/brkiter.h
sl@0
    55
sl@0
    56
/* The <iostream> include has been moved to unicode/ustream.h */
sl@0
    57
sl@0
    58
/**
sl@0
    59
 * Constant to be used in the UnicodeString(char *, int32_t, EInvariant) constructor
sl@0
    60
 * which constructs a Unicode string from an invariant-character char * string.
sl@0
    61
 * About invariant characters see utypes.h.
sl@0
    62
 * This constructor has no runtime dependency on conversion code and is
sl@0
    63
 * therefore recommended over ones taking a charset name string
sl@0
    64
 * (where the empty string "" indicates invariant-character conversion).
sl@0
    65
 *
sl@0
    66
 * @draft ICU 3.2
sl@0
    67
 */
sl@0
    68
#define US_INV UnicodeString::kInvariant
sl@0
    69
sl@0
    70
/**
sl@0
    71
 * Unicode String literals in C++.
sl@0
    72
 * Dependent on the platform properties, different UnicodeString
sl@0
    73
 * constructors should be used to create a UnicodeString object from
sl@0
    74
 * a string literal.
sl@0
    75
 * The macros are defined for maximum performance.
sl@0
    76
 * They work only for strings that contain "invariant characters", i.e.,
sl@0
    77
 * only latin letters, digits, and some punctuation.
sl@0
    78
 * See utypes.h for details.
sl@0
    79
 *
sl@0
    80
 * The string parameter must be a C string literal.
sl@0
    81
 * The length of the string, not including the terminating
sl@0
    82
 * <code>NUL</code>, must be specified as a constant.
sl@0
    83
 * The U_STRING_DECL macro should be invoked exactly once for one
sl@0
    84
 * such string variable before it is used.
sl@0
    85
 * @stable ICU 2.0
sl@0
    86
 */
sl@0
    87
#if U_SIZEOF_WCHAR_T==U_SIZEOF_UCHAR && (U_CHARSET_FAMILY==U_ASCII_FAMILY || (U_SIZEOF_UCHAR == 2 && defined(U_WCHAR_IS_UTF16)))
sl@0
    88
#   define UNICODE_STRING(cs, _length) UnicodeString(TRUE, (const UChar *)L ## cs, _length)
sl@0
    89
#elif U_SIZEOF_UCHAR==1 && U_CHARSET_FAMILY==U_ASCII_FAMILY
sl@0
    90
#   define UNICODE_STRING(cs, _length) UnicodeString(TRUE, (const UChar *)cs, _length)
sl@0
    91
#else
sl@0
    92
#   define UNICODE_STRING(cs, _length) UnicodeString(cs, _length, US_INV)
sl@0
    93
#endif
sl@0
    94
sl@0
    95
/**
sl@0
    96
 * Unicode String literals in C++.
sl@0
    97
 * Dependent on the platform properties, different UnicodeString
sl@0
    98
 * constructors should be used to create a UnicodeString object from
sl@0
    99
 * a string literal.
sl@0
   100
 * The macros are defined for improved performance.
sl@0
   101
 * They work only for strings that contain "invariant characters", i.e.,
sl@0
   102
 * only latin letters, digits, and some punctuation.
sl@0
   103
 * See utypes.h for details.
sl@0
   104
 *
sl@0
   105
 * The string parameter must be a C string literal.
sl@0
   106
 * @stable ICU 2.0
sl@0
   107
 */
sl@0
   108
#if U_SIZEOF_WCHAR_T==U_SIZEOF_UCHAR && (U_CHARSET_FAMILY==U_ASCII_FAMILY || (U_SIZEOF_UCHAR == 2 && defined(U_WCHAR_IS_UTF16)))
sl@0
   109
#   define UNICODE_STRING_SIMPLE(cs) UnicodeString(TRUE, (const UChar *)L ## cs, -1)
sl@0
   110
#elif U_SIZEOF_UCHAR==1 && U_CHARSET_FAMILY==U_ASCII_FAMILY
sl@0
   111
#   define UNICODE_STRING_SIMPLE(cs) UnicodeString(TRUE, (const UChar *)cs, -1)
sl@0
   112
#else
sl@0
   113
#   define UNICODE_STRING_SIMPLE(cs) UnicodeString(cs, -1, US_INV)
sl@0
   114
#endif
sl@0
   115
sl@0
   116
/**
sl@0
   117
 * UnicodeString is a string class that stores Unicode characters directly and provides
sl@0
   118
 * similar functionality as the Java String and StringBuffer classes.
sl@0
   119
 * It is a concrete implementation of the abstract class Replaceable (for transliteration).
sl@0
   120
 *
sl@0
   121
 * The UnicodeString class is not suitable for subclassing.
sl@0
   122
 *
sl@0
   123
 * <p>For an overview of Unicode strings in C and C++ see the
sl@0
   124
 * <a href="http://icu.sourceforge.net/userguide/strings.html">User Guide Strings chapter</a>.</p>
sl@0
   125
 *
sl@0
   126
 * <p>In ICU, a Unicode string consists of 16-bit Unicode <em>code units</em>.
sl@0
   127
 * A Unicode character may be stored with either one code unit
sl@0
   128
 * (the most common case) or with a matched pair of special code units
sl@0
   129
 * ("surrogates"). The data type for code units is UChar. 
sl@0
   130
 * For single-character handling, a Unicode character code <em>point</em> is a value
sl@0
   131
 * in the range 0..0x10ffff. ICU uses the UChar32 type for code points.</p>
sl@0
   132
 *
sl@0
   133
 * <p>Indexes and offsets into and lengths of strings always count code units, not code points.
sl@0
   134
 * This is the same as with multi-byte char* strings in traditional string handling.
sl@0
   135
 * Operations on partial strings typically do not test for code point boundaries.
sl@0
   136
 * If necessary, the user needs to take care of such boundaries by testing for the code unit
sl@0
   137
 * values or by using functions like
sl@0
   138
 * UnicodeString::getChar32Start() and UnicodeString::getChar32Limit()
sl@0
   139
 * (or, in C, the equivalent macros U16_SET_CP_START() and U16_SET_CP_LIMIT(), see utf.h).</p>
sl@0
   140
 *
sl@0
   141
 * UnicodeString methods are more lenient with regard to input parameter values
sl@0
   142
 * than other ICU APIs. In particular:
sl@0
   143
 * - If indexes are out of bounds for a UnicodeString object
sl@0
   144
 *   (<0 or >length()) then they are "pinned" to the nearest boundary.
sl@0
   145
 * - If primitive string pointer values (e.g., const UChar * or char *)
sl@0
   146
 *   for input strings are NULL, then those input string parameters are treated
sl@0
   147
 *   as if they pointed to an empty string.
sl@0
   148
 *   However, this is <em>not</em> the case for char * parameters for charset names
sl@0
   149
 *   or other IDs.
sl@0
   150
 * - Most UnicodeString methods do not take a UErrorCode parameter because
sl@0
   151
 *   there are usually very few opportunities for failure other than a shortage
sl@0
   152
 *   of memory, error codes in low-level C++ string methods would be inconvenient,
sl@0
   153
 *   and the error code as the last parameter (ICU convention) would prevent
sl@0
   154
 *   the use of default parameter values.
sl@0
   155
 *   Instead, such methods set the UnicodeString into a "bogus" state
sl@0
   156
 *   (see isBogus()) if an error occurs.
sl@0
   157
 *
sl@0
   158
 * In string comparisons, two UnicodeString objects that are both "bogus"
sl@0
   159
 * compare equal (to be transitive and prevent endless loops in sorting),
sl@0
   160
 * and a "bogus" string compares less than any non-"bogus" one.
sl@0
   161
 *
sl@0
   162
 * Const UnicodeString methods are thread-safe. Multiple threads can use
sl@0
   163
 * const methods on the same UnicodeString object simultaneously,
sl@0
   164
 * but non-const methods must not be called concurrently (in multiple threads)
sl@0
   165
 * with any other (const or non-const) methods.
sl@0
   166
 *
sl@0
   167
 * Similarly, const UnicodeString & parameters are thread-safe.
sl@0
   168
 * One object may be passed in as such a parameter concurrently in multiple threads.
sl@0
   169
 * This includes the const UnicodeString & parameters for
sl@0
   170
 * copy construction, assignment, and cloning.
sl@0
   171
 *
sl@0
   172
 * <p>UnicodeString uses several storage methods.
sl@0
   173
 * String contents can be stored inside the UnicodeString object itself,
sl@0
   174
 * in an allocated and shared buffer, or in an outside buffer that is "aliased".
sl@0
   175
 * Most of this is done transparently, but careful aliasing in particular provides
sl@0
   176
 * significant performance improvements.
sl@0
   177
 * Also, the internal buffer is accessible via special functions.
sl@0
   178
 * For details see the
sl@0
   179
 * <a href="http://icu.sourceforge.net/userguide/strings.html">User Guide Strings chapter</a>.</p>
sl@0
   180
 *
sl@0
   181
 * @see utf.h
sl@0
   182
 * @see CharacterIterator
sl@0
   183
 * @stable ICU 2.0
sl@0
   184
 */
sl@0
   185
class U_COMMON_API UnicodeString : public Replaceable
sl@0
   186
{
sl@0
   187
public:
sl@0
   188
sl@0
   189
  /**
sl@0
   190
   * Constant to be used in the UnicodeString(char *, int32_t, EInvariant) constructor
sl@0
   191
   * which constructs a Unicode string from an invariant-character char * string.
sl@0
   192
   * Use the macro US_INV instead of the full qualification for this value.
sl@0
   193
   *
sl@0
   194
   * @see US_INV
sl@0
   195
   * @draft ICU 3.2
sl@0
   196
   */
sl@0
   197
  enum EInvariant {
sl@0
   198
    /**
sl@0
   199
     * @see EInvariant
sl@0
   200
     * @draft ICU 3.2
sl@0
   201
     */
sl@0
   202
    kInvariant
sl@0
   203
  };
sl@0
   204
sl@0
   205
  //========================================
sl@0
   206
  // Read-only operations
sl@0
   207
  //========================================
sl@0
   208
sl@0
   209
  /* Comparison - bitwise only - for international comparison use collation */
sl@0
   210
sl@0
   211
  /**
sl@0
   212
   * Equality operator. Performs only bitwise comparison.
sl@0
   213
   * @param text The UnicodeString to compare to this one.
sl@0
   214
   * @return TRUE if <TT>text</TT> contains the same characters as this one,
sl@0
   215
   * FALSE otherwise.
sl@0
   216
   * @stable ICU 2.0
sl@0
   217
   */
sl@0
   218
  inline UBool operator== (const UnicodeString& text) const;
sl@0
   219
sl@0
   220
  /**
sl@0
   221
   * Inequality operator. Performs only bitwise comparison.
sl@0
   222
   * @param text The UnicodeString to compare to this one.
sl@0
   223
   * @return FALSE if <TT>text</TT> contains the same characters as this one,
sl@0
   224
   * TRUE otherwise.
sl@0
   225
   * @stable ICU 2.0
sl@0
   226
   */
sl@0
   227
  inline UBool operator!= (const UnicodeString& text) const;
sl@0
   228
sl@0
   229
  /**
sl@0
   230
   * Greater than operator. Performs only bitwise comparison.
sl@0
   231
   * @param text The UnicodeString to compare to this one.
sl@0
   232
   * @return TRUE if the characters in this are bitwise
sl@0
   233
   * greater than the characters in <code>text</code>, FALSE otherwise
sl@0
   234
   * @stable ICU 2.0
sl@0
   235
   */
sl@0
   236
  inline UBool operator> (const UnicodeString& text) const;
sl@0
   237
sl@0
   238
  /**
sl@0
   239
   * Less than operator. Performs only bitwise comparison.
sl@0
   240
   * @param text The UnicodeString to compare to this one.
sl@0
   241
   * @return TRUE if the characters in this are bitwise
sl@0
   242
   * less than the characters in <code>text</code>, FALSE otherwise
sl@0
   243
   * @stable ICU 2.0
sl@0
   244
   */
sl@0
   245
  inline UBool operator< (const UnicodeString& text) const;
sl@0
   246
sl@0
   247
  /**
sl@0
   248
   * Greater than or equal operator. Performs only bitwise comparison.
sl@0
   249
   * @param text The UnicodeString to compare to this one.
sl@0
   250
   * @return TRUE if the characters in this are bitwise
sl@0
   251
   * greater than or equal to the characters in <code>text</code>, FALSE otherwise
sl@0
   252
   * @stable ICU 2.0
sl@0
   253
   */
sl@0
   254
  inline UBool operator>= (const UnicodeString& text) const;
sl@0
   255
sl@0
   256
  /**
sl@0
   257
   * Less than or equal operator. Performs only bitwise comparison.
sl@0
   258
   * @param text The UnicodeString to compare to this one.
sl@0
   259
   * @return TRUE if the characters in this are bitwise
sl@0
   260
   * less than or equal to the characters in <code>text</code>, FALSE otherwise
sl@0
   261
   * @stable ICU 2.0
sl@0
   262
   */
sl@0
   263
  inline UBool operator<= (const UnicodeString& text) const;
sl@0
   264
sl@0
   265
  /**
sl@0
   266
   * Compare the characters bitwise in this UnicodeString to
sl@0
   267
   * the characters in <code>text</code>.
sl@0
   268
   * @param text The UnicodeString to compare to this one.
sl@0
   269
   * @return The result of bitwise character comparison: 0 if this
sl@0
   270
   * contains the same characters as <code>text</code>, -1 if the characters in
sl@0
   271
   * this are bitwise less than the characters in <code>text</code>, +1 if the
sl@0
   272
   * characters in this are bitwise greater than the characters
sl@0
   273
   * in <code>text</code>.
sl@0
   274
   * @stable ICU 2.0
sl@0
   275
   */
sl@0
   276
  inline int8_t compare(const UnicodeString& text) const;
sl@0
   277
sl@0
   278
  /**
sl@0
   279
   * Compare the characters bitwise in the range
sl@0
   280
   * [<TT>start</TT>, <TT>start + length</TT>) with the characters
sl@0
   281
   * in <TT>text</TT>
sl@0
   282
   * @param start the offset at which the compare operation begins
sl@0
   283
   * @param length the number of characters of text to compare.
sl@0
   284
   * @param text the other text to be compared against this string.
sl@0
   285
   * @return The result of bitwise character comparison: 0 if this
sl@0
   286
   * contains the same characters as <code>text</code>, -1 if the characters in
sl@0
   287
   * this are bitwise less than the characters in <code>text</code>, +1 if the
sl@0
   288
   * characters in this are bitwise greater than the characters
sl@0
   289
   * in <code>text</code>.
sl@0
   290
   * @stable ICU 2.0
sl@0
   291
   */
sl@0
   292
  inline int8_t compare(int32_t start,
sl@0
   293
         int32_t length,
sl@0
   294
         const UnicodeString& text) const;
sl@0
   295
sl@0
   296
  /**
sl@0
   297
   * Compare the characters bitwise in the range
sl@0
   298
   * [<TT>start</TT>, <TT>start + length</TT>) with the characters
sl@0
   299
   * in <TT>srcText</TT> in the range
sl@0
   300
   * [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>).
sl@0
   301
   * @param start the offset at which the compare operation begins
sl@0
   302
   * @param length the number of characters in this to compare.
sl@0
   303
   * @param srcText the text to be compared
sl@0
   304
   * @param srcStart the offset into <TT>srcText</TT> to start comparison
sl@0
   305
   * @param srcLength the number of characters in <TT>src</TT> to compare
sl@0
   306
   * @return The result of bitwise character comparison: 0 if this
sl@0
   307
   * contains the same characters as <code>srcText</code>, -1 if the characters in
sl@0
   308
   * this are bitwise less than the characters in <code>srcText</code>, +1 if the
sl@0
   309
   * characters in this are bitwise greater than the characters
sl@0
   310
   * in <code>srcText</code>.
sl@0
   311
   * @stable ICU 2.0
sl@0
   312
   */
sl@0
   313
   inline int8_t compare(int32_t start,
sl@0
   314
         int32_t length,
sl@0
   315
         const UnicodeString& srcText,
sl@0
   316
         int32_t srcStart,
sl@0
   317
         int32_t srcLength) const;
sl@0
   318
sl@0
   319
  /**
sl@0
   320
   * Compare the characters bitwise in this UnicodeString with the first
sl@0
   321
   * <TT>srcLength</TT> characters in <TT>srcChars</TT>.
sl@0
   322
   * @param srcChars The characters to compare to this UnicodeString.
sl@0
   323
   * @param srcLength the number of characters in <TT>srcChars</TT> to compare
sl@0
   324
   * @return The result of bitwise character comparison: 0 if this
sl@0
   325
   * contains the same characters as <code>srcChars</code>, -1 if the characters in
sl@0
   326
   * this are bitwise less than the characters in <code>srcChars</code>, +1 if the
sl@0
   327
   * characters in this are bitwise greater than the characters
sl@0
   328
   * in <code>srcChars</code>.
sl@0
   329
   * @stable ICU 2.0
sl@0
   330
   */
sl@0
   331
  inline int8_t compare(const UChar *srcChars,
sl@0
   332
         int32_t srcLength) const;
sl@0
   333
sl@0
   334
  /**
sl@0
   335
   * Compare the characters bitwise in the range
sl@0
   336
   * [<TT>start</TT>, <TT>start + length</TT>) with the first
sl@0
   337
   * <TT>length</TT> characters in <TT>srcChars</TT>
sl@0
   338
   * @param start the offset at which the compare operation begins
sl@0
   339
   * @param length the number of characters to compare.
sl@0
   340
   * @param srcChars the characters to be compared
sl@0
   341
   * @return The result of bitwise character comparison: 0 if this
sl@0
   342
   * contains the same characters as <code>srcChars</code>, -1 if the characters in
sl@0
   343
   * this are bitwise less than the characters in <code>srcChars</code>, +1 if the
sl@0
   344
   * characters in this are bitwise greater than the characters
sl@0
   345
   * in <code>srcChars</code>.
sl@0
   346
   * @stable ICU 2.0
sl@0
   347
   */
sl@0
   348
  inline int8_t compare(int32_t start,
sl@0
   349
         int32_t length,
sl@0
   350
         const UChar *srcChars) const;
sl@0
   351
sl@0
   352
  /**
sl@0
   353
   * Compare the characters bitwise in the range
sl@0
   354
   * [<TT>start</TT>, <TT>start + length</TT>) with the characters
sl@0
   355
   * in <TT>srcChars</TT> in the range
sl@0
   356
   * [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>).
sl@0
   357
   * @param start the offset at which the compare operation begins
sl@0
   358
   * @param length the number of characters in this to compare
sl@0
   359
   * @param srcChars the characters to be compared
sl@0
   360
   * @param srcStart the offset into <TT>srcChars</TT> to start comparison
sl@0
   361
   * @param srcLength the number of characters in <TT>srcChars</TT> to compare
sl@0
   362
   * @return The result of bitwise character comparison: 0 if this
sl@0
   363
   * contains the same characters as <code>srcChars</code>, -1 if the characters in
sl@0
   364
   * this are bitwise less than the characters in <code>srcChars</code>, +1 if the
sl@0
   365
   * characters in this are bitwise greater than the characters
sl@0
   366
   * in <code>srcChars</code>.
sl@0
   367
   * @stable ICU 2.0
sl@0
   368
   */
sl@0
   369
  inline int8_t compare(int32_t start,
sl@0
   370
         int32_t length,
sl@0
   371
         const UChar *srcChars,
sl@0
   372
         int32_t srcStart,
sl@0
   373
         int32_t srcLength) const;
sl@0
   374
sl@0
   375
  /**
sl@0
   376
   * Compare the characters bitwise in the range
sl@0
   377
   * [<TT>start</TT>, <TT>limit</TT>) with the characters
sl@0
   378
   * in <TT>srcText</TT> in the range
sl@0
   379
   * [<TT>srcStart</TT>, <TT>srcLimit</TT>).
sl@0
   380
   * @param start the offset at which the compare operation begins
sl@0
   381
   * @param limit the offset immediately following the compare operation
sl@0
   382
   * @param srcText the text to be compared
sl@0
   383
   * @param srcStart the offset into <TT>srcText</TT> to start comparison
sl@0
   384
   * @param srcLimit the offset into <TT>srcText</TT> to limit comparison
sl@0
   385
   * @return The result of bitwise character comparison: 0 if this
sl@0
   386
   * contains the same characters as <code>srcText</code>, -1 if the characters in
sl@0
   387
   * this are bitwise less than the characters in <code>srcText</code>, +1 if the
sl@0
   388
   * characters in this are bitwise greater than the characters
sl@0
   389
   * in <code>srcText</code>.
sl@0
   390
   * @stable ICU 2.0
sl@0
   391
   */
sl@0
   392
  inline int8_t compareBetween(int32_t start,
sl@0
   393
            int32_t limit,
sl@0
   394
            const UnicodeString& srcText,
sl@0
   395
            int32_t srcStart,
sl@0
   396
            int32_t srcLimit) const;
sl@0
   397
sl@0
   398
  /**
sl@0
   399
   * Compare two Unicode strings in code point order.
sl@0
   400
   * This is different in UTF-16 from how compare(), operator==, startsWith() etc. work
sl@0
   401
   * if supplementary characters are present:
sl@0
   402
   *
sl@0
   403
   * In UTF-16, supplementary characters (with code points U+10000 and above) are
sl@0
   404
   * stored with pairs of surrogate code units. These have values from 0xd800 to 0xdfff,
sl@0
   405
   * which means that they compare as less than some other BMP characters like U+feff.
sl@0
   406
   * This function compares Unicode strings in code point order.
sl@0
   407
   * If either of the UTF-16 strings is malformed (i.e., it contains unpaired surrogates), then the result is not defined.
sl@0
   408
   *
sl@0
   409
   * @param text Another string to compare this one to.
sl@0
   410
   * @return a negative/zero/positive integer corresponding to whether
sl@0
   411
   * this string is less than/equal to/greater than the second one
sl@0
   412
   * in code point order
sl@0
   413
   * @stable ICU 2.0
sl@0
   414
   */
sl@0
   415
  inline int8_t compareCodePointOrder(const UnicodeString& text) const;
sl@0
   416
sl@0
   417
  /**
sl@0
   418
   * Compare two Unicode strings in code point order.
sl@0
   419
   * This is different in UTF-16 from how compare(), operator==, startsWith() etc. work
sl@0
   420
   * if supplementary characters are present:
sl@0
   421
   *
sl@0
   422
   * In UTF-16, supplementary characters (with code points U+10000 and above) are
sl@0
   423
   * stored with pairs of surrogate code units. These have values from 0xd800 to 0xdfff,
sl@0
   424
   * which means that they compare as less than some other BMP characters like U+feff.
sl@0
   425
   * This function compares Unicode strings in code point order.
sl@0
   426
   * If either of the UTF-16 strings is malformed (i.e., it contains unpaired surrogates), then the result is not defined.
sl@0
   427
   *
sl@0
   428
   * @param start The start offset in this string at which the compare operation begins.
sl@0
   429
   * @param length The number of code units from this string to compare.
sl@0
   430
   * @param srcText Another string to compare this one to.
sl@0
   431
   * @return a negative/zero/positive integer corresponding to whether
sl@0
   432
   * this string is less than/equal to/greater than the second one
sl@0
   433
   * in code point order
sl@0
   434
   * @stable ICU 2.0
sl@0
   435
   */
sl@0
   436
  inline int8_t compareCodePointOrder(int32_t start,
sl@0
   437
                                      int32_t length,
sl@0
   438
                                      const UnicodeString& srcText) const;
sl@0
   439
sl@0
   440
  /**
sl@0
   441
   * Compare two Unicode strings in code point order.
sl@0
   442
   * This is different in UTF-16 from how compare(), operator==, startsWith() etc. work
sl@0
   443
   * if supplementary characters are present:
sl@0
   444
   *
sl@0
   445
   * In UTF-16, supplementary characters (with code points U+10000 and above) are
sl@0
   446
   * stored with pairs of surrogate code units. These have values from 0xd800 to 0xdfff,
sl@0
   447
   * which means that they compare as less than some other BMP characters like U+feff.
sl@0
   448
   * This function compares Unicode strings in code point order.
sl@0
   449
   * If either of the UTF-16 strings is malformed (i.e., it contains unpaired surrogates), then the result is not defined.
sl@0
   450
   *
sl@0
   451
   * @param start The start offset in this string at which the compare operation begins.
sl@0
   452
   * @param length The number of code units from this string to compare.
sl@0
   453
   * @param srcText Another string to compare this one to.
sl@0
   454
   * @param srcStart The start offset in that string at which the compare operation begins.
sl@0
   455
   * @param srcLength The number of code units from that string to compare.
sl@0
   456
   * @return a negative/zero/positive integer corresponding to whether
sl@0
   457
   * this string is less than/equal to/greater than the second one
sl@0
   458
   * in code point order
sl@0
   459
   * @stable ICU 2.0
sl@0
   460
   */
sl@0
   461
   inline int8_t compareCodePointOrder(int32_t start,
sl@0
   462
                                       int32_t length,
sl@0
   463
                                       const UnicodeString& srcText,
sl@0
   464
                                       int32_t srcStart,
sl@0
   465
                                       int32_t srcLength) const;
sl@0
   466
sl@0
   467
  /**
sl@0
   468
   * Compare two Unicode strings in code point order.
sl@0
   469
   * This is different in UTF-16 from how compare(), operator==, startsWith() etc. work
sl@0
   470
   * if supplementary characters are present:
sl@0
   471
   *
sl@0
   472
   * In UTF-16, supplementary characters (with code points U+10000 and above) are
sl@0
   473
   * stored with pairs of surrogate code units. These have values from 0xd800 to 0xdfff,
sl@0
   474
   * which means that they compare as less than some other BMP characters like U+feff.
sl@0
   475
   * This function compares Unicode strings in code point order.
sl@0
   476
   * If either of the UTF-16 strings is malformed (i.e., it contains unpaired surrogates), then the result is not defined.
sl@0
   477
   *
sl@0
   478
   * @param srcChars A pointer to another string to compare this one to.
sl@0
   479
   * @param srcLength The number of code units from that string to compare.
sl@0
   480
   * @return a negative/zero/positive integer corresponding to whether
sl@0
   481
   * this string is less than/equal to/greater than the second one
sl@0
   482
   * in code point order
sl@0
   483
   * @stable ICU 2.0
sl@0
   484
   */
sl@0
   485
  inline int8_t compareCodePointOrder(const UChar *srcChars,
sl@0
   486
                                      int32_t srcLength) const;
sl@0
   487
sl@0
   488
  /**
sl@0
   489
   * Compare two Unicode strings in code point order.
sl@0
   490
   * This is different in UTF-16 from how compare(), operator==, startsWith() etc. work
sl@0
   491
   * if supplementary characters are present:
sl@0
   492
   *
sl@0
   493
   * In UTF-16, supplementary characters (with code points U+10000 and above) are
sl@0
   494
   * stored with pairs of surrogate code units. These have values from 0xd800 to 0xdfff,
sl@0
   495
   * which means that they compare as less than some other BMP characters like U+feff.
sl@0
   496
   * This function compares Unicode strings in code point order.
sl@0
   497
   * If either of the UTF-16 strings is malformed (i.e., it contains unpaired surrogates), then the result is not defined.
sl@0
   498
   *
sl@0
   499
   * @param start The start offset in this string at which the compare operation begins.
sl@0
   500
   * @param length The number of code units from this string to compare.
sl@0
   501
   * @param srcChars A pointer to another string to compare this one to.
sl@0
   502
   * @return a negative/zero/positive integer corresponding to whether
sl@0
   503
   * this string is less than/equal to/greater than the second one
sl@0
   504
   * in code point order
sl@0
   505
   * @stable ICU 2.0
sl@0
   506
   */
sl@0
   507
  inline int8_t compareCodePointOrder(int32_t start,
sl@0
   508
                                      int32_t length,
sl@0
   509
                                      const UChar *srcChars) const;
sl@0
   510
sl@0
   511
  /**
sl@0
   512
   * Compare two Unicode strings in code point order.
sl@0
   513
   * This is different in UTF-16 from how compare(), operator==, startsWith() etc. work
sl@0
   514
   * if supplementary characters are present:
sl@0
   515
   *
sl@0
   516
   * In UTF-16, supplementary characters (with code points U+10000 and above) are
sl@0
   517
   * stored with pairs of surrogate code units. These have values from 0xd800 to 0xdfff,
sl@0
   518
   * which means that they compare as less than some other BMP characters like U+feff.
sl@0
   519
   * This function compares Unicode strings in code point order.
sl@0
   520
   * If either of the UTF-16 strings is malformed (i.e., it contains unpaired surrogates), then the result is not defined.
sl@0
   521
   *
sl@0
   522
   * @param start The start offset in this string at which the compare operation begins.
sl@0
   523
   * @param length The number of code units from this string to compare.
sl@0
   524
   * @param srcChars A pointer to another string to compare this one to.
sl@0
   525
   * @param srcStart The start offset in that string at which the compare operation begins.
sl@0
   526
   * @param srcLength The number of code units from that string to compare.
sl@0
   527
   * @return a negative/zero/positive integer corresponding to whether
sl@0
   528
   * this string is less than/equal to/greater than the second one
sl@0
   529
   * in code point order
sl@0
   530
   * @stable ICU 2.0
sl@0
   531
   */
sl@0
   532
  inline int8_t compareCodePointOrder(int32_t start,
sl@0
   533
                                      int32_t length,
sl@0
   534
                                      const UChar *srcChars,
sl@0
   535
                                      int32_t srcStart,
sl@0
   536
                                      int32_t srcLength) const;
sl@0
   537
sl@0
   538
  /**
sl@0
   539
   * Compare two Unicode strings in code point order.
sl@0
   540
   * This is different in UTF-16 from how compare(), operator==, startsWith() etc. work
sl@0
   541
   * if supplementary characters are present:
sl@0
   542
   *
sl@0
   543
   * In UTF-16, supplementary characters (with code points U+10000 and above) are
sl@0
   544
   * stored with pairs of surrogate code units. These have values from 0xd800 to 0xdfff,
sl@0
   545
   * which means that they compare as less than some other BMP characters like U+feff.
sl@0
   546
   * This function compares Unicode strings in code point order.
sl@0
   547
   * If either of the UTF-16 strings is malformed (i.e., it contains unpaired surrogates), then the result is not defined.
sl@0
   548
   *
sl@0
   549
   * @param start The start offset in this string at which the compare operation begins.
sl@0
   550
   * @param limit The offset after the last code unit from this string to compare.
sl@0
   551
   * @param srcText Another string to compare this one to.
sl@0
   552
   * @param srcStart The start offset in that string at which the compare operation begins.
sl@0
   553
   * @param srcLimit The offset after the last code unit from that string to compare.
sl@0
   554
   * @return a negative/zero/positive integer corresponding to whether
sl@0
   555
   * this string is less than/equal to/greater than the second one
sl@0
   556
   * in code point order
sl@0
   557
   * @stable ICU 2.0
sl@0
   558
   */
sl@0
   559
  inline int8_t compareCodePointOrderBetween(int32_t start,
sl@0
   560
                                             int32_t limit,
sl@0
   561
                                             const UnicodeString& srcText,
sl@0
   562
                                             int32_t srcStart,
sl@0
   563
                                             int32_t srcLimit) const;
sl@0
   564
sl@0
   565
  /**
sl@0
   566
   * Compare two strings case-insensitively using full case folding.
sl@0
   567
   * This is equivalent to this->foldCase(options).compare(text.foldCase(options)).
sl@0
   568
   *
sl@0
   569
   * @param text Another string to compare this one to.
sl@0
   570
   * @param options A bit set of options:
sl@0
   571
   *   - U_FOLD_CASE_DEFAULT or 0 is used for default options:
sl@0
   572
   *     Comparison in code unit order with default case folding.
sl@0
   573
   *
sl@0
   574
   *   - U_COMPARE_CODE_POINT_ORDER
sl@0
   575
   *     Set to choose code point order instead of code unit order
sl@0
   576
   *     (see u_strCompare for details).
sl@0
   577
   *
sl@0
   578
   *   - U_FOLD_CASE_EXCLUDE_SPECIAL_I
sl@0
   579
   *
sl@0
   580
   * @return A negative, zero, or positive integer indicating the comparison result.
sl@0
   581
   * @stable ICU 2.0
sl@0
   582
   */
sl@0
   583
  inline int8_t caseCompare(const UnicodeString& text, uint32_t options) const;
sl@0
   584
sl@0
   585
  /**
sl@0
   586
   * Compare two strings case-insensitively using full case folding.
sl@0
   587
   * This is equivalent to this->foldCase(options).compare(srcText.foldCase(options)).
sl@0
   588
   *
sl@0
   589
   * @param start The start offset in this string at which the compare operation begins.
sl@0
   590
   * @param length The number of code units from this string to compare.
sl@0
   591
   * @param srcText Another string to compare this one to.
sl@0
   592
   * @param options A bit set of options:
sl@0
   593
   *   - U_FOLD_CASE_DEFAULT or 0 is used for default options:
sl@0
   594
   *     Comparison in code unit order with default case folding.
sl@0
   595
   *
sl@0
   596
   *   - U_COMPARE_CODE_POINT_ORDER
sl@0
   597
   *     Set to choose code point order instead of code unit order
sl@0
   598
   *     (see u_strCompare for details).
sl@0
   599
   *
sl@0
   600
   *   - U_FOLD_CASE_EXCLUDE_SPECIAL_I
sl@0
   601
   *
sl@0
   602
   * @return A negative, zero, or positive integer indicating the comparison result.
sl@0
   603
   * @stable ICU 2.0
sl@0
   604
   */
sl@0
   605
  inline int8_t caseCompare(int32_t start,
sl@0
   606
         int32_t length,
sl@0
   607
         const UnicodeString& srcText,
sl@0
   608
         uint32_t options) const;
sl@0
   609
sl@0
   610
  /**
sl@0
   611
   * Compare two strings case-insensitively using full case folding.
sl@0
   612
   * This is equivalent to this->foldCase(options).compare(srcText.foldCase(options)).
sl@0
   613
   *
sl@0
   614
   * @param start The start offset in this string at which the compare operation begins.
sl@0
   615
   * @param length The number of code units from this string to compare.
sl@0
   616
   * @param srcText Another string to compare this one to.
sl@0
   617
   * @param srcStart The start offset in that string at which the compare operation begins.
sl@0
   618
   * @param srcLength The number of code units from that string to compare.
sl@0
   619
   * @param options A bit set of options:
sl@0
   620
   *   - U_FOLD_CASE_DEFAULT or 0 is used for default options:
sl@0
   621
   *     Comparison in code unit order with default case folding.
sl@0
   622
   *
sl@0
   623
   *   - U_COMPARE_CODE_POINT_ORDER
sl@0
   624
   *     Set to choose code point order instead of code unit order
sl@0
   625
   *     (see u_strCompare for details).
sl@0
   626
   *
sl@0
   627
   *   - U_FOLD_CASE_EXCLUDE_SPECIAL_I
sl@0
   628
   *
sl@0
   629
   * @return A negative, zero, or positive integer indicating the comparison result.
sl@0
   630
   * @stable ICU 2.0
sl@0
   631
   */
sl@0
   632
  inline int8_t caseCompare(int32_t start,
sl@0
   633
         int32_t length,
sl@0
   634
         const UnicodeString& srcText,
sl@0
   635
         int32_t srcStart,
sl@0
   636
         int32_t srcLength,
sl@0
   637
         uint32_t options) const;
sl@0
   638
sl@0
   639
  /**
sl@0
   640
   * Compare two strings case-insensitively using full case folding.
sl@0
   641
   * This is equivalent to this->foldCase(options).compare(srcChars.foldCase(options)).
sl@0
   642
   *
sl@0
   643
   * @param srcChars A pointer to another string to compare this one to.
sl@0
   644
   * @param srcLength The number of code units from that string to compare.
sl@0
   645
   * @param options A bit set of options:
sl@0
   646
   *   - U_FOLD_CASE_DEFAULT or 0 is used for default options:
sl@0
   647
   *     Comparison in code unit order with default case folding.
sl@0
   648
   *
sl@0
   649
   *   - U_COMPARE_CODE_POINT_ORDER
sl@0
   650
   *     Set to choose code point order instead of code unit order
sl@0
   651
   *     (see u_strCompare for details).
sl@0
   652
   *
sl@0
   653
   *   - U_FOLD_CASE_EXCLUDE_SPECIAL_I
sl@0
   654
   *
sl@0
   655
   * @return A negative, zero, or positive integer indicating the comparison result.
sl@0
   656
   * @stable ICU 2.0
sl@0
   657
   */
sl@0
   658
  inline int8_t caseCompare(const UChar *srcChars,
sl@0
   659
         int32_t srcLength,
sl@0
   660
         uint32_t options) const;
sl@0
   661
sl@0
   662
  /**
sl@0
   663
   * Compare two strings case-insensitively using full case folding.
sl@0
   664
   * This is equivalent to this->foldCase(options).compare(srcChars.foldCase(options)).
sl@0
   665
   *
sl@0
   666
   * @param start The start offset in this string at which the compare operation begins.
sl@0
   667
   * @param length The number of code units from this string to compare.
sl@0
   668
   * @param srcChars A pointer to another string to compare this one to.
sl@0
   669
   * @param options A bit set of options:
sl@0
   670
   *   - U_FOLD_CASE_DEFAULT or 0 is used for default options:
sl@0
   671
   *     Comparison in code unit order with default case folding.
sl@0
   672
   *
sl@0
   673
   *   - U_COMPARE_CODE_POINT_ORDER
sl@0
   674
   *     Set to choose code point order instead of code unit order
sl@0
   675
   *     (see u_strCompare for details).
sl@0
   676
   *
sl@0
   677
   *   - U_FOLD_CASE_EXCLUDE_SPECIAL_I
sl@0
   678
   *
sl@0
   679
   * @return A negative, zero, or positive integer indicating the comparison result.
sl@0
   680
   * @stable ICU 2.0
sl@0
   681
   */
sl@0
   682
  inline int8_t caseCompare(int32_t start,
sl@0
   683
         int32_t length,
sl@0
   684
         const UChar *srcChars,
sl@0
   685
         uint32_t options) const;
sl@0
   686
sl@0
   687
  /**
sl@0
   688
   * Compare two strings case-insensitively using full case folding.
sl@0
   689
   * This is equivalent to this->foldCase(options).compare(srcChars.foldCase(options)).
sl@0
   690
   *
sl@0
   691
   * @param start The start offset in this string at which the compare operation begins.
sl@0
   692
   * @param length The number of code units from this string to compare.
sl@0
   693
   * @param srcChars A pointer to another string to compare this one to.
sl@0
   694
   * @param srcStart The start offset in that string at which the compare operation begins.
sl@0
   695
   * @param srcLength The number of code units from that string to compare.
sl@0
   696
   * @param options A bit set of options:
sl@0
   697
   *   - U_FOLD_CASE_DEFAULT or 0 is used for default options:
sl@0
   698
   *     Comparison in code unit order with default case folding.
sl@0
   699
   *
sl@0
   700
   *   - U_COMPARE_CODE_POINT_ORDER
sl@0
   701
   *     Set to choose code point order instead of code unit order
sl@0
   702
   *     (see u_strCompare for details).
sl@0
   703
   *
sl@0
   704
   *   - U_FOLD_CASE_EXCLUDE_SPECIAL_I
sl@0
   705
   *
sl@0
   706
   * @return A negative, zero, or positive integer indicating the comparison result.
sl@0
   707
   * @stable ICU 2.0
sl@0
   708
   */
sl@0
   709
  inline int8_t caseCompare(int32_t start,
sl@0
   710
         int32_t length,
sl@0
   711
         const UChar *srcChars,
sl@0
   712
         int32_t srcStart,
sl@0
   713
         int32_t srcLength,
sl@0
   714
         uint32_t options) const;
sl@0
   715
sl@0
   716
  /**
sl@0
   717
   * Compare two strings case-insensitively using full case folding.
sl@0
   718
   * This is equivalent to this->foldCase(options).compareBetween(text.foldCase(options)).
sl@0
   719
   *
sl@0
   720
   * @param start The start offset in this string at which the compare operation begins.
sl@0
   721
   * @param limit The offset after the last code unit from this string to compare.
sl@0
   722
   * @param srcText Another string to compare this one to.
sl@0
   723
   * @param srcStart The start offset in that string at which the compare operation begins.
sl@0
   724
   * @param srcLimit The offset after the last code unit from that string to compare.
sl@0
   725
   * @param options A bit set of options:
sl@0
   726
   *   - U_FOLD_CASE_DEFAULT or 0 is used for default options:
sl@0
   727
   *     Comparison in code unit order with default case folding.
sl@0
   728
   *
sl@0
   729
   *   - U_COMPARE_CODE_POINT_ORDER
sl@0
   730
   *     Set to choose code point order instead of code unit order
sl@0
   731
   *     (see u_strCompare for details).
sl@0
   732
   *
sl@0
   733
   *   - U_FOLD_CASE_EXCLUDE_SPECIAL_I
sl@0
   734
   *
sl@0
   735
   * @return A negative, zero, or positive integer indicating the comparison result.
sl@0
   736
   * @stable ICU 2.0
sl@0
   737
   */
sl@0
   738
  inline int8_t caseCompareBetween(int32_t start,
sl@0
   739
            int32_t limit,
sl@0
   740
            const UnicodeString& srcText,
sl@0
   741
            int32_t srcStart,
sl@0
   742
            int32_t srcLimit,
sl@0
   743
            uint32_t options) const;
sl@0
   744
sl@0
   745
  /**
sl@0
   746
   * Determine if this starts with the characters in <TT>text</TT>
sl@0
   747
   * @param text The text to match.
sl@0
   748
   * @return TRUE if this starts with the characters in <TT>text</TT>,
sl@0
   749
   * FALSE otherwise
sl@0
   750
   * @stable ICU 2.0
sl@0
   751
   */
sl@0
   752
  inline UBool startsWith(const UnicodeString& text) const;
sl@0
   753
sl@0
   754
  /**
sl@0
   755
   * Determine if this starts with the characters in <TT>srcText</TT>
sl@0
   756
   * in the range [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>).
sl@0
   757
   * @param srcText The text to match.
sl@0
   758
   * @param srcStart the offset into <TT>srcText</TT> to start matching
sl@0
   759
   * @param srcLength the number of characters in <TT>srcText</TT> to match
sl@0
   760
   * @return TRUE if this starts with the characters in <TT>text</TT>,
sl@0
   761
   * FALSE otherwise
sl@0
   762
   * @stable ICU 2.0
sl@0
   763
   */
sl@0
   764
  inline UBool startsWith(const UnicodeString& srcText,
sl@0
   765
            int32_t srcStart,
sl@0
   766
            int32_t srcLength) const;
sl@0
   767
sl@0
   768
  /**
sl@0
   769
   * Determine if this starts with the characters in <TT>srcChars</TT>
sl@0
   770
   * @param srcChars The characters to match.
sl@0
   771
   * @param srcLength the number of characters in <TT>srcChars</TT>
sl@0
   772
   * @return TRUE if this starts with the characters in <TT>srcChars</TT>,
sl@0
   773
   * FALSE otherwise
sl@0
   774
   * @stable ICU 2.0
sl@0
   775
   */
sl@0
   776
  inline UBool startsWith(const UChar *srcChars,
sl@0
   777
            int32_t srcLength) const;
sl@0
   778
sl@0
   779
  /**
sl@0
   780
   * Determine if this ends with the characters in <TT>srcChars</TT>
sl@0
   781
   * in the range  [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>).
sl@0
   782
   * @param srcChars The characters to match.
sl@0
   783
   * @param srcStart the offset into <TT>srcText</TT> to start matching
sl@0
   784
   * @param srcLength the number of characters in <TT>srcChars</TT> to match
sl@0
   785
   * @return TRUE if this ends with the characters in <TT>srcChars</TT>, FALSE otherwise
sl@0
   786
   * @stable ICU 2.0
sl@0
   787
   */
sl@0
   788
  inline UBool startsWith(const UChar *srcChars,
sl@0
   789
            int32_t srcStart,
sl@0
   790
            int32_t srcLength) const;
sl@0
   791
sl@0
   792
  /**
sl@0
   793
   * Determine if this ends with the characters in <TT>text</TT>
sl@0
   794
   * @param text The text to match.
sl@0
   795
   * @return TRUE if this ends with the characters in <TT>text</TT>,
sl@0
   796
   * FALSE otherwise
sl@0
   797
   * @stable ICU 2.0
sl@0
   798
   */
sl@0
   799
  inline UBool endsWith(const UnicodeString& text) const;
sl@0
   800
sl@0
   801
  /**
sl@0
   802
   * Determine if this ends with the characters in <TT>srcText</TT>
sl@0
   803
   * in the range [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>).
sl@0
   804
   * @param srcText The text to match.
sl@0
   805
   * @param srcStart the offset into <TT>srcText</TT> to start matching
sl@0
   806
   * @param srcLength the number of characters in <TT>srcText</TT> to match
sl@0
   807
   * @return TRUE if this ends with the characters in <TT>text</TT>,
sl@0
   808
   * FALSE otherwise
sl@0
   809
   * @stable ICU 2.0
sl@0
   810
   */
sl@0
   811
  inline UBool endsWith(const UnicodeString& srcText,
sl@0
   812
          int32_t srcStart,
sl@0
   813
          int32_t srcLength) const;
sl@0
   814
sl@0
   815
  /**
sl@0
   816
   * Determine if this ends with the characters in <TT>srcChars</TT>
sl@0
   817
   * @param srcChars The characters to match.
sl@0
   818
   * @param srcLength the number of characters in <TT>srcChars</TT>
sl@0
   819
   * @return TRUE if this ends with the characters in <TT>srcChars</TT>,
sl@0
   820
   * FALSE otherwise
sl@0
   821
   * @stable ICU 2.0
sl@0
   822
   */
sl@0
   823
  inline UBool endsWith(const UChar *srcChars,
sl@0
   824
          int32_t srcLength) const;
sl@0
   825
sl@0
   826
  /**
sl@0
   827
   * Determine if this ends with the characters in <TT>srcChars</TT>
sl@0
   828
   * in the range  [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>).
sl@0
   829
   * @param srcChars The characters to match.
sl@0
   830
   * @param srcStart the offset into <TT>srcText</TT> to start matching
sl@0
   831
   * @param srcLength the number of characters in <TT>srcChars</TT> to match
sl@0
   832
   * @return TRUE if this ends with the characters in <TT>srcChars</TT>,
sl@0
   833
   * FALSE otherwise
sl@0
   834
   * @stable ICU 2.0
sl@0
   835
   */
sl@0
   836
  inline UBool endsWith(const UChar *srcChars,
sl@0
   837
          int32_t srcStart,
sl@0
   838
          int32_t srcLength) const;
sl@0
   839
sl@0
   840
sl@0
   841
  /* Searching - bitwise only */
sl@0
   842
sl@0
   843
  /**
sl@0
   844
   * Locate in this the first occurrence of the characters in <TT>text</TT>,
sl@0
   845
   * using bitwise comparison.
sl@0
   846
   * @param text The text to search for.
sl@0
   847
   * @return The offset into this of the start of <TT>text</TT>,
sl@0
   848
   * or -1 if not found.
sl@0
   849
   * @stable ICU 2.0
sl@0
   850
   */
sl@0
   851
  inline int32_t indexOf(const UnicodeString& text) const;
sl@0
   852
sl@0
   853
  /**
sl@0
   854
   * Locate in this the first occurrence of the characters in <TT>text</TT>
sl@0
   855
   * starting at offset <TT>start</TT>, using bitwise comparison.
sl@0
   856
   * @param text The text to search for.
sl@0
   857
   * @param start The offset at which searching will start.
sl@0
   858
   * @return The offset into this of the start of <TT>text</TT>,
sl@0
   859
   * or -1 if not found.
sl@0
   860
   * @stable ICU 2.0
sl@0
   861
   */
sl@0
   862
  inline int32_t indexOf(const UnicodeString& text,
sl@0
   863
              int32_t start) const;
sl@0
   864
sl@0
   865
  /**
sl@0
   866
   * Locate in this the first occurrence in the range
sl@0
   867
   * [<TT>start</TT>, <TT>start + length</TT>) of the characters
sl@0
   868
   * in <TT>text</TT>, using bitwise comparison.
sl@0
   869
   * @param text The text to search for.
sl@0
   870
   * @param start The offset at which searching will start.
sl@0
   871
   * @param length The number of characters to search
sl@0
   872
   * @return The offset into this of the start of <TT>text</TT>,
sl@0
   873
   * or -1 if not found.
sl@0
   874
   * @stable ICU 2.0
sl@0
   875
   */
sl@0
   876
  inline int32_t indexOf(const UnicodeString& text,
sl@0
   877
              int32_t start,
sl@0
   878
              int32_t length) const;
sl@0
   879
sl@0
   880
  /**
sl@0
   881
   * Locate in this the first occurrence in the range
sl@0
   882
   * [<TT>start</TT>, <TT>start + length</TT>) of the characters
sl@0
   883
   *  in <TT>srcText</TT> in the range
sl@0
   884
   * [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>),
sl@0
   885
   * using bitwise comparison.
sl@0
   886
   * @param srcText The text to search for.
sl@0
   887
   * @param srcStart the offset into <TT>srcText</TT> at which
sl@0
   888
   * to start matching
sl@0
   889
   * @param srcLength the number of characters in <TT>srcText</TT> to match
sl@0
   890
   * @param start the offset into this at which to start matching
sl@0
   891
   * @param length the number of characters in this to search
sl@0
   892
   * @return The offset into this of the start of <TT>text</TT>,
sl@0
   893
   * or -1 if not found.
sl@0
   894
   * @stable ICU 2.0
sl@0
   895
   */
sl@0
   896
  inline int32_t indexOf(const UnicodeString& srcText,
sl@0
   897
              int32_t srcStart,
sl@0
   898
              int32_t srcLength,
sl@0
   899
              int32_t start,
sl@0
   900
              int32_t length) const;
sl@0
   901
sl@0
   902
  /**
sl@0
   903
   * Locate in this the first occurrence of the characters in
sl@0
   904
   * <TT>srcChars</TT>
sl@0
   905
   * starting at offset <TT>start</TT>, using bitwise comparison.
sl@0
   906
   * @param srcChars The text to search for.
sl@0
   907
   * @param srcLength the number of characters in <TT>srcChars</TT> to match
sl@0
   908
   * @param start the offset into this at which to start matching
sl@0
   909
   * @return The offset into this of the start of <TT>text</TT>,
sl@0
   910
   * or -1 if not found.
sl@0
   911
   * @stable ICU 2.0
sl@0
   912
   */
sl@0
   913
  inline int32_t indexOf(const UChar *srcChars,
sl@0
   914
              int32_t srcLength,
sl@0
   915
              int32_t start) const;
sl@0
   916
sl@0
   917
  /**
sl@0
   918
   * Locate in this the first occurrence in the range
sl@0
   919
   * [<TT>start</TT>, <TT>start + length</TT>) of the characters
sl@0
   920
   * in <TT>srcChars</TT>, using bitwise comparison.
sl@0
   921
   * @param srcChars The text to search for.
sl@0
   922
   * @param srcLength the number of characters in <TT>srcChars</TT>
sl@0
   923
   * @param start The offset at which searching will start.
sl@0
   924
   * @param length The number of characters to search
sl@0
   925
   * @return The offset into this of the start of <TT>srcChars</TT>,
sl@0
   926
   * or -1 if not found.
sl@0
   927
   * @stable ICU 2.0
sl@0
   928
   */
sl@0
   929
  inline int32_t indexOf(const UChar *srcChars,
sl@0
   930
              int32_t srcLength,
sl@0
   931
              int32_t start,
sl@0
   932
              int32_t length) const;
sl@0
   933
sl@0
   934
  /**
sl@0
   935
   * Locate in this the first occurrence in the range
sl@0
   936
   * [<TT>start</TT>, <TT>start + length</TT>) of the characters
sl@0
   937
   * in <TT>srcChars</TT> in the range
sl@0
   938
   * [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>),
sl@0
   939
   * using bitwise comparison.
sl@0
   940
   * @param srcChars The text to search for.
sl@0
   941
   * @param srcStart the offset into <TT>srcChars</TT> at which
sl@0
   942
   * to start matching
sl@0
   943
   * @param srcLength the number of characters in <TT>srcChars</TT> to match
sl@0
   944
   * @param start the offset into this at which to start matching
sl@0
   945
   * @param length the number of characters in this to search
sl@0
   946
   * @return The offset into this of the start of <TT>text</TT>,
sl@0
   947
   * or -1 if not found.
sl@0
   948
   * @stable ICU 2.0
sl@0
   949
   */
sl@0
   950
  int32_t indexOf(const UChar *srcChars,
sl@0
   951
              int32_t srcStart,
sl@0
   952
              int32_t srcLength,
sl@0
   953
              int32_t start,
sl@0
   954
              int32_t length) const;
sl@0
   955
sl@0
   956
  /**
sl@0
   957
   * Locate in this the first occurrence of the BMP code point <code>c</code>,
sl@0
   958
   * using bitwise comparison.
sl@0
   959
   * @param c The code unit to search for.
sl@0
   960
   * @return The offset into this of <TT>c</TT>, or -1 if not found.
sl@0
   961
   * @stable ICU 2.0
sl@0
   962
   */
sl@0
   963
  inline int32_t indexOf(UChar c) const;
sl@0
   964
sl@0
   965
  /**
sl@0
   966
   * Locate in this the first occurrence of the code point <TT>c</TT>,
sl@0
   967
   * using bitwise comparison.
sl@0
   968
   *
sl@0
   969
   * @param c The code point to search for.
sl@0
   970
   * @return The offset into this of <TT>c</TT>, or -1 if not found.
sl@0
   971
   * @stable ICU 2.0
sl@0
   972
   */
sl@0
   973
  inline int32_t indexOf(UChar32 c) const;
sl@0
   974
sl@0
   975
  /**
sl@0
   976
   * Locate in this the first occurrence of the BMP code point <code>c</code>,
sl@0
   977
   * starting at offset <TT>start</TT>, using bitwise comparison.
sl@0
   978
   * @param c The code unit to search for.
sl@0
   979
   * @param start The offset at which searching will start.
sl@0
   980
   * @return The offset into this of <TT>c</TT>, or -1 if not found.
sl@0
   981
   * @stable ICU 2.0
sl@0
   982
   */
sl@0
   983
  inline int32_t indexOf(UChar c,
sl@0
   984
              int32_t start) const;
sl@0
   985
sl@0
   986
  /**
sl@0
   987
   * Locate in this the first occurrence of the code point <TT>c</TT>
sl@0
   988
   * starting at offset <TT>start</TT>, using bitwise comparison.
sl@0
   989
   *
sl@0
   990
   * @param c The code point to search for.
sl@0
   991
   * @param start The offset at which searching will start.
sl@0
   992
   * @return The offset into this of <TT>c</TT>, or -1 if not found.
sl@0
   993
   * @stable ICU 2.0
sl@0
   994
   */
sl@0
   995
  inline int32_t indexOf(UChar32 c,
sl@0
   996
              int32_t start) const;
sl@0
   997
sl@0
   998
  /**
sl@0
   999
   * Locate in this the first occurrence of the BMP code point <code>c</code>
sl@0
  1000
   * in the range [<TT>start</TT>, <TT>start + length</TT>),
sl@0
  1001
   * using bitwise comparison.
sl@0
  1002
   * @param c The code unit to search for.
sl@0
  1003
   * @param start the offset into this at which to start matching
sl@0
  1004
   * @param length the number of characters in this to search
sl@0
  1005
   * @return The offset into this of <TT>c</TT>, or -1 if not found.
sl@0
  1006
   * @stable ICU 2.0
sl@0
  1007
   */
sl@0
  1008
  inline int32_t indexOf(UChar c,
sl@0
  1009
              int32_t start,
sl@0
  1010
              int32_t length) const;
sl@0
  1011
sl@0
  1012
  /**
sl@0
  1013
   * Locate in this the first occurrence of the code point <TT>c</TT>
sl@0
  1014
   * in the range [<TT>start</TT>, <TT>start + length</TT>),
sl@0
  1015
   * using bitwise comparison.
sl@0
  1016
   *
sl@0
  1017
   * @param c The code point to search for.
sl@0
  1018
   * @param start the offset into this at which to start matching
sl@0
  1019
   * @param length the number of characters in this to search
sl@0
  1020
   * @return The offset into this of <TT>c</TT>, or -1 if not found.
sl@0
  1021
   * @stable ICU 2.0
sl@0
  1022
   */
sl@0
  1023
  inline int32_t indexOf(UChar32 c,
sl@0
  1024
              int32_t start,
sl@0
  1025
              int32_t length) const;
sl@0
  1026
sl@0
  1027
  /**
sl@0
  1028
   * Locate in this the last occurrence of the characters in <TT>text</TT>,
sl@0
  1029
   * using bitwise comparison.
sl@0
  1030
   * @param text The text to search for.
sl@0
  1031
   * @return The offset into this of the start of <TT>text</TT>,
sl@0
  1032
   * or -1 if not found.
sl@0
  1033
   * @stable ICU 2.0
sl@0
  1034
   */
sl@0
  1035
  inline int32_t lastIndexOf(const UnicodeString& text) const;
sl@0
  1036
sl@0
  1037
  /**
sl@0
  1038
   * Locate in this the last occurrence of the characters in <TT>text</TT>
sl@0
  1039
   * starting at offset <TT>start</TT>, using bitwise comparison.
sl@0
  1040
   * @param text The text to search for.
sl@0
  1041
   * @param start The offset at which searching will start.
sl@0
  1042
   * @return The offset into this of the start of <TT>text</TT>,
sl@0
  1043
   * or -1 if not found.
sl@0
  1044
   * @stable ICU 2.0
sl@0
  1045
   */
sl@0
  1046
  inline int32_t lastIndexOf(const UnicodeString& text,
sl@0
  1047
              int32_t start) const;
sl@0
  1048
sl@0
  1049
  /**
sl@0
  1050
   * Locate in this the last occurrence in the range
sl@0
  1051
   * [<TT>start</TT>, <TT>start + length</TT>) of the characters
sl@0
  1052
   * in <TT>text</TT>, using bitwise comparison.
sl@0
  1053
   * @param text The text to search for.
sl@0
  1054
   * @param start The offset at which searching will start.
sl@0
  1055
   * @param length The number of characters to search
sl@0
  1056
   * @return The offset into this of the start of <TT>text</TT>,
sl@0
  1057
   * or -1 if not found.
sl@0
  1058
   * @stable ICU 2.0
sl@0
  1059
   */
sl@0
  1060
  inline int32_t lastIndexOf(const UnicodeString& text,
sl@0
  1061
              int32_t start,
sl@0
  1062
              int32_t length) const;
sl@0
  1063
sl@0
  1064
  /**
sl@0
  1065
   * Locate in this the last occurrence in the range
sl@0
  1066
   * [<TT>start</TT>, <TT>start + length</TT>) of the characters
sl@0
  1067
   * in <TT>srcText</TT> in the range
sl@0
  1068
   * [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>),
sl@0
  1069
   * using bitwise comparison.
sl@0
  1070
   * @param srcText The text to search for.
sl@0
  1071
   * @param srcStart the offset into <TT>srcText</TT> at which
sl@0
  1072
   * to start matching
sl@0
  1073
   * @param srcLength the number of characters in <TT>srcText</TT> to match
sl@0
  1074
   * @param start the offset into this at which to start matching
sl@0
  1075
   * @param length the number of characters in this to search
sl@0
  1076
   * @return The offset into this of the start of <TT>text</TT>,
sl@0
  1077
   * or -1 if not found.
sl@0
  1078
   * @stable ICU 2.0
sl@0
  1079
   */
sl@0
  1080
  inline int32_t lastIndexOf(const UnicodeString& srcText,
sl@0
  1081
              int32_t srcStart,
sl@0
  1082
              int32_t srcLength,
sl@0
  1083
              int32_t start,
sl@0
  1084
              int32_t length) const;
sl@0
  1085
sl@0
  1086
  /**
sl@0
  1087
   * Locate in this the last occurrence of the characters in <TT>srcChars</TT>
sl@0
  1088
   * starting at offset <TT>start</TT>, using bitwise comparison.
sl@0
  1089
   * @param srcChars The text to search for.
sl@0
  1090
   * @param srcLength the number of characters in <TT>srcChars</TT> to match
sl@0
  1091
   * @param start the offset into this at which to start matching
sl@0
  1092
   * @return The offset into this of the start of <TT>text</TT>,
sl@0
  1093
   * or -1 if not found.
sl@0
  1094
   * @stable ICU 2.0
sl@0
  1095
   */
sl@0
  1096
  inline int32_t lastIndexOf(const UChar *srcChars,
sl@0
  1097
              int32_t srcLength,
sl@0
  1098
              int32_t start) const;
sl@0
  1099
sl@0
  1100
  /**
sl@0
  1101
   * Locate in this the last occurrence in the range
sl@0
  1102
   * [<TT>start</TT>, <TT>start + length</TT>) of the characters
sl@0
  1103
   * in <TT>srcChars</TT>, using bitwise comparison.
sl@0
  1104
   * @param srcChars The text to search for.
sl@0
  1105
   * @param srcLength the number of characters in <TT>srcChars</TT>
sl@0
  1106
   * @param start The offset at which searching will start.
sl@0
  1107
   * @param length The number of characters to search
sl@0
  1108
   * @return The offset into this of the start of <TT>srcChars</TT>,
sl@0
  1109
   * or -1 if not found.
sl@0
  1110
   * @stable ICU 2.0
sl@0
  1111
   */
sl@0
  1112
  inline int32_t lastIndexOf(const UChar *srcChars,
sl@0
  1113
              int32_t srcLength,
sl@0
  1114
              int32_t start,
sl@0
  1115
              int32_t length) const;
sl@0
  1116
sl@0
  1117
  /**
sl@0
  1118
   * Locate in this the last occurrence in the range
sl@0
  1119
   * [<TT>start</TT>, <TT>start + length</TT>) of the characters
sl@0
  1120
   * in <TT>srcChars</TT> in the range
sl@0
  1121
   * [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>),
sl@0
  1122
   * using bitwise comparison.
sl@0
  1123
   * @param srcChars The text to search for.
sl@0
  1124
   * @param srcStart the offset into <TT>srcChars</TT> at which
sl@0
  1125
   * to start matching
sl@0
  1126
   * @param srcLength the number of characters in <TT>srcChars</TT> to match
sl@0
  1127
   * @param start the offset into this at which to start matching
sl@0
  1128
   * @param length the number of characters in this to search
sl@0
  1129
   * @return The offset into this of the start of <TT>text</TT>,
sl@0
  1130
   * or -1 if not found.
sl@0
  1131
   * @stable ICU 2.0
sl@0
  1132
   */
sl@0
  1133
  int32_t lastIndexOf(const UChar *srcChars,
sl@0
  1134
              int32_t srcStart,
sl@0
  1135
              int32_t srcLength,
sl@0
  1136
              int32_t start,
sl@0
  1137
              int32_t length) const;
sl@0
  1138
sl@0
  1139
  /**
sl@0
  1140
   * Locate in this the last occurrence of the BMP code point <code>c</code>,
sl@0
  1141
   * using bitwise comparison.
sl@0
  1142
   * @param c The code unit to search for.
sl@0
  1143
   * @return The offset into this of <TT>c</TT>, or -1 if not found.
sl@0
  1144
   * @stable ICU 2.0
sl@0
  1145
   */
sl@0
  1146
  inline int32_t lastIndexOf(UChar c) const;
sl@0
  1147
sl@0
  1148
  /**
sl@0
  1149
   * Locate in this the last occurrence of the code point <TT>c</TT>,
sl@0
  1150
   * using bitwise comparison.
sl@0
  1151
   *
sl@0
  1152
   * @param c The code point to search for.
sl@0
  1153
   * @return The offset into this of <TT>c</TT>, or -1 if not found.
sl@0
  1154
   * @stable ICU 2.0
sl@0
  1155
   */
sl@0
  1156
  inline int32_t lastIndexOf(UChar32 c) const;
sl@0
  1157
sl@0
  1158
  /**
sl@0
  1159
   * Locate in this the last occurrence of the BMP code point <code>c</code>
sl@0
  1160
   * starting at offset <TT>start</TT>, using bitwise comparison.
sl@0
  1161
   * @param c The code unit to search for.
sl@0
  1162
   * @param start The offset at which searching will start.
sl@0
  1163
   * @return The offset into this of <TT>c</TT>, or -1 if not found.
sl@0
  1164
   * @stable ICU 2.0
sl@0
  1165
   */
sl@0
  1166
  inline int32_t lastIndexOf(UChar c,
sl@0
  1167
              int32_t start) const;
sl@0
  1168
sl@0
  1169
  /**
sl@0
  1170
   * Locate in this the last occurrence of the code point <TT>c</TT>
sl@0
  1171
   * starting at offset <TT>start</TT>, using bitwise comparison.
sl@0
  1172
   *
sl@0
  1173
   * @param c The code point to search for.
sl@0
  1174
   * @param start The offset at which searching will start.
sl@0
  1175
   * @return The offset into this of <TT>c</TT>, or -1 if not found.
sl@0
  1176
   * @stable ICU 2.0
sl@0
  1177
   */
sl@0
  1178
  inline int32_t lastIndexOf(UChar32 c,
sl@0
  1179
              int32_t start) const;
sl@0
  1180
sl@0
  1181
  /**
sl@0
  1182
   * Locate in this the last occurrence of the BMP code point <code>c</code>
sl@0
  1183
   * in the range [<TT>start</TT>, <TT>start + length</TT>),
sl@0
  1184
   * using bitwise comparison.
sl@0
  1185
   * @param c The code unit to search for.
sl@0
  1186
   * @param start the offset into this at which to start matching
sl@0
  1187
   * @param length the number of characters in this to search
sl@0
  1188
   * @return The offset into this of <TT>c</TT>, or -1 if not found.
sl@0
  1189
   * @stable ICU 2.0
sl@0
  1190
   */
sl@0
  1191
  inline int32_t lastIndexOf(UChar c,
sl@0
  1192
              int32_t start,
sl@0
  1193
              int32_t length) const;
sl@0
  1194
sl@0
  1195
  /**
sl@0
  1196
   * Locate in this the last occurrence of the code point <TT>c</TT>
sl@0
  1197
   * in the range [<TT>start</TT>, <TT>start + length</TT>),
sl@0
  1198
   * using bitwise comparison.
sl@0
  1199
   *
sl@0
  1200
   * @param c The code point to search for.
sl@0
  1201
   * @param start the offset into this at which to start matching
sl@0
  1202
   * @param length the number of characters in this to search
sl@0
  1203
   * @return The offset into this of <TT>c</TT>, or -1 if not found.
sl@0
  1204
   * @stable ICU 2.0
sl@0
  1205
   */
sl@0
  1206
  inline int32_t lastIndexOf(UChar32 c,
sl@0
  1207
              int32_t start,
sl@0
  1208
              int32_t length) const;
sl@0
  1209
sl@0
  1210
sl@0
  1211
  /* Character access */
sl@0
  1212
sl@0
  1213
  /**
sl@0
  1214
   * Return the code unit at offset <tt>offset</tt>.
sl@0
  1215
   * If the offset is not valid (0..length()-1) then U+ffff is returned.
sl@0
  1216
   * @param offset a valid offset into the text
sl@0
  1217
   * @return the code unit at offset <tt>offset</tt>
sl@0
  1218
   *         or 0xffff if the offset is not valid for this string
sl@0
  1219
   * @stable ICU 2.0
sl@0
  1220
   */
sl@0
  1221
  inline UChar charAt(int32_t offset) const;
sl@0
  1222
sl@0
  1223
  /**
sl@0
  1224
   * Return the code unit at offset <tt>offset</tt>.
sl@0
  1225
   * If the offset is not valid (0..length()-1) then U+ffff is returned.
sl@0
  1226
   * @param offset a valid offset into the text
sl@0
  1227
   * @return the code unit at offset <tt>offset</tt>
sl@0
  1228
   * @stable ICU 2.0
sl@0
  1229
   */
sl@0
  1230
  inline UChar operator[] (int32_t offset) const;
sl@0
  1231
sl@0
  1232
  /**
sl@0
  1233
   * Return the code point that contains the code unit
sl@0
  1234
   * at offset <tt>offset</tt>.
sl@0
  1235
   * If the offset is not valid (0..length()-1) then U+ffff is returned.
sl@0
  1236
   * @param offset a valid offset into the text
sl@0
  1237
   * that indicates the text offset of any of the code units
sl@0
  1238
   * that will be assembled into a code point (21-bit value) and returned
sl@0
  1239
   * @return the code point of text at <tt>offset</tt>
sl@0
  1240
   *         or 0xffff if the offset is not valid for this string
sl@0
  1241
   * @stable ICU 2.0
sl@0
  1242
   */
sl@0
  1243
  inline UChar32 char32At(int32_t offset) const;
sl@0
  1244
sl@0
  1245
  /**
sl@0
  1246
   * Adjust a random-access offset so that
sl@0
  1247
   * it points to the beginning of a Unicode character.
sl@0
  1248
   * The offset that is passed in points to
sl@0
  1249
   * any code unit of a code point,
sl@0
  1250
   * while the returned offset will point to the first code unit
sl@0
  1251
   * of the same code point.
sl@0
  1252
   * In UTF-16, if the input offset points to a second surrogate
sl@0
  1253
   * of a surrogate pair, then the returned offset will point
sl@0
  1254
   * to the first surrogate.
sl@0
  1255
   * @param offset a valid offset into one code point of the text
sl@0
  1256
   * @return offset of the first code unit of the same code point
sl@0
  1257
   * @see U16_SET_CP_START
sl@0
  1258
   * @stable ICU 2.0
sl@0
  1259
   */
sl@0
  1260
  inline int32_t getChar32Start(int32_t offset) const;
sl@0
  1261
sl@0
  1262
  /**
sl@0
  1263
   * Adjust a random-access offset so that
sl@0
  1264
   * it points behind a Unicode character.
sl@0
  1265
   * The offset that is passed in points behind
sl@0
  1266
   * any code unit of a code point,
sl@0
  1267
   * while the returned offset will point behind the last code unit
sl@0
  1268
   * of the same code point.
sl@0
  1269
   * In UTF-16, if the input offset points behind the first surrogate
sl@0
  1270
   * (i.e., to the second surrogate)
sl@0
  1271
   * of a surrogate pair, then the returned offset will point
sl@0
  1272
   * behind the second surrogate (i.e., to the first surrogate).
sl@0
  1273
   * @param offset a valid offset after any code unit of a code point of the text
sl@0
  1274
   * @return offset of the first code unit after the same code point
sl@0
  1275
   * @see U16_SET_CP_LIMIT
sl@0
  1276
   * @stable ICU 2.0
sl@0
  1277
   */
sl@0
  1278
  inline int32_t getChar32Limit(int32_t offset) const;
sl@0
  1279
sl@0
  1280
  /**
sl@0
  1281
   * Move the code unit index along the string by delta code points.
sl@0
  1282
   * Interpret the input index as a code unit-based offset into the string,
sl@0
  1283
   * move the index forward or backward by delta code points, and
sl@0
  1284
   * return the resulting index.
sl@0
  1285
   * The input index should point to the first code unit of a code point,
sl@0
  1286
   * if there is more than one.
sl@0
  1287
   *
sl@0
  1288
   * Both input and output indexes are code unit-based as for all
sl@0
  1289
   * string indexes/offsets in ICU (and other libraries, like MBCS char*).
sl@0
  1290
   * If delta<0 then the index is moved backward (toward the start of the string).
sl@0
  1291
   * If delta>0 then the index is moved forward (toward the end of the string).
sl@0
  1292
   *
sl@0
  1293
   * This behaves like CharacterIterator::move32(delta, kCurrent).
sl@0
  1294
   *
sl@0
  1295
   * Behavior for out-of-bounds indexes:
sl@0
  1296
   * <code>moveIndex32</code> pins the input index to 0..length(), i.e.,
sl@0
  1297
   * if the input index<0 then it is pinned to 0;
sl@0
  1298
   * if it is index>length() then it is pinned to length().
sl@0
  1299
   * Afterwards, the index is moved by <code>delta</code> code points
sl@0
  1300
   * forward or backward,
sl@0
  1301
   * but no further backward than to 0 and no further forward than to length().
sl@0
  1302
   * The resulting index return value will be in between 0 and length(), inclusively.
sl@0
  1303
   *
sl@0
  1304
   * Examples:
sl@0
  1305
   * <pre>
sl@0
  1306
   * // s has code points 'a' U+10000 'b' U+10ffff U+2029
sl@0
  1307
   * UnicodeString s=UNICODE_STRING("a\\U00010000b\\U0010ffff\\u2029", 31).unescape();
sl@0
  1308
   *
sl@0
  1309
   * // initial index: position of U+10000
sl@0
  1310
   * int32_t index=1;
sl@0
  1311
   *
sl@0
  1312
   * // the following examples will all result in index==4, position of U+10ffff
sl@0
  1313
   *
sl@0
  1314
   * // skip 2 code points from some position in the string
sl@0
  1315
   * index=s.moveIndex32(index, 2); // skips U+10000 and 'b'
sl@0
  1316
   *
sl@0
  1317
   * // go to the 3rd code point from the start of s (0-based)
sl@0
  1318
   * index=s.moveIndex32(0, 3); // skips 'a', U+10000, and 'b'
sl@0
  1319
   *
sl@0
  1320
   * // go to the next-to-last code point of s
sl@0
  1321
   * index=s.moveIndex32(s.length(), -2); // backward-skips U+2029 and U+10ffff
sl@0
  1322
   * </pre>
sl@0
  1323
   *
sl@0
  1324
   * @param index input code unit index
sl@0
  1325
   * @param delta (signed) code point count to move the index forward or backward
sl@0
  1326
   *        in the string
sl@0
  1327
   * @return the resulting code unit index
sl@0
  1328
   * @stable ICU 2.0
sl@0
  1329
   */
sl@0
  1330
  int32_t moveIndex32(int32_t index, int32_t delta) const;
sl@0
  1331
sl@0
  1332
  /* Substring extraction */
sl@0
  1333
sl@0
  1334
  /**
sl@0
  1335
   * Copy the characters in the range
sl@0
  1336
   * [<tt>start</tt>, <tt>start + length</tt>) into the array <tt>dst</tt>,
sl@0
  1337
   * beginning at <tt>dstStart</tt>.
sl@0
  1338
   * If the string aliases to <code>dst</code> itself as an external buffer,
sl@0
  1339
   * then extract() will not copy the contents.
sl@0
  1340
   *
sl@0
  1341
   * @param start offset of first character which will be copied into the array
sl@0
  1342
   * @param length the number of characters to extract
sl@0
  1343
   * @param dst array in which to copy characters.  The length of <tt>dst</tt>
sl@0
  1344
   * must be at least (<tt>dstStart + length</tt>).
sl@0
  1345
   * @param dstStart the offset in <TT>dst</TT> where the first character
sl@0
  1346
   * will be extracted
sl@0
  1347
   * @stable ICU 2.0
sl@0
  1348
   */
sl@0
  1349
  inline void extract(int32_t start,
sl@0
  1350
           int32_t length,
sl@0
  1351
           UChar *dst,
sl@0
  1352
           int32_t dstStart = 0) const;
sl@0
  1353
sl@0
  1354
  /**
sl@0
  1355
   * Copy the contents of the string into dest.
sl@0
  1356
   * This is a convenience function that
sl@0
  1357
   * checks if there is enough space in dest,
sl@0
  1358
   * extracts the entire string if possible,
sl@0
  1359
   * and NUL-terminates dest if possible.
sl@0
  1360
   *
sl@0
  1361
   * If the string fits into dest but cannot be NUL-terminated
sl@0
  1362
   * (length()==destCapacity) then the error code is set to U_STRING_NOT_TERMINATED_WARNING.
sl@0
  1363
   * If the string itself does not fit into dest
sl@0
  1364
   * (length()>destCapacity) then the error code is set to U_BUFFER_OVERFLOW_ERROR.
sl@0
  1365
   *
sl@0
  1366
   * If the string aliases to <code>dest</code> itself as an external buffer,
sl@0
  1367
   * then extract() will not copy the contents.
sl@0
  1368
   *
sl@0
  1369
   * @param dest Destination string buffer.
sl@0
  1370
   * @param destCapacity Number of UChars available at dest.
sl@0
  1371
   * @param errorCode ICU error code.
sl@0
  1372
   * @return length()
sl@0
  1373
   * @stable ICU 2.0
sl@0
  1374
   */
sl@0
  1375
  int32_t
sl@0
  1376
  extract(UChar *dest, int32_t destCapacity,
sl@0
  1377
          UErrorCode &errorCode) const;
sl@0
  1378
sl@0
  1379
  /**
sl@0
  1380
   * Copy the characters in the range
sl@0
  1381
   * [<tt>start</tt>, <tt>start + length</tt>) into the  UnicodeString
sl@0
  1382
   * <tt>target</tt>.
sl@0
  1383
   * @param start offset of first character which will be copied
sl@0
  1384
   * @param length the number of characters to extract
sl@0
  1385
   * @param target UnicodeString into which to copy characters.
sl@0
  1386
   * @return A reference to <TT>target</TT>
sl@0
  1387
   * @stable ICU 2.0
sl@0
  1388
   */
sl@0
  1389
  inline void extract(int32_t start,
sl@0
  1390
           int32_t length,
sl@0
  1391
           UnicodeString& target) const;
sl@0
  1392
sl@0
  1393
  /**
sl@0
  1394
   * Copy the characters in the range [<tt>start</tt>, <tt>limit</tt>)
sl@0
  1395
   * into the array <tt>dst</tt>, beginning at <tt>dstStart</tt>.
sl@0
  1396
   * @param start offset of first character which will be copied into the array
sl@0
  1397
   * @param limit offset immediately following the last character to be copied
sl@0
  1398
   * @param dst array in which to copy characters.  The length of <tt>dst</tt>
sl@0
  1399
   * must be at least (<tt>dstStart + (limit - start)</tt>).
sl@0
  1400
   * @param dstStart the offset in <TT>dst</TT> where the first character
sl@0
  1401
   * will be extracted
sl@0
  1402
   * @stable ICU 2.0
sl@0
  1403
   */
sl@0
  1404
  inline void extractBetween(int32_t start,
sl@0
  1405
              int32_t limit,
sl@0
  1406
              UChar *dst,
sl@0
  1407
              int32_t dstStart = 0) const;
sl@0
  1408
sl@0
  1409
  /**
sl@0
  1410
   * Copy the characters in the range [<tt>start</tt>, <tt>limit</tt>)
sl@0
  1411
   * into the UnicodeString <tt>target</tt>.  Replaceable API.
sl@0
  1412
   * @param start offset of first character which will be copied
sl@0
  1413
   * @param limit offset immediately following the last character to be copied
sl@0
  1414
   * @param target UnicodeString into which to copy characters.
sl@0
  1415
   * @return A reference to <TT>target</TT>
sl@0
  1416
   * @stable ICU 2.0
sl@0
  1417
   */
sl@0
  1418
  virtual void extractBetween(int32_t start,
sl@0
  1419
              int32_t limit,
sl@0
  1420
              UnicodeString& target) const;
sl@0
  1421
sl@0
  1422
  /**
sl@0
  1423
   * Copy the characters in the range 
sl@0
  1424
   * [<tt>start</TT>, <tt>start + length</TT>) into an array of characters.
sl@0
  1425
   * All characters must be invariant (see utypes.h).
sl@0
  1426
   * Use US_INV as the last, signature-distinguishing parameter.
sl@0
  1427
   *
sl@0
  1428
   * This function does not write any more than <code>targetLength</code>
sl@0
  1429
   * characters but returns the length of the entire output string
sl@0
  1430
   * so that one can allocate a larger buffer and call the function again
sl@0
  1431
   * if necessary.
sl@0
  1432
   * The output string is NUL-terminated if possible.
sl@0
  1433
   *
sl@0
  1434
   * @param start offset of first character which will be copied
sl@0
  1435
   * @param startLength the number of characters to extract
sl@0
  1436
   * @param target the target buffer for extraction, can be NULL
sl@0
  1437
   *               if targetLength is 0
sl@0
  1438
   * @param targetCapacity the length of the target buffer
sl@0
  1439
   * @param inv Signature-distinguishing paramater, use US_INV.
sl@0
  1440
   * @return the output string length, not including the terminating NUL
sl@0
  1441
   * @draft ICU 3.2
sl@0
  1442
   */
sl@0
  1443
  int32_t extract(int32_t start,
sl@0
  1444
           int32_t startLength,
sl@0
  1445
           char *target,
sl@0
  1446
           int32_t targetCapacity,
sl@0
  1447
           enum EInvariant inv) const;
sl@0
  1448
sl@0
  1449
#if !UCONFIG_NO_CONVERSION
sl@0
  1450
sl@0
  1451
  /**
sl@0
  1452
   * Copy the characters in the range
sl@0
  1453
   * [<tt>start</TT>, <tt>start + length</TT>) into an array of characters
sl@0
  1454
   * in a specified codepage.
sl@0
  1455
   * The output string is NUL-terminated.
sl@0
  1456
   *
sl@0
  1457
   * Recommendation: For invariant-character strings use
sl@0
  1458
   * extract(int32_t start, int32_t length, char *target, int32_t targetCapacity, enum EInvariant inv) const
sl@0
  1459
   * because it avoids object code dependencies of UnicodeString on
sl@0
  1460
   * the conversion code.
sl@0
  1461
   *
sl@0
  1462
   * @param start offset of first character which will be copied
sl@0
  1463
   * @param startLength the number of characters to extract
sl@0
  1464
   * @param target the target buffer for extraction
sl@0
  1465
   * @param codepage the desired codepage for the characters.  0 has
sl@0
  1466
   * the special meaning of the default codepage
sl@0
  1467
   * If <code>codepage</code> is an empty string (<code>""</code>),
sl@0
  1468
   * then a simple conversion is performed on the codepage-invariant
sl@0
  1469
   * subset ("invariant characters") of the platform encoding. See utypes.h.
sl@0
  1470
   * If <TT>target</TT> is NULL, then the number of bytes required for
sl@0
  1471
   * <TT>target</TT> is returned. It is assumed that the target is big enough
sl@0
  1472
   * to fit all of the characters.
sl@0
  1473
   * @return the output string length, not including the terminating NUL
sl@0
  1474
   * @stable ICU 2.0
sl@0
  1475
   */
sl@0
  1476
  inline int32_t extract(int32_t start,
sl@0
  1477
                 int32_t startLength,
sl@0
  1478
                 char *target,
sl@0
  1479
                 const char *codepage = 0) const;
sl@0
  1480
sl@0
  1481
  /**
sl@0
  1482
   * Copy the characters in the range
sl@0
  1483
   * [<tt>start</TT>, <tt>start + length</TT>) into an array of characters
sl@0
  1484
   * in a specified codepage.
sl@0
  1485
   * This function does not write any more than <code>targetLength</code>
sl@0
  1486
   * characters but returns the length of the entire output string
sl@0
  1487
   * so that one can allocate a larger buffer and call the function again
sl@0
  1488
   * if necessary.
sl@0
  1489
   * The output string is NUL-terminated if possible.
sl@0
  1490
   *
sl@0
  1491
   * Recommendation: For invariant-character strings use
sl@0
  1492
   * extract(int32_t start, int32_t length, char *target, int32_t targetCapacity, enum EInvariant inv) const
sl@0
  1493
   * because it avoids object code dependencies of UnicodeString on
sl@0
  1494
   * the conversion code.
sl@0
  1495
   *
sl@0
  1496
   * @param start offset of first character which will be copied
sl@0
  1497
   * @param startLength the number of characters to extract
sl@0
  1498
   * @param target the target buffer for extraction
sl@0
  1499
   * @param targetLength the length of the target buffer
sl@0
  1500
   * @param codepage the desired codepage for the characters.  0 has
sl@0
  1501
   * the special meaning of the default codepage
sl@0
  1502
   * If <code>codepage</code> is an empty string (<code>""</code>),
sl@0
  1503
   * then a simple conversion is performed on the codepage-invariant
sl@0
  1504
   * subset ("invariant characters") of the platform encoding. See utypes.h.
sl@0
  1505
   * If <TT>target</TT> is NULL, then the number of bytes required for
sl@0
  1506
   * <TT>target</TT> is returned.
sl@0
  1507
   * @return the output string length, not including the terminating NUL
sl@0
  1508
   * @stable ICU 2.0
sl@0
  1509
   */
sl@0
  1510
  int32_t extract(int32_t start,
sl@0
  1511
           int32_t startLength,
sl@0
  1512
           char *target,
sl@0
  1513
           uint32_t targetLength,
sl@0
  1514
           const char *codepage = 0) const;
sl@0
  1515
sl@0
  1516
  /**
sl@0
  1517
   * Convert the UnicodeString into a codepage string using an existing UConverter.
sl@0
  1518
   * The output string is NUL-terminated if possible.
sl@0
  1519
   *
sl@0
  1520
   * This function avoids the overhead of opening and closing a converter if
sl@0
  1521
   * multiple strings are extracted.
sl@0
  1522
   *
sl@0
  1523
   * @param dest destination string buffer, can be NULL if destCapacity==0
sl@0
  1524
   * @param destCapacity the number of chars available at dest
sl@0
  1525
   * @param cnv the converter object to be used (ucnv_resetFromUnicode() will be called),
sl@0
  1526
   *        or NULL for the default converter
sl@0
  1527
   * @param errorCode normal ICU error code
sl@0
  1528
   * @return the length of the output string, not counting the terminating NUL;
sl@0
  1529
   *         if the length is greater than destCapacity, then the string will not fit
sl@0
  1530
   *         and a buffer of the indicated length would need to be passed in
sl@0
  1531
   * @stable ICU 2.0
sl@0
  1532
   */
sl@0
  1533
  int32_t extract(char *dest, int32_t destCapacity,
sl@0
  1534
                  UConverter *cnv,
sl@0
  1535
                  UErrorCode &errorCode) const;
sl@0
  1536
sl@0
  1537
#endif
sl@0
  1538
sl@0
  1539
  /* Length operations */
sl@0
  1540
sl@0
  1541
  /**
sl@0
  1542
   * Return the length of the UnicodeString object.
sl@0
  1543
   * The length is the number of UChar code units are in the UnicodeString.
sl@0
  1544
   * If you want the number of code points, please use countChar32().
sl@0
  1545
   * @return the length of the UnicodeString object
sl@0
  1546
   * @see countChar32
sl@0
  1547
   * @stable ICU 2.0
sl@0
  1548
   */
sl@0
  1549
  inline int32_t length(void) const;
sl@0
  1550
sl@0
  1551
  /**
sl@0
  1552
   * Count Unicode code points in the length UChar code units of the string.
sl@0
  1553
   * A code point may occupy either one or two UChar code units.
sl@0
  1554
   * Counting code points involves reading all code units.
sl@0
  1555
   *
sl@0
  1556
   * This functions is basically the inverse of moveIndex32().
sl@0
  1557
   *
sl@0
  1558
   * @param start the index of the first code unit to check
sl@0
  1559
   * @param length the number of UChar code units to check
sl@0
  1560
   * @return the number of code points in the specified code units
sl@0
  1561
   * @see length
sl@0
  1562
   * @stable ICU 2.0
sl@0
  1563
   */
sl@0
  1564
  int32_t
sl@0
  1565
  countChar32(int32_t start=0, int32_t length=INT32_MAX) const;
sl@0
  1566
sl@0
  1567
  /**
sl@0
  1568
   * Check if the length UChar code units of the string
sl@0
  1569
   * contain more Unicode code points than a certain number.
sl@0
  1570
   * This is more efficient than counting all code points in this part of the string
sl@0
  1571
   * and comparing that number with a threshold.
sl@0
  1572
   * This function may not need to scan the string at all if the length
sl@0
  1573
   * falls within a certain range, and
sl@0
  1574
   * never needs to count more than 'number+1' code points.
sl@0
  1575
   * Logically equivalent to (countChar32(start, length)>number).
sl@0
  1576
   * A Unicode code point may occupy either one or two UChar code units.
sl@0
  1577
   *
sl@0
  1578
   * @param start the index of the first code unit to check (0 for the entire string)
sl@0
  1579
   * @param length the number of UChar code units to check
sl@0
  1580
   *               (use INT32_MAX for the entire string; remember that start/length
sl@0
  1581
   *                values are pinned)
sl@0
  1582
   * @param number The number of code points in the (sub)string is compared against
sl@0
  1583
   *               the 'number' parameter.
sl@0
  1584
   * @return Boolean value for whether the string contains more Unicode code points
sl@0
  1585
   *         than 'number'. Same as (u_countChar32(s, length)>number).
sl@0
  1586
   * @see countChar32
sl@0
  1587
   * @see u_strHasMoreChar32Than
sl@0
  1588
   * @stable ICU 2.4
sl@0
  1589
   */
sl@0
  1590
  UBool
sl@0
  1591
  hasMoreChar32Than(int32_t start, int32_t length, int32_t number) const;
sl@0
  1592
sl@0
  1593
  /**
sl@0
  1594
   * Determine if this string is empty.
sl@0
  1595
   * @return TRUE if this string contains 0 characters, FALSE otherwise.
sl@0
  1596
   * @stable ICU 2.0
sl@0
  1597
   */
sl@0
  1598
  inline UBool isEmpty(void) const;
sl@0
  1599
sl@0
  1600
  /**
sl@0
  1601
   * Return the capacity of the internal buffer of the UnicodeString object.
sl@0
  1602
   * This is useful together with the getBuffer functions.
sl@0
  1603
   * See there for details.
sl@0
  1604
   *
sl@0
  1605
   * @return the number of UChars available in the internal buffer
sl@0
  1606
   * @see getBuffer
sl@0
  1607
   * @stable ICU 2.0
sl@0
  1608
   */
sl@0
  1609
  inline int32_t getCapacity(void) const;
sl@0
  1610
sl@0
  1611
  /* Other operations */
sl@0
  1612
sl@0
  1613
  /**
sl@0
  1614
   * Generate a hash code for this object.
sl@0
  1615
   * @return The hash code of this UnicodeString.
sl@0
  1616
   * @stable ICU 2.0
sl@0
  1617
   */
sl@0
  1618
  inline int32_t hashCode(void) const;
sl@0
  1619
sl@0
  1620
  /**
sl@0
  1621
   * Determine if this object contains a valid string.
sl@0
  1622
   * A bogus string has no value. It is different from an empty string.
sl@0
  1623
   * It can be used to indicate that no string value is available.
sl@0
  1624
   * getBuffer() and getTerminatedBuffer() return NULL, and
sl@0
  1625
   * length() returns 0.
sl@0
  1626
   *
sl@0
  1627
   * @return TRUE if the string is valid, FALSE otherwise
sl@0
  1628
   * @see setToBogus()
sl@0
  1629
   * @stable ICU 2.0
sl@0
  1630
   */
sl@0
  1631
  inline UBool isBogus(void) const;
sl@0
  1632
sl@0
  1633
sl@0
  1634
  //========================================
sl@0
  1635
  // Write operations
sl@0
  1636
  //========================================
sl@0
  1637
sl@0
  1638
  /* Assignment operations */
sl@0
  1639
sl@0
  1640
  /**
sl@0
  1641
   * Assignment operator.  Replace the characters in this UnicodeString
sl@0
  1642
   * with the characters from <TT>srcText</TT>.
sl@0
  1643
   * @param srcText The text containing the characters to replace
sl@0
  1644
   * @return a reference to this
sl@0
  1645
   * @stable ICU 2.0
sl@0
  1646
   */
sl@0
  1647
  UnicodeString &operator=(const UnicodeString &srcText);
sl@0
  1648
sl@0
  1649
  /**
sl@0
  1650
   * Almost the same as the assignment operator.
sl@0
  1651
   * Replace the characters in this UnicodeString
sl@0
  1652
   * with the characters from <code>srcText</code>.
sl@0
  1653
   *
sl@0
  1654
   * This function works the same for all strings except for ones that
sl@0
  1655
   * are readonly aliases.
sl@0
  1656
   * Starting with ICU 2.4, the assignment operator and the copy constructor
sl@0
  1657
   * allocate a new buffer and copy the buffer contents even for readonly aliases.
sl@0
  1658
   * This function implements the old, more efficient but less safe behavior
sl@0
  1659
   * of making this string also a readonly alias to the same buffer.
sl@0
  1660
   * The fastCopyFrom function must be used only if it is known that the lifetime of
sl@0
  1661
   * this UnicodeString is at least as long as the lifetime of the aliased buffer
sl@0
  1662
   * including its contents, for example for strings from resource bundles
sl@0
  1663
   * or aliases to string contents.
sl@0
  1664
   *
sl@0
  1665
   * @param src The text containing the characters to replace.
sl@0
  1666
   * @return a reference to this
sl@0
  1667
   * @stable ICU 2.4
sl@0
  1668
   */
sl@0
  1669
  UnicodeString &fastCopyFrom(const UnicodeString &src);
sl@0
  1670
sl@0
  1671
  /**
sl@0
  1672
   * Assignment operator.  Replace the characters in this UnicodeString
sl@0
  1673
   * with the code unit <TT>ch</TT>.
sl@0
  1674
   * @param ch the code unit to replace
sl@0
  1675
   * @return a reference to this
sl@0
  1676
   * @stable ICU 2.0
sl@0
  1677
   */
sl@0
  1678
  inline UnicodeString& operator= (UChar ch);
sl@0
  1679
sl@0
  1680
  /**
sl@0
  1681
   * Assignment operator.  Replace the characters in this UnicodeString
sl@0
  1682
   * with the code point <TT>ch</TT>.
sl@0
  1683
   * @param ch the code point to replace
sl@0
  1684
   * @return a reference to this
sl@0
  1685
   * @stable ICU 2.0
sl@0
  1686
   */
sl@0
  1687
  inline UnicodeString& operator= (UChar32 ch);
sl@0
  1688
sl@0
  1689
  /**
sl@0
  1690
   * Set the text in the UnicodeString object to the characters
sl@0
  1691
   * in <TT>srcText</TT> in the range
sl@0
  1692
   * [<TT>srcStart</TT>, <TT>srcText.length()</TT>).
sl@0
  1693
   * <TT>srcText</TT> is not modified.
sl@0
  1694
   * @param srcText the source for the new characters
sl@0
  1695
   * @param srcStart the offset into <TT>srcText</TT> where new characters
sl@0
  1696
   * will be obtained
sl@0
  1697
   * @return a reference to this
sl@0
  1698
   * @stable ICU 2.2
sl@0
  1699
   */
sl@0
  1700
  inline UnicodeString& setTo(const UnicodeString& srcText,
sl@0
  1701
               int32_t srcStart);
sl@0
  1702
sl@0
  1703
  /**
sl@0
  1704
   * Set the text in the UnicodeString object to the characters
sl@0
  1705
   * in <TT>srcText</TT> in the range
sl@0
  1706
   * [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>).
sl@0
  1707
   * <TT>srcText</TT> is not modified.
sl@0
  1708
   * @param srcText the source for the new characters
sl@0
  1709
   * @param srcStart the offset into <TT>srcText</TT> where new characters
sl@0
  1710
   * will be obtained
sl@0
  1711
   * @param srcLength the number of characters in <TT>srcText</TT> in the
sl@0
  1712
   * replace string.
sl@0
  1713
   * @return a reference to this
sl@0
  1714
   * @stable ICU 2.0
sl@0
  1715
   */
sl@0
  1716
  inline UnicodeString& setTo(const UnicodeString& srcText,
sl@0
  1717
               int32_t srcStart,
sl@0
  1718
               int32_t srcLength);
sl@0
  1719
sl@0
  1720
  /**
sl@0
  1721
   * Set the text in the UnicodeString object to the characters in
sl@0
  1722
   * <TT>srcText</TT>.
sl@0
  1723
   * <TT>srcText</TT> is not modified.
sl@0
  1724
   * @param srcText the source for the new characters
sl@0
  1725
   * @return a reference to this
sl@0
  1726
   * @stable ICU 2.0
sl@0
  1727
   */
sl@0
  1728
  inline UnicodeString& setTo(const UnicodeString& srcText);
sl@0
  1729
sl@0
  1730
  /**
sl@0
  1731
   * Set the characters in the UnicodeString object to the characters
sl@0
  1732
   * in <TT>srcChars</TT>. <TT>srcChars</TT> is not modified.
sl@0
  1733
   * @param srcChars the source for the new characters
sl@0
  1734
   * @param srcLength the number of Unicode characters in srcChars.
sl@0
  1735
   * @return a reference to this
sl@0
  1736
   * @stable ICU 2.0
sl@0
  1737
   */
sl@0
  1738
  inline UnicodeString& setTo(const UChar *srcChars,
sl@0
  1739
               int32_t srcLength);
sl@0
  1740
sl@0
  1741
  /**
sl@0
  1742
   * Set the characters in the UnicodeString object to the code unit
sl@0
  1743
   * <TT>srcChar</TT>.
sl@0
  1744
   * @param srcChar the code unit which becomes the UnicodeString's character
sl@0
  1745
   * content
sl@0
  1746
   * @return a reference to this
sl@0
  1747
   * @stable ICU 2.0
sl@0
  1748
   */
sl@0
  1749
  UnicodeString& setTo(UChar srcChar);
sl@0
  1750
sl@0
  1751
  /**
sl@0
  1752
   * Set the characters in the UnicodeString object to the code point
sl@0
  1753
   * <TT>srcChar</TT>.
sl@0
  1754
   * @param srcChar the code point which becomes the UnicodeString's character
sl@0
  1755
   * content
sl@0
  1756
   * @return a reference to this
sl@0
  1757
   * @stable ICU 2.0
sl@0
  1758
   */
sl@0
  1759
  UnicodeString& setTo(UChar32 srcChar);
sl@0
  1760
sl@0
  1761
  /**
sl@0
  1762
   * Aliasing setTo() function, analogous to the readonly-aliasing UChar* constructor.
sl@0
  1763
   * The text will be used for the UnicodeString object, but
sl@0
  1764
   * it will not be released when the UnicodeString is destroyed.
sl@0
  1765
   * This has copy-on-write semantics:
sl@0
  1766
   * When the string is modified, then the buffer is first copied into
sl@0
  1767
   * newly allocated memory.
sl@0
  1768
   * The aliased buffer is never modified.
sl@0
  1769
   * In an assignment to another UnicodeString, the text will be aliased again,
sl@0
  1770
   * so that both strings then alias the same readonly-text.
sl@0
  1771
   *
sl@0
  1772
   * @param isTerminated specifies if <code>text</code> is <code>NUL</code>-terminated.
sl@0
  1773
   *                     This must be true if <code>textLength==-1</code>.
sl@0
  1774
   * @param text The characters to alias for the UnicodeString.
sl@0
  1775
   * @param textLength The number of Unicode characters in <code>text</code> to alias.
sl@0
  1776
   *                   If -1, then this constructor will determine the length
sl@0
  1777
   *                   by calling <code>u_strlen()</code>.
sl@0
  1778
   * @return a reference to this
sl@0
  1779
   * @stable ICU 2.0
sl@0
  1780
   */
sl@0
  1781
  UnicodeString &setTo(UBool isTerminated,
sl@0
  1782
                       const UChar *text,
sl@0
  1783
                       int32_t textLength);
sl@0
  1784
sl@0
  1785
  /**
sl@0
  1786
   * Aliasing setTo() function, analogous to the writable-aliasing UChar* constructor.
sl@0
  1787
   * The text will be used for the UnicodeString object, but
sl@0
  1788
   * it will not be released when the UnicodeString is destroyed.
sl@0
  1789
   * This has write-through semantics:
sl@0
  1790
   * For as long as the capacity of the buffer is sufficient, write operations
sl@0
  1791
   * will directly affect the buffer. When more capacity is necessary, then
sl@0
  1792
   * a new buffer will be allocated and the contents copied as with regularly
sl@0
  1793
   * constructed strings.
sl@0
  1794
   * In an assignment to another UnicodeString, the buffer will be copied.
sl@0
  1795
   * The extract(UChar *dst) function detects whether the dst pointer is the same
sl@0
  1796
   * as the string buffer itself and will in this case not copy the contents.
sl@0
  1797
   *
sl@0
  1798
   * @param buffer The characters to alias for the UnicodeString.
sl@0
  1799
   * @param buffLength The number of Unicode characters in <code>buffer</code> to alias.
sl@0
  1800
   * @param buffCapacity The size of <code>buffer</code> in UChars.
sl@0
  1801
   * @return a reference to this
sl@0
  1802
   * @stable ICU 2.0
sl@0
  1803
   */
sl@0
  1804
  UnicodeString &setTo(UChar *buffer,
sl@0
  1805
                       int32_t buffLength,
sl@0
  1806
                       int32_t buffCapacity);
sl@0
  1807
sl@0
  1808
  /**
sl@0
  1809
   * Make this UnicodeString object invalid.
sl@0
  1810
   * The string will test TRUE with isBogus().
sl@0
  1811
   *
sl@0
  1812
   * A bogus string has no value. It is different from an empty string.
sl@0
  1813
   * It can be used to indicate that no string value is available.
sl@0
  1814
   * getBuffer() and getTerminatedBuffer() return NULL, and
sl@0
  1815
   * length() returns 0.
sl@0
  1816
   *
sl@0
  1817
   * This utility function is used throughout the UnicodeString
sl@0
  1818
   * implementation to indicate that a UnicodeString operation failed,
sl@0
  1819
   * and may be used in other functions,
sl@0
  1820
   * especially but not exclusively when such functions do not
sl@0
  1821
   * take a UErrorCode for simplicity.
sl@0
  1822
   *
sl@0
  1823
   * The following methods, and no others, will clear a string object's bogus flag:
sl@0
  1824
   * - remove()
sl@0
  1825
   * - remove(0, INT32_MAX)
sl@0
  1826
   * - truncate(0)
sl@0
  1827
   * - operator=() (assignment operator)
sl@0
  1828
   * - setTo(...)
sl@0
  1829
   *
sl@0
  1830
   * The simplest ways to turn a bogus string into an empty one
sl@0
  1831
   * is to use the remove() function.
sl@0
  1832
   * Examples for other functions that are equivalent to "set to empty string":
sl@0
  1833
   * \code
sl@0
  1834
   * if(s.isBogus()) {
sl@0
  1835
   *   s.remove();           // set to an empty string (remove all), or
sl@0
  1836
   *   s.remove(0, INT32_MAX); // set to an empty string (remove all), or
sl@0
  1837
   *   s.truncate(0);        // set to an empty string (complete truncation), or
sl@0
  1838
   *   s=UnicodeString();    // assign an empty string, or
sl@0
  1839
   *   s.setTo((UChar32)-1); // set to a pseudo code point that is out of range, or
sl@0
  1840
   *   static const UChar nul=0;
sl@0
  1841
   *   s.setTo(&nul, 0);     // set to an empty C Unicode string
sl@0
  1842
   * }
sl@0
  1843
   * \endcode
sl@0
  1844
   *
sl@0
  1845
   * @see isBogus()
sl@0
  1846
   * @stable ICU 2.0
sl@0
  1847
   */
sl@0
  1848
  void setToBogus();
sl@0
  1849
sl@0
  1850
  /**
sl@0
  1851
   * Set the character at the specified offset to the specified character.
sl@0
  1852
   * @param offset A valid offset into the text of the character to set
sl@0
  1853
   * @param ch The new character
sl@0
  1854
   * @return A reference to this
sl@0
  1855
   * @stable ICU 2.0
sl@0
  1856
   */
sl@0
  1857
  UnicodeString& setCharAt(int32_t offset,
sl@0
  1858
               UChar ch);
sl@0
  1859
sl@0
  1860
sl@0
  1861
  /* Append operations */
sl@0
  1862
sl@0
  1863
  /**
sl@0
  1864
   * Append operator. Append the code unit <TT>ch</TT> to the UnicodeString
sl@0
  1865
   * object.
sl@0
  1866
   * @param ch the code unit to be appended
sl@0
  1867
   * @return a reference to this
sl@0
  1868
   * @stable ICU 2.0
sl@0
  1869
   */
sl@0
  1870
 inline  UnicodeString& operator+= (UChar ch);
sl@0
  1871
sl@0
  1872
  /**
sl@0
  1873
   * Append operator. Append the code point <TT>ch</TT> to the UnicodeString
sl@0
  1874
   * object.
sl@0
  1875
   * @param ch the code point to be appended
sl@0
  1876
   * @return a reference to this
sl@0
  1877
   * @stable ICU 2.0
sl@0
  1878
   */
sl@0
  1879
 inline  UnicodeString& operator+= (UChar32 ch);
sl@0
  1880
sl@0
  1881
  /**
sl@0
  1882
   * Append operator. Append the characters in <TT>srcText</TT> to the
sl@0
  1883
   * UnicodeString object at offset <TT>start</TT>. <TT>srcText</TT> is
sl@0
  1884
   * not modified.
sl@0
  1885
   * @param srcText the source for the new characters
sl@0
  1886
   * @return a reference to this
sl@0
  1887
   * @stable ICU 2.0
sl@0
  1888
   */
sl@0
  1889
  inline UnicodeString& operator+= (const UnicodeString& srcText);
sl@0
  1890
sl@0
  1891
  /**
sl@0
  1892
   * Append the characters
sl@0
  1893
   * in <TT>srcText</TT> in the range
sl@0
  1894
   * [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>) to the
sl@0
  1895
   * UnicodeString object at offset <TT>start</TT>. <TT>srcText</TT>
sl@0
  1896
   * is not modified.
sl@0
  1897
   * @param srcText the source for the new characters
sl@0
  1898
   * @param srcStart the offset into <TT>srcText</TT> where new characters
sl@0
  1899
   * will be obtained
sl@0
  1900
   * @param srcLength the number of characters in <TT>srcText</TT> in
sl@0
  1901
   * the append string
sl@0
  1902
   * @return a reference to this
sl@0
  1903
   * @stable ICU 2.0
sl@0
  1904
   */
sl@0
  1905
  inline UnicodeString& append(const UnicodeString& srcText,
sl@0
  1906
            int32_t srcStart,
sl@0
  1907
            int32_t srcLength);
sl@0
  1908
sl@0
  1909
  /**
sl@0
  1910
   * Append the characters in <TT>srcText</TT> to the UnicodeString object at
sl@0
  1911
   * offset <TT>start</TT>. <TT>srcText</TT> is not modified.
sl@0
  1912
   * @param srcText the source for the new characters
sl@0
  1913
   * @return a reference to this
sl@0
  1914
   * @stable ICU 2.0
sl@0
  1915
   */
sl@0
  1916
  inline UnicodeString& append(const UnicodeString& srcText);
sl@0
  1917
sl@0
  1918
  /**
sl@0
  1919
   * Append the characters in <TT>srcChars</TT> in the range
sl@0
  1920
   * [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>) to the UnicodeString
sl@0
  1921
   * object at offset
sl@0
  1922
   * <TT>start</TT>. <TT>srcChars</TT> is not modified.
sl@0
  1923
   * @param srcChars the source for the new characters
sl@0
  1924
   * @param srcStart the offset into <TT>srcChars</TT> where new characters
sl@0
  1925
   * will be obtained
sl@0
  1926
   * @param srcLength the number of characters in <TT>srcChars</TT> in
sl@0
  1927
   * the append string
sl@0
  1928
   * @return a reference to this
sl@0
  1929
   * @stable ICU 2.0
sl@0
  1930
   */
sl@0
  1931
  inline UnicodeString& append(const UChar *srcChars,
sl@0
  1932
            int32_t srcStart,
sl@0
  1933
            int32_t srcLength);
sl@0
  1934
sl@0
  1935
  /**
sl@0
  1936
   * Append the characters in <TT>srcChars</TT> to the UnicodeString object
sl@0
  1937
   * at offset <TT>start</TT>. <TT>srcChars</TT> is not modified.
sl@0
  1938
   * @param srcChars the source for the new characters
sl@0
  1939
   * @param srcLength the number of Unicode characters in <TT>srcChars</TT>
sl@0
  1940
   * @return a reference to this
sl@0
  1941
   * @stable ICU 2.0
sl@0
  1942
   */
sl@0
  1943
  inline UnicodeString& append(const UChar *srcChars,
sl@0
  1944
            int32_t srcLength);
sl@0
  1945
sl@0
  1946
  /**
sl@0
  1947
   * Append the code unit <TT>srcChar</TT> to the UnicodeString object.
sl@0
  1948
   * @param srcChar the code unit to append
sl@0
  1949
   * @return a reference to this
sl@0
  1950
   * @stable ICU 2.0
sl@0
  1951
   */
sl@0
  1952
  inline UnicodeString& append(UChar srcChar);
sl@0
  1953
sl@0
  1954
  /**
sl@0
  1955
   * Append the code point <TT>srcChar</TT> to the UnicodeString object.
sl@0
  1956
   * @param srcChar the code point to append
sl@0
  1957
   * @return a reference to this
sl@0
  1958
   * @stable ICU 2.0
sl@0
  1959
   */
sl@0
  1960
  inline UnicodeString& append(UChar32 srcChar);
sl@0
  1961
sl@0
  1962
sl@0
  1963
  /* Insert operations */
sl@0
  1964
sl@0
  1965
  /**
sl@0
  1966
   * Insert the characters in <TT>srcText</TT> in the range
sl@0
  1967
   * [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>) into the UnicodeString
sl@0
  1968
   * object at offset <TT>start</TT>. <TT>srcText</TT> is not modified.
sl@0
  1969
   * @param start the offset where the insertion begins
sl@0
  1970
   * @param srcText the source for the new characters
sl@0
  1971
   * @param srcStart the offset into <TT>srcText</TT> where new characters
sl@0
  1972
   * will be obtained
sl@0
  1973
   * @param srcLength the number of characters in <TT>srcText</TT> in
sl@0
  1974
   * the insert string
sl@0
  1975
   * @return a reference to this
sl@0
  1976
   * @stable ICU 2.0
sl@0
  1977
   */
sl@0
  1978
  inline UnicodeString& insert(int32_t start,
sl@0
  1979
            const UnicodeString& srcText,
sl@0
  1980
            int32_t srcStart,
sl@0
  1981
            int32_t srcLength);
sl@0
  1982
sl@0
  1983
  /**
sl@0
  1984
   * Insert the characters in <TT>srcText</TT> into the UnicodeString object
sl@0
  1985
   * at offset <TT>start</TT>. <TT>srcText</TT> is not modified.
sl@0
  1986
   * @param start the offset where the insertion begins
sl@0
  1987
   * @param srcText the source for the new characters
sl@0
  1988
   * @return a reference to this
sl@0
  1989
   * @stable ICU 2.0
sl@0
  1990
   */
sl@0
  1991
  inline UnicodeString& insert(int32_t start,
sl@0
  1992
            const UnicodeString& srcText);
sl@0
  1993
sl@0
  1994
  /**
sl@0
  1995
   * Insert the characters in <TT>srcChars</TT> in the range
sl@0
  1996
   * [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>) into the UnicodeString
sl@0
  1997
   *  object at offset <TT>start</TT>. <TT>srcChars</TT> is not modified.
sl@0
  1998
   * @param start the offset at which the insertion begins
sl@0
  1999
   * @param srcChars the source for the new characters
sl@0
  2000
   * @param srcStart the offset into <TT>srcChars</TT> where new characters
sl@0
  2001
   * will be obtained
sl@0
  2002
   * @param srcLength the number of characters in <TT>srcChars</TT>
sl@0
  2003
   * in the insert string
sl@0
  2004
   * @return a reference to this
sl@0
  2005
   * @stable ICU 2.0
sl@0
  2006
   */
sl@0
  2007
  inline UnicodeString& insert(int32_t start,
sl@0
  2008
            const UChar *srcChars,
sl@0
  2009
            int32_t srcStart,
sl@0
  2010
            int32_t srcLength);
sl@0
  2011
sl@0
  2012
  /**
sl@0
  2013
   * Insert the characters in <TT>srcChars</TT> into the UnicodeString object
sl@0
  2014
   * at offset <TT>start</TT>. <TT>srcChars</TT> is not modified.
sl@0
  2015
   * @param start the offset where the insertion begins
sl@0
  2016
   * @param srcChars the source for the new characters
sl@0
  2017
   * @param srcLength the number of Unicode characters in srcChars.
sl@0
  2018
   * @return a reference to this
sl@0
  2019
   * @stable ICU 2.0
sl@0
  2020
   */
sl@0
  2021
  inline UnicodeString& insert(int32_t start,
sl@0
  2022
            const UChar *srcChars,
sl@0
  2023
            int32_t srcLength);
sl@0
  2024
sl@0
  2025
  /**
sl@0
  2026
   * Insert the code unit <TT>srcChar</TT> into the UnicodeString object at
sl@0
  2027
   * offset <TT>start</TT>.
sl@0
  2028
   * @param start the offset at which the insertion occurs
sl@0
  2029
   * @param srcChar the code unit to insert
sl@0
  2030
   * @return a reference to this
sl@0
  2031
   * @stable ICU 2.0
sl@0
  2032
   */
sl@0
  2033
  inline UnicodeString& insert(int32_t start,
sl@0
  2034
            UChar srcChar);
sl@0
  2035
sl@0
  2036
  /**
sl@0
  2037
   * Insert the code point <TT>srcChar</TT> into the UnicodeString object at
sl@0
  2038
   * offset <TT>start</TT>.
sl@0
  2039
   * @param start the offset at which the insertion occurs
sl@0
  2040
   * @param srcChar the code point to insert
sl@0
  2041
   * @return a reference to this
sl@0
  2042
   * @stable ICU 2.0
sl@0
  2043
   */
sl@0
  2044
  inline UnicodeString& insert(int32_t start,
sl@0
  2045
            UChar32 srcChar);
sl@0
  2046
sl@0
  2047
sl@0
  2048
  /* Replace operations */
sl@0
  2049
sl@0
  2050
  /**
sl@0
  2051
   * Replace the characters in the range
sl@0
  2052
   * [<TT>start</TT>, <TT>start + length</TT>) with the characters in
sl@0
  2053
   * <TT>srcText</TT> in the range
sl@0
  2054
   * [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>).
sl@0
  2055
   * <TT>srcText</TT> is not modified.
sl@0
  2056
   * @param start the offset at which the replace operation begins
sl@0
  2057
   * @param length the number of characters to replace. The character at
sl@0
  2058
   * <TT>start + length</TT> is not modified.
sl@0
  2059
   * @param srcText the source for the new characters
sl@0
  2060
   * @param srcStart the offset into <TT>srcText</TT> where new characters
sl@0
  2061
   * will be obtained
sl@0
  2062
   * @param srcLength the number of characters in <TT>srcText</TT> in
sl@0
  2063
   * the replace string
sl@0
  2064
   * @return a reference to this
sl@0
  2065
   * @stable ICU 2.0
sl@0
  2066
   */
sl@0
  2067
  UnicodeString& replace(int32_t start,
sl@0
  2068
             int32_t length,
sl@0
  2069
             const UnicodeString& srcText,
sl@0
  2070
             int32_t srcStart,
sl@0
  2071
             int32_t srcLength);
sl@0
  2072
sl@0
  2073
  /**
sl@0
  2074
   * Replace the characters in the range
sl@0
  2075
   * [<TT>start</TT>, <TT>start + length</TT>)
sl@0
  2076
   * with the characters in <TT>srcText</TT>.  <TT>srcText</TT> is
sl@0
  2077
   *  not modified.
sl@0
  2078
   * @param start the offset at which the replace operation begins
sl@0
  2079
   * @param length the number of characters to replace. The character at
sl@0
  2080
   * <TT>start + length</TT> is not modified.
sl@0
  2081
   * @param srcText the source for the new characters
sl@0
  2082
   * @return a reference to this
sl@0
  2083
   * @stable ICU 2.0
sl@0
  2084
   */
sl@0
  2085
  UnicodeString& replace(int32_t start,
sl@0
  2086
             int32_t length,
sl@0
  2087
             const UnicodeString& srcText);
sl@0
  2088
sl@0
  2089
  /**
sl@0
  2090
   * Replace the characters in the range
sl@0
  2091
   * [<TT>start</TT>, <TT>start + length</TT>) with the characters in
sl@0
  2092
   * <TT>srcChars</TT> in the range
sl@0
  2093
   * [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>). <TT>srcChars</TT>
sl@0
  2094
   * is not modified.
sl@0
  2095
   * @param start the offset at which the replace operation begins
sl@0
  2096
   * @param length the number of characters to replace.  The character at
sl@0
  2097
   * <TT>start + length</TT> is not modified.
sl@0
  2098
   * @param srcChars the source for the new characters
sl@0
  2099
   * @param srcStart the offset into <TT>srcChars</TT> where new characters
sl@0
  2100
   * will be obtained
sl@0
  2101
   * @param srcLength the number of characters in <TT>srcChars</TT>
sl@0
  2102
   * in the replace string
sl@0
  2103
   * @return a reference to this
sl@0
  2104
   * @stable ICU 2.0
sl@0
  2105
   */
sl@0
  2106
  UnicodeString& replace(int32_t start,
sl@0
  2107
             int32_t length,
sl@0
  2108
             const UChar *srcChars,
sl@0
  2109
             int32_t srcStart,
sl@0
  2110
             int32_t srcLength);
sl@0
  2111
sl@0
  2112
  /**
sl@0
  2113
   * Replace the characters in the range
sl@0
  2114
   * [<TT>start</TT>, <TT>start + length</TT>) with the characters in
sl@0
  2115
   * <TT>srcChars</TT>.  <TT>srcChars</TT> is not modified.
sl@0
  2116
   * @param start the offset at which the replace operation begins
sl@0
  2117
   * @param length number of characters to replace.  The character at
sl@0
  2118
   * <TT>start + length</TT> is not modified.
sl@0
  2119
   * @param srcChars the source for the new characters
sl@0
  2120
   * @param srcLength the number of Unicode characters in srcChars
sl@0
  2121
   * @return a reference to this
sl@0
  2122
   * @stable ICU 2.0
sl@0
  2123
   */
sl@0
  2124
  inline UnicodeString& replace(int32_t start,
sl@0
  2125
             int32_t length,
sl@0
  2126
             const UChar *srcChars,
sl@0
  2127
             int32_t srcLength);
sl@0
  2128
sl@0
  2129
  /**
sl@0
  2130
   * Replace the characters in the range
sl@0
  2131
   * [<TT>start</TT>, <TT>start + length</TT>) with the code unit
sl@0
  2132
   * <TT>srcChar</TT>.
sl@0
  2133
   * @param start the offset at which the replace operation begins
sl@0
  2134
   * @param length the number of characters to replace.  The character at
sl@0
  2135
   * <TT>start + length</TT> is not modified.
sl@0
  2136
   * @param srcChar the new code unit
sl@0
  2137
   * @return a reference to this
sl@0
  2138
   * @stable ICU 2.0
sl@0
  2139
   */
sl@0
  2140
  inline UnicodeString& replace(int32_t start,
sl@0
  2141
             int32_t length,
sl@0
  2142
             UChar srcChar);
sl@0
  2143
sl@0
  2144
  /**
sl@0
  2145
   * Replace the characters in the range
sl@0
  2146
   * [<TT>start</TT>, <TT>start + length</TT>) with the code point
sl@0
  2147
   * <TT>srcChar</TT>.
sl@0
  2148
   * @param start the offset at which the replace operation begins
sl@0
  2149
   * @param length the number of characters to replace.  The character at
sl@0
  2150
   * <TT>start + length</TT> is not modified.
sl@0
  2151
   * @param srcChar the new code point
sl@0
  2152
   * @return a reference to this
sl@0
  2153
   * @stable ICU 2.0
sl@0
  2154
   */
sl@0
  2155
  inline UnicodeString& replace(int32_t start,
sl@0
  2156
             int32_t length,
sl@0
  2157
             UChar32 srcChar);
sl@0
  2158
sl@0
  2159
  /**
sl@0
  2160
   * Replace the characters in the range [<TT>start</TT>, <TT>limit</TT>)
sl@0
  2161
   * with the characters in <TT>srcText</TT>. <TT>srcText</TT> is not modified.
sl@0
  2162
   * @param start the offset at which the replace operation begins
sl@0
  2163
   * @param limit the offset immediately following the replace range
sl@0
  2164
   * @param srcText the source for the new characters
sl@0
  2165
   * @return a reference to this
sl@0
  2166
   * @stable ICU 2.0
sl@0
  2167
   */
sl@0
  2168
  inline UnicodeString& replaceBetween(int32_t start,
sl@0
  2169
                int32_t limit,
sl@0
  2170
                const UnicodeString& srcText);
sl@0
  2171
sl@0
  2172
  /**
sl@0
  2173
   * Replace the characters in the range [<TT>start</TT>, <TT>limit</TT>)
sl@0
  2174
   * with the characters in <TT>srcText</TT> in the range
sl@0
  2175
   * [<TT>srcStart</TT>, <TT>srcLimit</TT>). <TT>srcText</TT> is not modified.
sl@0
  2176
   * @param start the offset at which the replace operation begins
sl@0
  2177
   * @param limit the offset immediately following the replace range
sl@0
  2178
   * @param srcText the source for the new characters
sl@0
  2179
   * @param srcStart the offset into <TT>srcChars</TT> where new characters
sl@0
  2180
   * will be obtained
sl@0
  2181
   * @param srcLimit the offset immediately following the range to copy
sl@0
  2182
   * in <TT>srcText</TT>
sl@0
  2183
   * @return a reference to this
sl@0
  2184
   * @stable ICU 2.0
sl@0
  2185
   */
sl@0
  2186
  inline UnicodeString& replaceBetween(int32_t start,
sl@0
  2187
                int32_t limit,
sl@0
  2188
                const UnicodeString& srcText,
sl@0
  2189
                int32_t srcStart,
sl@0
  2190
                int32_t srcLimit);
sl@0
  2191
sl@0
  2192
  /**
sl@0
  2193
   * Replace a substring of this object with the given text.
sl@0
  2194
   * @param start the beginning index, inclusive; <code>0 <= start
sl@0
  2195
   * <= limit</code>.
sl@0
  2196
   * @param limit the ending index, exclusive; <code>start <= limit
sl@0
  2197
   * <= length()</code>.
sl@0
  2198
   * @param text the text to replace characters <code>start</code>
sl@0
  2199
   * to <code>limit - 1</code>
sl@0
  2200
   * @stable ICU 2.0
sl@0
  2201
   */
sl@0
  2202
  virtual void handleReplaceBetween(int32_t start,
sl@0
  2203
                                    int32_t limit,
sl@0
  2204
                                    const UnicodeString& text);
sl@0
  2205
sl@0
  2206
  /**
sl@0
  2207
   * Replaceable API
sl@0
  2208
   * @return TRUE if it has MetaData
sl@0
  2209
   * @stable ICU 2.4
sl@0
  2210
   */
sl@0
  2211
  virtual UBool hasMetaData() const;
sl@0
  2212
sl@0
  2213
  /**
sl@0
  2214
   * Copy a substring of this object, retaining attribute (out-of-band)
sl@0
  2215
   * information.  This method is used to duplicate or reorder substrings.
sl@0
  2216
   * The destination index must not overlap the source range.
sl@0
  2217
   *
sl@0
  2218
   * @param start the beginning index, inclusive; <code>0 <= start <=
sl@0
  2219
   * limit</code>.
sl@0
  2220
   * @param limit the ending index, exclusive; <code>start <= limit <=
sl@0
  2221
   * length()</code>.
sl@0
  2222
   * @param dest the destination index.  The characters from
sl@0
  2223
   * <code>start..limit-1</code> will be copied to <code>dest</code>.
sl@0
  2224
   * Implementations of this method may assume that <code>dest <= start ||
sl@0
  2225
   * dest >= limit</code>.
sl@0
  2226
   * @stable ICU 2.0
sl@0
  2227
   */
sl@0
  2228
  virtual void copy(int32_t start, int32_t limit, int32_t dest);
sl@0
  2229
sl@0
  2230
  /* Search and replace operations */
sl@0
  2231
sl@0
  2232
  /**
sl@0
  2233
   * Replace all occurrences of characters in oldText with the characters
sl@0
  2234
   * in newText
sl@0
  2235
   * @param oldText the text containing the search text
sl@0
  2236
   * @param newText the text containing the replacement text
sl@0
  2237
   * @return a reference to this
sl@0
  2238
   * @stable ICU 2.0
sl@0
  2239
   */
sl@0
  2240
  inline UnicodeString& findAndReplace(const UnicodeString& oldText,
sl@0
  2241
                const UnicodeString& newText);
sl@0
  2242
sl@0
  2243
  /**
sl@0
  2244
   * Replace all occurrences of characters in oldText with characters
sl@0
  2245
   * in newText
sl@0
  2246
   * in the range [<TT>start</TT>, <TT>start + length</TT>).
sl@0
  2247
   * @param start the start of the range in which replace will performed
sl@0
  2248
   * @param length the length of the range in which replace will be performed
sl@0
  2249
   * @param oldText the text containing the search text
sl@0
  2250
   * @param newText the text containing the replacement text
sl@0
  2251
   * @return a reference to this
sl@0
  2252
   * @stable ICU 2.0
sl@0
  2253
   */
sl@0
  2254
  inline UnicodeString& findAndReplace(int32_t start,
sl@0
  2255
                int32_t length,
sl@0
  2256
                const UnicodeString& oldText,
sl@0
  2257
                const UnicodeString& newText);
sl@0
  2258
sl@0
  2259
  /**
sl@0
  2260
   * Replace all occurrences of characters in oldText in the range
sl@0
  2261
   * [<TT>oldStart</TT>, <TT>oldStart + oldLength</TT>) with the characters
sl@0
  2262
   * in newText in the range
sl@0
  2263
   * [<TT>newStart</TT>, <TT>newStart + newLength</TT>)
sl@0
  2264
   * in the range [<TT>start</TT>, <TT>start + length</TT>).
sl@0
  2265
   * @param start the start of the range in which replace will performed
sl@0
  2266
   * @param length the length of the range in which replace will be performed
sl@0
  2267
   * @param oldText the text containing the search text
sl@0
  2268
   * @param oldStart the start of the search range in <TT>oldText</TT>
sl@0
  2269
   * @param oldLength the length of the search range in <TT>oldText</TT>
sl@0
  2270
   * @param newText the text containing the replacement text
sl@0
  2271
   * @param newStart the start of the replacement range in <TT>newText</TT>
sl@0
  2272
   * @param newLength the length of the replacement range in <TT>newText</TT>
sl@0
  2273
   * @return a reference to this
sl@0
  2274
   * @stable ICU 2.0
sl@0
  2275
   */
sl@0
  2276
  UnicodeString& findAndReplace(int32_t start,
sl@0
  2277
                int32_t length,
sl@0
  2278
                const UnicodeString& oldText,
sl@0
  2279
                int32_t oldStart,
sl@0
  2280
                int32_t oldLength,
sl@0
  2281
                const UnicodeString& newText,
sl@0
  2282
                int32_t newStart,
sl@0
  2283
                int32_t newLength);
sl@0
  2284
sl@0
  2285
sl@0
  2286
  /* Remove operations */
sl@0
  2287
sl@0
  2288
  /**
sl@0
  2289
   * Remove all characters from the UnicodeString object.
sl@0
  2290
   * @return a reference to this
sl@0
  2291
   * @stable ICU 2.0
sl@0
  2292
   */
sl@0
  2293
  inline UnicodeString& remove(void);
sl@0
  2294
sl@0
  2295
  /**
sl@0
  2296
   * Remove the characters in the range
sl@0
  2297
   * [<TT>start</TT>, <TT>start + length</TT>) from the UnicodeString object.
sl@0
  2298
   * @param start the offset of the first character to remove
sl@0
  2299
   * @param length the number of characters to remove
sl@0
  2300
   * @return a reference to this
sl@0
  2301
   * @stable ICU 2.0
sl@0
  2302
   */
sl@0
  2303
  inline UnicodeString& remove(int32_t start,
sl@0
  2304
                               int32_t length = (int32_t)INT32_MAX);
sl@0
  2305
sl@0
  2306
  /**
sl@0
  2307
   * Remove the characters in the range
sl@0
  2308
   * [<TT>start</TT>, <TT>limit</TT>) from the UnicodeString object.
sl@0
  2309
   * @param start the offset of the first character to remove
sl@0
  2310
   * @param limit the offset immediately following the range to remove
sl@0
  2311
   * @return a reference to this
sl@0
  2312
   * @stable ICU 2.0
sl@0
  2313
   */
sl@0
  2314
  inline UnicodeString& removeBetween(int32_t start,
sl@0
  2315
                                      int32_t limit = (int32_t)INT32_MAX);
sl@0
  2316
sl@0
  2317
sl@0
  2318
  /* Length operations */
sl@0
  2319
sl@0
  2320
  /**
sl@0
  2321
   * Pad the start of this UnicodeString with the character <TT>padChar</TT>.
sl@0
  2322
   * If the length of this UnicodeString is less than targetLength,
sl@0
  2323
   * length() - targetLength copies of padChar will be added to the
sl@0
  2324
   * beginning of this UnicodeString.
sl@0
  2325
   * @param targetLength the desired length of the string
sl@0
  2326
   * @param padChar the character to use for padding. Defaults to
sl@0
  2327
   * space (U+0020)
sl@0
  2328
   * @return TRUE if the text was padded, FALSE otherwise.
sl@0
  2329
   * @stable ICU 2.0
sl@0
  2330
   */
sl@0
  2331
  UBool padLeading(int32_t targetLength,
sl@0
  2332
                    UChar padChar = 0x0020);
sl@0
  2333
sl@0
  2334
  /**
sl@0
  2335
   * Pad the end of this UnicodeString with the character <TT>padChar</TT>.
sl@0
  2336
   * If the length of this UnicodeString is less than targetLength,
sl@0
  2337
   * length() - targetLength copies of padChar will be added to the
sl@0
  2338
   * end of this UnicodeString.
sl@0
  2339
   * @param targetLength the desired length of the string
sl@0
  2340
   * @param padChar the character to use for padding. Defaults to
sl@0
  2341
   * space (U+0020)
sl@0
  2342
   * @return TRUE if the text was padded, FALSE otherwise.
sl@0
  2343
   * @stable ICU 2.0
sl@0
  2344
   */
sl@0
  2345
  UBool padTrailing(int32_t targetLength,
sl@0
  2346
                     UChar padChar = 0x0020);
sl@0
  2347
sl@0
  2348
  /**
sl@0
  2349
   * Truncate this UnicodeString to the <TT>targetLength</TT>.
sl@0
  2350
   * @param targetLength the desired length of this UnicodeString.
sl@0
  2351
   * @return TRUE if the text was truncated, FALSE otherwise
sl@0
  2352
   * @stable ICU 2.0
sl@0
  2353
   */
sl@0
  2354
  inline UBool truncate(int32_t targetLength);
sl@0
  2355
sl@0
  2356
  /**
sl@0
  2357
   * Trims leading and trailing whitespace from this UnicodeString.
sl@0
  2358
   * @return a reference to this
sl@0
  2359
   * @stable ICU 2.0
sl@0
  2360
   */
sl@0
  2361
  UnicodeString& trim(void);
sl@0
  2362
sl@0
  2363
sl@0
  2364
  /* Miscellaneous operations */
sl@0
  2365
sl@0
  2366
  /**
sl@0
  2367
   * Reverse this UnicodeString in place.
sl@0
  2368
   * @return a reference to this
sl@0
  2369
   * @stable ICU 2.0
sl@0
  2370
   */
sl@0
  2371
  inline UnicodeString& reverse(void);
sl@0
  2372
sl@0
  2373
  /**
sl@0
  2374
   * Reverse the range [<TT>start</TT>, <TT>start + length</TT>) in
sl@0
  2375
   * this UnicodeString.
sl@0
  2376
   * @param start the start of the range to reverse
sl@0
  2377
   * @param length the number of characters to to reverse
sl@0
  2378
   * @return a reference to this
sl@0
  2379
   * @stable ICU 2.0
sl@0
  2380
   */
sl@0
  2381
  inline UnicodeString& reverse(int32_t start,
sl@0
  2382
             int32_t length);
sl@0
  2383
sl@0
  2384
  /**
sl@0
  2385
   * Convert the characters in this to UPPER CASE following the conventions of
sl@0
  2386
   * the default locale.
sl@0
  2387
   * @return A reference to this.
sl@0
  2388
   * @stable ICU 2.0
sl@0
  2389
   */
sl@0
  2390
  UnicodeString& toUpper(void);
sl@0
  2391
sl@0
  2392
  /**
sl@0
  2393
   * Convert the characters in this to UPPER CASE following the conventions of
sl@0
  2394
   * a specific locale.
sl@0
  2395
   * @param locale The locale containing the conventions to use.
sl@0
  2396
   * @return A reference to this.
sl@0
  2397
   * @stable ICU 2.0
sl@0
  2398
   */
sl@0
  2399
  UnicodeString& toUpper(const Locale& locale);
sl@0
  2400
sl@0
  2401
  /**
sl@0
  2402
   * Convert the characters in this to lower case following the conventions of
sl@0
  2403
   * the default locale.
sl@0
  2404
   * @return A reference to this.
sl@0
  2405
   * @stable ICU 2.0
sl@0
  2406
   */
sl@0
  2407
  UnicodeString& toLower(void);
sl@0
  2408
sl@0
  2409
  /**
sl@0
  2410
   * Convert the characters in this to lower case following the conventions of
sl@0
  2411
   * a specific locale.
sl@0
  2412
   * @param locale The locale containing the conventions to use.
sl@0
  2413
   * @return A reference to this.
sl@0
  2414
   * @stable ICU 2.0
sl@0
  2415
   */
sl@0
  2416
  UnicodeString& toLower(const Locale& locale);
sl@0
  2417
sl@0
  2418
#if !UCONFIG_NO_BREAK_ITERATION
sl@0
  2419
sl@0
  2420
  /**
sl@0
  2421
   * Titlecase this string, convenience function using the default locale.
sl@0
  2422
   *
sl@0
  2423
   * Casing is locale-dependent and context-sensitive.
sl@0
  2424
   * Titlecasing uses a break iterator to find the first characters of words
sl@0
  2425
   * that are to be titlecased. It titlecases those characters and lowercases
sl@0
  2426
   * all others.
sl@0
  2427
   *
sl@0
  2428
   * The titlecase break iterator can be provided to customize for arbitrary
sl@0
  2429
   * styles, using rules and dictionaries beyond the standard iterators.
sl@0
  2430
   * It may be more efficient to always provide an iterator to avoid
sl@0
  2431
   * opening and closing one for each string.
sl@0
  2432
   * The standard titlecase iterator for the root locale implements the
sl@0
  2433
   * algorithm of Unicode TR 21.
sl@0
  2434
   *
sl@0
  2435
   * This function uses only the first() and next() methods of the
sl@0
  2436
   * provided break iterator.
sl@0
  2437
   *
sl@0
  2438
   * @param titleIter A break iterator to find the first characters of words
sl@0
  2439
   *                  that are to be titlecased.
sl@0
  2440
   *                  If none is provided (0), then a standard titlecase
sl@0
  2441
   *                  break iterator is opened.
sl@0
  2442
   *                  Otherwise the provided iterator is set to the string's text.
sl@0
  2443
   * @return A reference to this.
sl@0
  2444
   * @stable ICU 2.1
sl@0
  2445
   */
sl@0
  2446
  UnicodeString &toTitle(BreakIterator *titleIter);
sl@0
  2447
sl@0
  2448
  /**
sl@0
  2449
   * Titlecase this string.
sl@0
  2450
   *
sl@0
  2451
   * Casing is locale-dependent and context-sensitive.
sl@0
  2452
   * Titlecasing uses a break iterator to find the first characters of words
sl@0
  2453
   * that are to be titlecased. It titlecases those characters and lowercases
sl@0
  2454
   * all others.
sl@0
  2455
   *
sl@0
  2456
   * The titlecase break iterator can be provided to customize for arbitrary
sl@0
  2457
   * styles, using rules and dictionaries beyond the standard iterators.
sl@0
  2458
   * It may be more efficient to always provide an iterator to avoid
sl@0
  2459
   * opening and closing one for each string.
sl@0
  2460
   * The standard titlecase iterator for the root locale implements the
sl@0
  2461
   * algorithm of Unicode TR 21.
sl@0
  2462
   *
sl@0
  2463
   * This function uses only the first() and next() methods of the
sl@0
  2464
   * provided break iterator.
sl@0
  2465
   *
sl@0
  2466
   * @param titleIter A break iterator to find the first characters of words
sl@0
  2467
   *                  that are to be titlecased.
sl@0
  2468
   *                  If none is provided (0), then a standard titlecase
sl@0
  2469
   *                  break iterator is opened.
sl@0
  2470
   *                  Otherwise the provided iterator is set to the string's text.
sl@0
  2471
   * @param locale    The locale to consider.
sl@0
  2472
   * @return A reference to this.
sl@0
  2473
   * @stable ICU 2.1
sl@0
  2474
   */
sl@0
  2475
  UnicodeString &toTitle(BreakIterator *titleIter, const Locale &locale);
sl@0
  2476
sl@0
  2477
#endif
sl@0
  2478
sl@0
  2479
  /**
sl@0
  2480
   * Case-fold the characters in this string.
sl@0
  2481
   * Case-folding is locale-independent and not context-sensitive,
sl@0
  2482
   * but there is an option for whether to include or exclude mappings for dotted I
sl@0
  2483
   * and dotless i that are marked with 'I' in CaseFolding.txt.
sl@0
  2484
   * The result may be longer or shorter than the original.
sl@0
  2485
   *
sl@0
  2486
   * @param options Either U_FOLD_CASE_DEFAULT or U_FOLD_CASE_EXCLUDE_SPECIAL_I
sl@0
  2487
   * @return A reference to this.
sl@0
  2488
   * @stable ICU 2.0
sl@0
  2489
   */
sl@0
  2490
  UnicodeString &foldCase(uint32_t options=0 /*U_FOLD_CASE_DEFAULT*/);
sl@0
  2491
sl@0
  2492
  //========================================
sl@0
  2493
  // Access to the internal buffer
sl@0
  2494
  //========================================
sl@0
  2495
sl@0
  2496
  /**
sl@0
  2497
   * Get a read/write pointer to the internal buffer.
sl@0
  2498
   * The buffer is guaranteed to be large enough for at least minCapacity UChars,
sl@0
  2499
   * writable, and is still owned by the UnicodeString object.
sl@0
  2500
   * Calls to getBuffer(minCapacity) must not be nested, and
sl@0
  2501
   * must be matched with calls to releaseBuffer(newLength).
sl@0
  2502
   * If the string buffer was read-only or shared,
sl@0
  2503
   * then it will be reallocated and copied.
sl@0
  2504
   *
sl@0
  2505
   * An attempted nested call will return 0, and will not further modify the
sl@0
  2506
   * state of the UnicodeString object.
sl@0
  2507
   * It also returns 0 if the string is bogus.
sl@0
  2508
   *
sl@0
  2509
   * The actual capacity of the string buffer may be larger than minCapacity.
sl@0
  2510
   * getCapacity() returns the actual capacity.
sl@0
  2511
   * For many operations, the full capacity should be used to avoid reallocations.
sl@0
  2512
   *
sl@0
  2513
   * While the buffer is "open" between getBuffer(minCapacity)
sl@0
  2514
   * and releaseBuffer(newLength), the following applies:
sl@0
  2515
   * - The string length is set to 0.
sl@0
  2516
   * - Any read API call on the UnicodeString object will behave like on a 0-length string.
sl@0
  2517
   * - Any write API call on the UnicodeString object is disallowed and will have no effect.
sl@0
  2518
   * - You can read from and write to the returned buffer.
sl@0
  2519
   * - The previous string contents will still be in the buffer;
sl@0
  2520
   *   if you want to use it, then you need to call length() before getBuffer(minCapacity).
sl@0
  2521
   *   If the length() was greater than minCapacity, then any contents after minCapacity
sl@0
  2522
   *   may be lost.
sl@0
  2523
   *   The buffer contents is not NUL-terminated by getBuffer().
sl@0
  2524
   *   If length()<getCapacity() then you can terminate it by writing a NUL
sl@0
  2525
   *   at index length().
sl@0
  2526
   * - You must call releaseBuffer(newLength) before and in order to
sl@0
  2527
   *   return to normal UnicodeString operation.
sl@0
  2528
   *
sl@0
  2529
   * @param minCapacity the minimum number of UChars that are to be available
sl@0
  2530
   *        in the buffer, starting at the returned pointer;
sl@0
  2531
   *        default to the current string capacity if minCapacity==-1
sl@0
  2532
   * @return a writable pointer to the internal string buffer,
sl@0
  2533
   *         or 0 if an error occurs (nested calls, out of memory)
sl@0
  2534
   *
sl@0
  2535
   * @see releaseBuffer
sl@0
  2536
   * @see getTerminatedBuffer()
sl@0
  2537
   * @stable ICU 2.0
sl@0
  2538
   */
sl@0
  2539
  UChar *getBuffer(int32_t minCapacity);
sl@0
  2540
sl@0
  2541
  /**
sl@0
  2542
   * Release a read/write buffer on a UnicodeString object with an
sl@0
  2543
   * "open" getBuffer(minCapacity).
sl@0
  2544
   * This function must be called in a matched pair with getBuffer(minCapacity).
sl@0
  2545
   * releaseBuffer(newLength) must be called if and only if a getBuffer(minCapacity) is "open".
sl@0
  2546
   *
sl@0
  2547
   * It will set the string length to newLength, at most to the current capacity.
sl@0
  2548
   * If newLength==-1 then it will set the length according to the
sl@0
  2549
   * first NUL in the buffer, or to the capacity if there is no NUL.
sl@0
  2550
   *
sl@0
  2551
   * After calling releaseBuffer(newLength) the UnicodeString is back to normal operation.
sl@0
  2552
   *
sl@0
  2553
   * @param newLength the new length of the UnicodeString object;
sl@0
  2554
   *        defaults to the current capacity if newLength is greater than that;
sl@0
  2555
   *        if newLength==-1, it defaults to u_strlen(buffer) but not more than
sl@0
  2556
   *        the current capacity of the string
sl@0
  2557
   *
sl@0
  2558
   * @see getBuffer(int32_t minCapacity)
sl@0
  2559
   * @stable ICU 2.0
sl@0
  2560
   */
sl@0
  2561
  void releaseBuffer(int32_t newLength=-1);
sl@0
  2562
sl@0
  2563
  /**
sl@0
  2564
   * Get a read-only pointer to the internal buffer.
sl@0
  2565
   * This can be called at any time on a valid UnicodeString.
sl@0
  2566
   *
sl@0
  2567
   * It returns 0 if the string is bogus, or
sl@0
  2568
   * during an "open" getBuffer(minCapacity).
sl@0
  2569
   *
sl@0
  2570
   * It can be called as many times as desired.
sl@0
  2571
   * The pointer that it returns will remain valid until the UnicodeString object is modified,
sl@0
  2572
   * at which time the pointer is semantically invalidated and must not be used any more.
sl@0
  2573
   *
sl@0
  2574
   * The capacity of the buffer can be determined with getCapacity().
sl@0
  2575
   * The part after length() may or may not be initialized and valid,
sl@0
  2576
   * depending on the history of the UnicodeString object.
sl@0
  2577
   *
sl@0
  2578
   * The buffer contents is (probably) not NUL-terminated.
sl@0
  2579
   * You can check if it is with
sl@0
  2580
   * <code>(s.length()<s.getCapacity() && buffer[s.length()]==0)</code>.
sl@0
  2581
   * (See getTerminatedBuffer().)
sl@0
  2582
   *
sl@0
  2583
   * The buffer may reside in read-only memory. Its contents must not
sl@0
  2584
   * be modified.
sl@0
  2585
   *
sl@0
  2586
   * @return a read-only pointer to the internal string buffer,
sl@0
  2587
   *         or 0 if the string is empty or bogus
sl@0
  2588
   *
sl@0
  2589
   * @see getBuffer(int32_t minCapacity)
sl@0
  2590
   * @see getTerminatedBuffer()
sl@0
  2591
   * @stable ICU 2.0
sl@0
  2592
   */
sl@0
  2593
  inline const UChar *getBuffer() const;
sl@0
  2594
sl@0
  2595
  /**
sl@0
  2596
   * Get a read-only pointer to the internal buffer,
sl@0
  2597
   * making sure that it is NUL-terminated.
sl@0
  2598
   * This can be called at any time on a valid UnicodeString.
sl@0
  2599
   *
sl@0
  2600
   * It returns 0 if the string is bogus, or
sl@0
  2601
   * during an "open" getBuffer(minCapacity), or if the buffer cannot
sl@0
  2602
   * be NUL-terminated (because memory allocation failed).
sl@0
  2603
   *
sl@0
  2604
   * It can be called as many times as desired.
sl@0
  2605
   * The pointer that it returns will remain valid until the UnicodeString object is modified,
sl@0
  2606
   * at which time the pointer is semantically invalidated and must not be used any more.
sl@0
  2607
   *
sl@0
  2608
   * The capacity of the buffer can be determined with getCapacity().
sl@0
  2609
   * The part after length()+1 may or may not be initialized and valid,
sl@0
  2610
   * depending on the history of the UnicodeString object.
sl@0
  2611
   *
sl@0
  2612
   * The buffer contents is guaranteed to be NUL-terminated.
sl@0
  2613
   * getTerminatedBuffer() may reallocate the buffer if a terminating NUL
sl@0
  2614
   * is written.
sl@0
  2615
   * For this reason, this function is not const, unlike getBuffer().
sl@0
  2616
   * Note that a UnicodeString may also contain NUL characters as part of its contents.
sl@0
  2617
   *
sl@0
  2618
   * The buffer may reside in read-only memory. Its contents must not
sl@0
  2619
   * be modified.
sl@0
  2620
   *
sl@0
  2621
   * @return a read-only pointer to the internal string buffer,
sl@0
  2622
   *         or 0 if the string is empty or bogus
sl@0
  2623
   *
sl@0
  2624
   * @see getBuffer(int32_t minCapacity)
sl@0
  2625
   * @see getBuffer()
sl@0
  2626
   * @stable ICU 2.2
sl@0
  2627
   */
sl@0
  2628
  inline const UChar *getTerminatedBuffer();
sl@0
  2629
sl@0
  2630
  //========================================
sl@0
  2631
  // Constructors
sl@0
  2632
  //========================================
sl@0
  2633
sl@0
  2634
  /** Construct an empty UnicodeString.
sl@0
  2635
   * @stable ICU 2.0
sl@0
  2636
   */
sl@0
  2637
  UnicodeString();
sl@0
  2638
sl@0
  2639
  /**
sl@0
  2640
   * Construct a UnicodeString with capacity to hold <TT>capacity</TT> UChars
sl@0
  2641
   * @param capacity the number of UChars this UnicodeString should hold
sl@0
  2642
   * before a resize is necessary; if count is greater than 0 and count
sl@0
  2643
   * code points c take up more space than capacity, then capacity is adjusted
sl@0
  2644
   * accordingly.
sl@0
  2645
   * @param c is used to initially fill the string
sl@0
  2646
   * @param count specifies how many code points c are to be written in the
sl@0
  2647
   *              string
sl@0
  2648
   * @stable ICU 2.0
sl@0
  2649
   */
sl@0
  2650
  UnicodeString(int32_t capacity, UChar32 c, int32_t count);
sl@0
  2651
sl@0
  2652
  /**
sl@0
  2653
   * Single UChar (code unit) constructor.
sl@0
  2654
   * @param ch the character to place in the UnicodeString
sl@0
  2655
   * @stable ICU 2.0
sl@0
  2656
   */
sl@0
  2657
  UnicodeString(UChar ch);
sl@0
  2658
sl@0
  2659
  /**
sl@0
  2660
   * Single UChar32 (code point) constructor.
sl@0
  2661
   * @param ch the character to place in the UnicodeString
sl@0
  2662
   * @stable ICU 2.0
sl@0
  2663
   */
sl@0
  2664
  UnicodeString(UChar32 ch);
sl@0
  2665
sl@0
  2666
  /**
sl@0
  2667
   * UChar* constructor.
sl@0
  2668
   * @param text The characters to place in the UnicodeString.  <TT>text</TT>
sl@0
  2669
   * must be NULL (U+0000) terminated.
sl@0
  2670
   * @stable ICU 2.0
sl@0
  2671
   */
sl@0
  2672
  UnicodeString(const UChar *text);
sl@0
  2673
sl@0
  2674
  /**
sl@0
  2675
   * UChar* constructor.
sl@0
  2676
   * @param text The characters to place in the UnicodeString.
sl@0
  2677
   * @param textLength The number of Unicode characters in <TT>text</TT>
sl@0
  2678
   * to copy.
sl@0
  2679
   * @stable ICU 2.0
sl@0
  2680
   */
sl@0
  2681
  UnicodeString(const UChar *text,
sl@0
  2682
        int32_t textLength);
sl@0
  2683
sl@0
  2684
  /**
sl@0
  2685
   * Readonly-aliasing UChar* constructor.
sl@0
  2686
   * The text will be used for the UnicodeString object, but
sl@0
  2687
   * it will not be released when the UnicodeString is destroyed.
sl@0
  2688
   * This has copy-on-write semantics:
sl@0
  2689
   * When the string is modified, then the buffer is first copied into
sl@0
  2690
   * newly allocated memory.
sl@0
  2691
   * The aliased buffer is never modified.
sl@0
  2692
   * In an assignment to another UnicodeString, the text will be aliased again,
sl@0
  2693
   * so that both strings then alias the same readonly-text.
sl@0
  2694
   *
sl@0
  2695
   * @param isTerminated specifies if <code>text</code> is <code>NUL</code>-terminated.
sl@0
  2696
   *                     This must be true if <code>textLength==-1</code>.
sl@0
  2697
   * @param text The characters to alias for the UnicodeString.
sl@0
  2698
   * @param textLength The number of Unicode characters in <code>text</code> to alias.
sl@0
  2699
   *                   If -1, then this constructor will determine the length
sl@0
  2700
   *                   by calling <code>u_strlen()</code>.
sl@0
  2701
   * @stable ICU 2.0
sl@0
  2702
   */
sl@0
  2703
  UnicodeString(UBool isTerminated,
sl@0
  2704
                const UChar *text,
sl@0
  2705
                int32_t textLength);
sl@0
  2706
sl@0
  2707
  /**
sl@0
  2708
   * Writable-aliasing UChar* constructor.
sl@0
  2709
   * The text will be used for the UnicodeString object, but
sl@0
  2710
   * it will not be released when the UnicodeString is destroyed.
sl@0
  2711
   * This has write-through semantics:
sl@0
  2712
   * For as long as the capacity of the buffer is sufficient, write operations
sl@0
  2713
   * will directly affect the buffer. When more capacity is necessary, then
sl@0
  2714
   * a new buffer will be allocated and the contents copied as with regularly
sl@0
  2715
   * constructed strings.
sl@0
  2716
   * In an assignment to another UnicodeString, the buffer will be copied.
sl@0
  2717
   * The extract(UChar *dst) function detects whether the dst pointer is the same
sl@0
  2718
   * as the string buffer itself and will in this case not copy the contents.
sl@0
  2719
   *
sl@0
  2720
   * @param buffer The characters to alias for the UnicodeString.
sl@0
  2721
   * @param buffLength The number of Unicode characters in <code>buffer</code> to alias.
sl@0
  2722
   * @param buffCapacity The size of <code>buffer</code> in UChars.
sl@0
  2723
   * @stable ICU 2.0
sl@0
  2724
   */
sl@0
  2725
  UnicodeString(UChar *buffer, int32_t buffLength, int32_t buffCapacity);
sl@0
  2726
sl@0
  2727
#if !UCONFIG_NO_CONVERSION
sl@0
  2728
sl@0
  2729
  /**
sl@0
  2730
   * char* constructor.
sl@0
  2731
   * @param codepageData an array of bytes, null-terminated
sl@0
  2732
   * @param codepage the encoding of <TT>codepageData</TT>.  The special
sl@0
  2733
   * value 0 for <TT>codepage</TT> indicates that the text is in the
sl@0
  2734
   * platform's default codepage.
sl@0
  2735
   *
sl@0
  2736
   * If <code>codepage</code> is an empty string (<code>""</code>),
sl@0
  2737
   * then a simple conversion is performed on the codepage-invariant
sl@0
  2738
   * subset ("invariant characters") of the platform encoding. See utypes.h.
sl@0
  2739
   * Recommendation: For invariant-character strings use the constructor
sl@0
  2740
   * UnicodeString(const char *src, int32_t length, enum EInvariant inv)
sl@0
  2741
   * because it avoids object code dependencies of UnicodeString on
sl@0
  2742
   * the conversion code.
sl@0
  2743
   *
sl@0
  2744
   * @stable ICU 2.0
sl@0
  2745
   */
sl@0
  2746
  UnicodeString(const char *codepageData,
sl@0
  2747
        const char *codepage = 0);
sl@0
  2748
sl@0
  2749
  /**
sl@0
  2750
   * char* constructor.
sl@0
  2751
   * @param codepageData an array of bytes.
sl@0
  2752
   * @param dataLength The number of bytes in <TT>codepageData</TT>.
sl@0
  2753
   * @param codepage the encoding of <TT>codepageData</TT>.  The special
sl@0
  2754
   * value 0 for <TT>codepage</TT> indicates that the text is in the
sl@0
  2755
   * platform's default codepage.
sl@0
  2756
   * If <code>codepage</code> is an empty string (<code>""</code>),
sl@0
  2757
   * then a simple conversion is performed on the codepage-invariant
sl@0
  2758
   * subset ("invariant characters") of the platform encoding. See utypes.h.
sl@0
  2759
   * Recommendation: For invariant-character strings use the constructor
sl@0
  2760
   * UnicodeString(const char *src, int32_t length, enum EInvariant inv)
sl@0
  2761
   * because it avoids object code dependencies of UnicodeString on
sl@0
  2762
   * the conversion code.
sl@0
  2763
   *
sl@0
  2764
   * @stable ICU 2.0
sl@0
  2765
   */
sl@0
  2766
  UnicodeString(const char *codepageData,
sl@0
  2767
        int32_t dataLength,
sl@0
  2768
        const char *codepage = 0);
sl@0
  2769
sl@0
  2770
  /**
sl@0
  2771
   * char * / UConverter constructor.
sl@0
  2772
   * This constructor uses an existing UConverter object to
sl@0
  2773
   * convert the codepage string to Unicode and construct a UnicodeString
sl@0
  2774
   * from that.
sl@0
  2775
   *
sl@0
  2776
   * The converter is reset at first.
sl@0
  2777
   * If the error code indicates a failure before this constructor is called,
sl@0
  2778
   * or if an error occurs during conversion or construction,
sl@0
  2779
   * then the string will be bogus.
sl@0
  2780
   *
sl@0
  2781
   * This function avoids the overhead of opening and closing a converter if
sl@0
  2782
   * multiple strings are constructed.
sl@0
  2783
   *
sl@0
  2784
   * @param src input codepage string
sl@0
  2785
   * @param srcLength length of the input string, can be -1 for NUL-terminated strings
sl@0
  2786
   * @param cnv converter object (ucnv_resetToUnicode() will be called),
sl@0
  2787
   *        can be NULL for the default converter
sl@0
  2788
   * @param errorCode normal ICU error code
sl@0
  2789
   * @stable ICU 2.0
sl@0
  2790
   */
sl@0
  2791
  UnicodeString(
sl@0
  2792
        const char *src, int32_t srcLength,
sl@0
  2793
        UConverter *cnv,
sl@0
  2794
        UErrorCode &errorCode);
sl@0
  2795
sl@0
  2796
#endif
sl@0
  2797
sl@0
  2798
  /**
sl@0
  2799
   * Constructs a Unicode string from an invariant-character char * string.
sl@0
  2800
   * About invariant characters see utypes.h.
sl@0
  2801
   * This constructor has no runtime dependency on conversion code and is
sl@0
  2802
   * therefore recommended over ones taking a charset name string
sl@0
  2803
   * (where the empty string "" indicates invariant-character conversion).
sl@0
  2804
   *
sl@0
  2805
   * Use the macro US_INV as the third, signature-distinguishing parameter.
sl@0
  2806
   *
sl@0
  2807
   * For example:
sl@0
  2808
   * \code
sl@0
  2809
   * void fn(const char *s) {
sl@0
  2810
   *   UnicodeString ustr(s, -1, US_INV);
sl@0
  2811
   *   // use ustr ...
sl@0
  2812
   * }
sl@0
  2813
   * \endcode
sl@0
  2814
   *
sl@0
  2815
   * @param src String using only invariant characters.
sl@0
  2816
   * @param length Length of src, or -1 if NUL-terminated.
sl@0
  2817
   * @param inv Signature-distinguishing paramater, use US_INV.
sl@0
  2818
   *
sl@0
  2819
   * @see US_INV
sl@0
  2820
   * @draft ICU 3.2
sl@0
  2821
   */
sl@0
  2822
  UnicodeString(const char *src, int32_t length, enum EInvariant inv);
sl@0
  2823
sl@0
  2824
sl@0
  2825
  /**
sl@0
  2826
   * Copy constructor.
sl@0
  2827
   * @param that The UnicodeString object to copy.
sl@0
  2828
   * @stable ICU 2.0
sl@0
  2829
   */
sl@0
  2830
  UnicodeString(const UnicodeString& that);
sl@0
  2831
sl@0
  2832
  /**
sl@0
  2833
   * 'Substring' constructor from tail of source string.
sl@0
  2834
   * @param src The UnicodeString object to copy.
sl@0
  2835
   * @param srcStart The offset into <tt>src</tt> at which to start copying.
sl@0
  2836
   * @stable ICU 2.2
sl@0
  2837
   */
sl@0
  2838
  UnicodeString(const UnicodeString& src, int32_t srcStart);
sl@0
  2839
sl@0
  2840
  /**
sl@0
  2841
   * 'Substring' constructor from subrange of source string.
sl@0
  2842
   * @param src The UnicodeString object to copy.
sl@0
  2843
   * @param srcStart The offset into <tt>src</tt> at which to start copying.
sl@0
  2844
   * @param srcLength The number of characters from <tt>src</tt> to copy.
sl@0
  2845
   * @stable ICU 2.2
sl@0
  2846
   */
sl@0
  2847
  UnicodeString(const UnicodeString& src, int32_t srcStart, int32_t srcLength);
sl@0
  2848
sl@0
  2849
  /**
sl@0
  2850
   * Clone this object, an instance of a subclass of Replaceable.
sl@0
  2851
   * Clones can be used concurrently in multiple threads.
sl@0
  2852
   * If a subclass does not implement clone(), or if an error occurs,
sl@0
  2853
   * then NULL is returned.
sl@0
  2854
   * The clone functions in all subclasses return a pointer to a Replaceable
sl@0
  2855
   * because some compilers do not support covariant (same-as-this)
sl@0
  2856
   * return types; cast to the appropriate subclass if necessary.
sl@0
  2857
   * The caller must delete the clone.
sl@0
  2858
   *
sl@0
  2859
   * @return a clone of this object
sl@0
  2860
   *
sl@0
  2861
   * @see Replaceable::clone
sl@0
  2862
   * @see getDynamicClassID
sl@0
  2863
   * @stable ICU 2.6
sl@0
  2864
   */
sl@0
  2865
  virtual Replaceable *clone() const;
sl@0
  2866
sl@0
  2867
  /** Destructor.
sl@0
  2868
   * @stable ICU 2.0
sl@0
  2869
   */
sl@0
  2870
  virtual ~UnicodeString();
sl@0
  2871
sl@0
  2872
sl@0
  2873
  /* Miscellaneous operations */
sl@0
  2874
sl@0
  2875
  /**
sl@0
  2876
   * Unescape a string of characters and return a string containing
sl@0
  2877
   * the result.  The following escape sequences are recognized:
sl@0
  2878
   *
sl@0
  2879
   * \\uhhhh       4 hex digits; h in [0-9A-Fa-f]
sl@0
  2880
   * \\Uhhhhhhhh   8 hex digits
sl@0
  2881
   * \\xhh         1-2 hex digits
sl@0
  2882
   * \\ooo         1-3 octal digits; o in [0-7]
sl@0
  2883
   * \\cX          control-X; X is masked with 0x1F
sl@0
  2884
   *
sl@0
  2885
   * as well as the standard ANSI C escapes:
sl@0
  2886
   *
sl@0
  2887
   * \\a => U+0007, \\b => U+0008, \\t => U+0009, \\n => U+000A,
sl@0
  2888
   * \\v => U+000B, \\f => U+000C, \\r => U+000D, \\e => U+001B,
sl@0
  2889
   * \\" => U+0022, \\' => U+0027, \\? => U+003F, \\\\ => U+005C
sl@0
  2890
   *
sl@0
  2891
   * Anything else following a backslash is generically escaped.  For
sl@0
  2892
   * example, "[a\\-z]" returns "[a-z]".
sl@0
  2893
   *
sl@0
  2894
   * If an escape sequence is ill-formed, this method returns an empty
sl@0
  2895
   * string.  An example of an ill-formed sequence is "\\u" followed by
sl@0
  2896
   * fewer than 4 hex digits.
sl@0
  2897
   *
sl@0
  2898
   * This function is similar to u_unescape() but not identical to it.
sl@0
  2899
   * The latter takes a source char*, so it does escape recognition
sl@0
  2900
   * and also invariant conversion.
sl@0
  2901
   *
sl@0
  2902
   * @return a string with backslash escapes interpreted, or an
sl@0
  2903
   * empty string on error.
sl@0
  2904
   * @see UnicodeString#unescapeAt()
sl@0
  2905
   * @see u_unescape()
sl@0
  2906
   * @see u_unescapeAt()
sl@0
  2907
   * @stable ICU 2.0
sl@0
  2908
   */
sl@0
  2909
  UnicodeString unescape() const;
sl@0
  2910
sl@0
  2911
  /**
sl@0
  2912
   * Unescape a single escape sequence and return the represented
sl@0
  2913
   * character.  See unescape() for a listing of the recognized escape
sl@0
  2914
   * sequences.  The character at offset-1 is assumed (without
sl@0
  2915
   * checking) to be a backslash.  If the escape sequence is
sl@0
  2916
   * ill-formed, or the offset is out of range, (UChar32)0xFFFFFFFF is
sl@0
  2917
   * returned.
sl@0
  2918
   *
sl@0
  2919
   * @param offset an input output parameter.  On input, it is the
sl@0
  2920
   * offset into this string where the escape sequence is located,
sl@0
  2921
   * after the initial backslash.  On output, it is advanced after the
sl@0
  2922
   * last character parsed.  On error, it is not advanced at all.
sl@0
  2923
   * @return the character represented by the escape sequence at
sl@0
  2924
   * offset, or (UChar32)0xFFFFFFFF on error.
sl@0
  2925
   * @see UnicodeString#unescape()
sl@0
  2926
   * @see u_unescape()
sl@0
  2927
   * @see u_unescapeAt()
sl@0
  2928
   * @stable ICU 2.0
sl@0
  2929
   */
sl@0
  2930
  UChar32 unescapeAt(int32_t &offset) const;
sl@0
  2931
sl@0
  2932
  /**
sl@0
  2933
   * ICU "poor man's RTTI", returns a UClassID for this class.
sl@0
  2934
   *
sl@0
  2935
   * @stable ICU 2.2
sl@0
  2936
   */
sl@0
  2937
  static UClassID U_EXPORT2 getStaticClassID();
sl@0
  2938
sl@0
  2939
  /**
sl@0
  2940
   * ICU "poor man's RTTI", returns a UClassID for the actual class.
sl@0
  2941
   *
sl@0
  2942
   * @stable ICU 2.2
sl@0
  2943
   */
sl@0
  2944
  virtual UClassID getDynamicClassID() const;
sl@0
  2945
sl@0
  2946
  //========================================
sl@0
  2947
  // Implementation methods
sl@0
  2948
  //========================================
sl@0
  2949
sl@0
  2950
protected:
sl@0
  2951
  /**
sl@0
  2952
   * Implement Replaceable::getLength() (see jitterbug 1027).
sl@0
  2953
   * @stable ICU 2.4
sl@0
  2954
   */
sl@0
  2955
  virtual int32_t getLength() const;
sl@0
  2956
sl@0
  2957
  /**
sl@0
  2958
   * The change in Replaceable to use virtual getCharAt() allows
sl@0
  2959
   * UnicodeString::charAt() to be inline again (see jitterbug 709).
sl@0
  2960
   * @stable ICU 2.4
sl@0
  2961
   */
sl@0
  2962
  virtual UChar getCharAt(int32_t offset) const;
sl@0
  2963
sl@0
  2964
  /**
sl@0
  2965
   * The change in Replaceable to use virtual getChar32At() allows
sl@0
  2966
   * UnicodeString::char32At() to be inline again (see jitterbug 709).
sl@0
  2967
   * @stable ICU 2.4
sl@0
  2968
   */
sl@0
  2969
  virtual UChar32 getChar32At(int32_t offset) const;
sl@0
  2970
sl@0
  2971
private:
sl@0
  2972
sl@0
  2973
  inline int8_t
sl@0
  2974
  doCompare(int32_t start,
sl@0
  2975
           int32_t length,
sl@0
  2976
           const UnicodeString& srcText,
sl@0
  2977
           int32_t srcStart,
sl@0
  2978
           int32_t srcLength) const;
sl@0
  2979
sl@0
  2980
  int8_t doCompare(int32_t start,
sl@0
  2981
           int32_t length,
sl@0
  2982
           const UChar *srcChars,
sl@0
  2983
           int32_t srcStart,
sl@0
  2984
           int32_t srcLength) const;
sl@0
  2985
sl@0
  2986
  inline int8_t
sl@0
  2987
  doCompareCodePointOrder(int32_t start,
sl@0
  2988
                          int32_t length,
sl@0
  2989
                          const UnicodeString& srcText,
sl@0
  2990
                          int32_t srcStart,
sl@0
  2991
                          int32_t srcLength) const;
sl@0
  2992
sl@0
  2993
  int8_t doCompareCodePointOrder(int32_t start,
sl@0
  2994
                                 int32_t length,
sl@0
  2995
                                 const UChar *srcChars,
sl@0
  2996
                                 int32_t srcStart,
sl@0
  2997
                                 int32_t srcLength) const;
sl@0
  2998
sl@0
  2999
  inline int8_t
sl@0
  3000
  doCaseCompare(int32_t start,
sl@0
  3001
                int32_t length,
sl@0
  3002
                const UnicodeString &srcText,
sl@0
  3003
                int32_t srcStart,
sl@0
  3004
                int32_t srcLength,
sl@0
  3005
                uint32_t options) const;
sl@0
  3006
sl@0
  3007
  int8_t
sl@0
  3008
  doCaseCompare(int32_t start,
sl@0
  3009
                int32_t length,
sl@0
  3010
                const UChar *srcChars,
sl@0
  3011
                int32_t srcStart,
sl@0
  3012
                int32_t srcLength,
sl@0
  3013
                uint32_t options) const;
sl@0
  3014
sl@0
  3015
  int32_t doIndexOf(UChar c,
sl@0
  3016
            int32_t start,
sl@0
  3017
            int32_t length) const;
sl@0
  3018
sl@0
  3019
  int32_t doIndexOf(UChar32 c,
sl@0
  3020
                        int32_t start,
sl@0
  3021
                        int32_t length) const;
sl@0
  3022
sl@0
  3023
  int32_t doLastIndexOf(UChar c,
sl@0
  3024
                int32_t start,
sl@0
  3025
                int32_t length) const;
sl@0
  3026
sl@0
  3027
  int32_t doLastIndexOf(UChar32 c,
sl@0
  3028
                            int32_t start,
sl@0
  3029
                            int32_t length) const;
sl@0
  3030
sl@0
  3031
  void doExtract(int32_t start,
sl@0
  3032
         int32_t length,
sl@0
  3033
         UChar *dst,
sl@0
  3034
         int32_t dstStart) const;
sl@0
  3035
sl@0
  3036
  inline void doExtract(int32_t start,
sl@0
  3037
         int32_t length,
sl@0
  3038
         UnicodeString& target) const;
sl@0
  3039
sl@0
  3040
  inline UChar doCharAt(int32_t offset)  const;
sl@0
  3041
sl@0
  3042
  UnicodeString& doReplace(int32_t start,
sl@0
  3043
               int32_t length,
sl@0
  3044
               const UnicodeString& srcText,
sl@0
  3045
               int32_t srcStart,
sl@0
  3046
               int32_t srcLength);
sl@0
  3047
sl@0
  3048
  UnicodeString& doReplace(int32_t start,
sl@0
  3049
               int32_t length,
sl@0
  3050
               const UChar *srcChars,
sl@0
  3051
               int32_t srcStart,
sl@0
  3052
               int32_t srcLength);
sl@0
  3053
sl@0
  3054
  UnicodeString& doReverse(int32_t start,
sl@0
  3055
               int32_t length);
sl@0
  3056
sl@0
  3057
  // calculate hash code
sl@0
  3058
  int32_t doHashCode(void) const;
sl@0
  3059
sl@0
  3060
  // get pointer to start of array
sl@0
  3061
  inline UChar* getArrayStart(void);
sl@0
  3062
  inline const UChar* getArrayStart(void) const;
sl@0
  3063
sl@0
  3064
  // allocate the array; result may be fStackBuffer
sl@0
  3065
  // sets refCount to 1 if appropriate
sl@0
  3066
  // sets fArray, fCapacity, and fFlags
sl@0
  3067
  // returns boolean for success or failure
sl@0
  3068
  UBool allocate(int32_t capacity);
sl@0
  3069
sl@0
  3070
  // release the array if owned
sl@0
  3071
  void releaseArray(void);
sl@0
  3072
sl@0
  3073
  // turn a bogus string into an empty one
sl@0
  3074
  void unBogus();
sl@0
  3075
sl@0
  3076
  // implements assigment operator, copy constructor, and fastCopyFrom()
sl@0
  3077
  UnicodeString &copyFrom(const UnicodeString &src, UBool fastCopy=FALSE);
sl@0
  3078
sl@0
  3079
  // Pin start and limit to acceptable values.
sl@0
  3080
  inline void pinIndex(int32_t& start) const;
sl@0
  3081
  inline void pinIndices(int32_t& start,
sl@0
  3082
                         int32_t& length) const;
sl@0
  3083
sl@0
  3084
#if !UCONFIG_NO_CONVERSION
sl@0
  3085
sl@0
  3086
  /* Internal extract() using UConverter. */
sl@0
  3087
  int32_t doExtract(int32_t start, int32_t length,
sl@0
  3088
                    char *dest, int32_t destCapacity,
sl@0
  3089
                    UConverter *cnv,
sl@0
  3090
                    UErrorCode &errorCode) const;
sl@0
  3091
sl@0
  3092
  /*
sl@0
  3093
   * Real constructor for converting from codepage data.
sl@0
  3094
   * It assumes that it is called with !fRefCounted.
sl@0
  3095
   *
sl@0
  3096
   * If <code>codepage==0</code>, then the default converter
sl@0
  3097
   * is used for the platform encoding.
sl@0
  3098
   * If <code>codepage</code> is an empty string (<code>""</code>),
sl@0
  3099
   * then a simple conversion is performed on the codepage-invariant
sl@0
  3100
   * subset ("invariant characters") of the platform encoding. See utypes.h.
sl@0
  3101
   */
sl@0
  3102
  void doCodepageCreate(const char *codepageData,
sl@0
  3103
                        int32_t dataLength,
sl@0
  3104
                        const char *codepage);
sl@0
  3105
sl@0
  3106
  /*
sl@0
  3107
   * Worker function for creating a UnicodeString from
sl@0
  3108
   * a codepage string using a UConverter.
sl@0
  3109
   */
sl@0
  3110
  void
sl@0
  3111
  doCodepageCreate(const char *codepageData,
sl@0
  3112
                   int32_t dataLength,
sl@0
  3113
                   UConverter *converter,
sl@0
  3114
                   UErrorCode &status);
sl@0
  3115
sl@0
  3116
#endif
sl@0
  3117
sl@0
  3118
  /*
sl@0
  3119
   * This function is called when write access to the array
sl@0
  3120
   * is necessary.
sl@0
  3121
   *
sl@0
  3122
   * We need to make a copy of the array if
sl@0
  3123
   * the buffer is read-only, or
sl@0
  3124
   * the buffer is refCounted (shared), and refCount>1, or
sl@0
  3125
   * the buffer is too small.
sl@0
  3126
   *
sl@0
  3127
   * Return FALSE if memory could not be allocated.
sl@0
  3128
   */
sl@0
  3129
  UBool cloneArrayIfNeeded(int32_t newCapacity = -1,
sl@0
  3130
                            int32_t growCapacity = -1,
sl@0
  3131
                            UBool doCopyArray = TRUE,
sl@0
  3132
                            int32_t **pBufferToDelete = 0,
sl@0
  3133
                            UBool forceClone = FALSE);
sl@0
  3134
sl@0
  3135
  // common function for case mappings
sl@0
  3136
  UnicodeString &
sl@0
  3137
  caseMap(BreakIterator *titleIter,
sl@0
  3138
          const char *locale,
sl@0
  3139
          uint32_t options,
sl@0
  3140
          int32_t toWhichCase);
sl@0
  3141
sl@0
  3142
  // ref counting
sl@0
  3143
  void addRef(void);
sl@0
  3144
  int32_t removeRef(void);
sl@0
  3145
  int32_t refCount(void) const;
sl@0
  3146
sl@0
  3147
  // constants
sl@0
  3148
  enum {
sl@0
  3149
    US_STACKBUF_SIZE=7, // Size of stack buffer for small strings
sl@0
  3150
    kInvalidUChar=0xffff, // invalid UChar index
sl@0
  3151
    kGrowSize=128, // grow size for this buffer
sl@0
  3152
    kInvalidHashCode=0, // invalid hash code
sl@0
  3153
    kEmptyHashCode=1, // hash code for empty string
sl@0
  3154
sl@0
  3155
    // bit flag values for fFlags
sl@0
  3156
    kIsBogus=1,         // this string is bogus, i.e., not valid or NULL
sl@0
  3157
    kUsingStackBuffer=2,// fArray==fStackBuffer
sl@0
  3158
    kRefCounted=4,      // there is a refCount field before the characters in fArray
sl@0
  3159
    kBufferIsReadonly=8,// do not write to this buffer
sl@0
  3160
    kOpenGetBuffer=16,  // getBuffer(minCapacity) was called (is "open"),
sl@0
  3161
                        // and releaseBuffer(newLength) must be called
sl@0
  3162
sl@0
  3163
    // combined values for convenience
sl@0
  3164
    kShortString=kUsingStackBuffer,
sl@0
  3165
    kLongString=kRefCounted,
sl@0
  3166
    kReadonlyAlias=kBufferIsReadonly,
sl@0
  3167
    kWritableAlias=0
sl@0
  3168
  };
sl@0
  3169
sl@0
  3170
  friend class StringCharacterIterator;
sl@0
  3171
  friend class StringThreadTest;
sl@0
  3172
sl@0
  3173
  /*
sl@0
  3174
   * The following are all the class fields that are stored
sl@0
  3175
   * in each UnicodeString object.
sl@0
  3176
   * Note that UnicodeString has virtual functions,
sl@0
  3177
   * therefore there is an implicit vtable pointer
sl@0
  3178
   * as the first real field.
sl@0
  3179
   * The fields should be aligned such that no padding is
sl@0
  3180
   * necessary, mostly by having larger types first.
sl@0
  3181
   * On 32-bit machines, the size should be 32 bytes,
sl@0
  3182
   * on 64-bit machines (8-byte pointers), it should be 40 bytes.
sl@0
  3183
   */
sl@0
  3184
  // (implicit) *vtable;
sl@0
  3185
  int32_t   fLength;        // number of characters in fArray
sl@0
  3186
  int32_t   fCapacity;      // sizeof fArray
sl@0
  3187
  UChar     *fArray;        // the Unicode data
sl@0
  3188
  uint16_t  fFlags;         // bit flags: see constants above
sl@0
  3189
  UChar     fStackBuffer [ US_STACKBUF_SIZE ]; // buffer for small strings
sl@0
  3190
sl@0
  3191
};
sl@0
  3192
sl@0
  3193
/**
sl@0
  3194
 * Create a new UnicodeString with the concatenation of two others.
sl@0
  3195
 *
sl@0
  3196
 * @param s1 The first string to be copied to the new one.
sl@0
  3197
 * @param s2 The second string to be copied to the new one, after s1.
sl@0
  3198
 * @return UnicodeString(s1).append(s2)
sl@0
  3199
 * @stable ICU 2.8
sl@0
  3200
 */
sl@0
  3201
U_COMMON_API UnicodeString U_EXPORT2
sl@0
  3202
operator+ (const UnicodeString &s1, const UnicodeString &s2);
sl@0
  3203
sl@0
  3204
U_NAMESPACE_END
sl@0
  3205
sl@0
  3206
// inline implementations -------------------------------------------------- ***
sl@0
  3207
sl@0
  3208
//========================================
sl@0
  3209
// Array copying
sl@0
  3210
//========================================
sl@0
  3211
/**
sl@0
  3212
 * Copy an array of UnicodeString OBJECTS (not pointers).
sl@0
  3213
 * @internal
sl@0
  3214
 */
sl@0
  3215
inline void
sl@0
  3216
uprv_arrayCopy(const U_NAMESPACE_QUALIFIER UnicodeString *src, U_NAMESPACE_QUALIFIER UnicodeString *dst, int32_t count)
sl@0
  3217
{ while(count-- > 0) *dst++ = *src++; }
sl@0
  3218
sl@0
  3219
/**
sl@0
  3220
 * Copy an array of UnicodeString OBJECTS (not pointers).
sl@0
  3221
 * @internal
sl@0
  3222
 */
sl@0
  3223
inline void
sl@0
  3224
uprv_arrayCopy(const U_NAMESPACE_QUALIFIER UnicodeString *src, int32_t srcStart,
sl@0
  3225
        U_NAMESPACE_QUALIFIER UnicodeString *dst, int32_t dstStart, int32_t count)
sl@0
  3226
{ uprv_arrayCopy(src+srcStart, dst+dstStart, count); }
sl@0
  3227
sl@0
  3228
U_NAMESPACE_BEGIN
sl@0
  3229
sl@0
  3230
//========================================
sl@0
  3231
// Inline members
sl@0
  3232
//========================================
sl@0
  3233
sl@0
  3234
//========================================
sl@0
  3235
// Privates
sl@0
  3236
//========================================
sl@0
  3237
sl@0
  3238
inline void
sl@0
  3239
UnicodeString::pinIndex(int32_t& start) const
sl@0
  3240
{
sl@0
  3241
  // pin index
sl@0
  3242
  if(start < 0) {
sl@0
  3243
    start = 0;
sl@0
  3244
  } else if(start > fLength) {
sl@0
  3245
    start = fLength;
sl@0
  3246
  }
sl@0
  3247
}
sl@0
  3248
sl@0
  3249
inline void
sl@0
  3250
UnicodeString::pinIndices(int32_t& start,
sl@0
  3251
                          int32_t& _length) const
sl@0
  3252
{
sl@0
  3253
  // pin indices
sl@0
  3254
  if(start < 0) {
sl@0
  3255
    start = 0;
sl@0
  3256
  } else if(start > fLength) {
sl@0
  3257
    start = fLength;
sl@0
  3258
  }
sl@0
  3259
  if(_length < 0) {
sl@0
  3260
    _length = 0;
sl@0
  3261
  } else if(_length > (fLength - start)) {
sl@0
  3262
    _length = (fLength - start);
sl@0
  3263
  }
sl@0
  3264
}
sl@0
  3265
sl@0
  3266
inline UChar*
sl@0
  3267
UnicodeString::getArrayStart()
sl@0
  3268
{ return fArray; }
sl@0
  3269
sl@0
  3270
inline const UChar*
sl@0
  3271
UnicodeString::getArrayStart() const
sl@0
  3272
{ return fArray; }
sl@0
  3273
sl@0
  3274
//========================================
sl@0
  3275
// Read-only implementation methods
sl@0
  3276
//========================================
sl@0
  3277
inline int32_t
sl@0
  3278
UnicodeString::length() const
sl@0
  3279
{ return fLength; }
sl@0
  3280
sl@0
  3281
inline int32_t
sl@0
  3282
UnicodeString::getCapacity() const
sl@0
  3283
{ return fCapacity; }
sl@0
  3284
sl@0
  3285
inline int32_t
sl@0
  3286
UnicodeString::hashCode() const
sl@0
  3287
{ return doHashCode(); }
sl@0
  3288
sl@0
  3289
inline UBool
sl@0
  3290
UnicodeString::isBogus() const
sl@0
  3291
{ return (UBool)(fFlags & kIsBogus); }
sl@0
  3292
sl@0
  3293
inline const UChar *
sl@0
  3294
UnicodeString::getBuffer() const {
sl@0
  3295
  if(!(fFlags&(kIsBogus|kOpenGetBuffer))) {
sl@0
  3296
    return fArray;
sl@0
  3297
  } else {
sl@0
  3298
    return 0;
sl@0
  3299
  }
sl@0
  3300
}
sl@0
  3301
sl@0
  3302
//========================================
sl@0
  3303
// Read-only alias methods
sl@0
  3304
//========================================
sl@0
  3305
inline int8_t
sl@0
  3306
UnicodeString::doCompare(int32_t start,
sl@0
  3307
              int32_t length,
sl@0
  3308
              const UnicodeString& srcText,
sl@0
  3309
              int32_t srcStart,
sl@0
  3310
              int32_t srcLength) const
sl@0
  3311
{
sl@0
  3312
  if(srcText.isBogus()) {
sl@0
  3313
    return (int8_t)!isBogus(); // 0 if both are bogus, 1 otherwise
sl@0
  3314
  } else {
sl@0
  3315
    srcText.pinIndices(srcStart, srcLength);
sl@0
  3316
    return doCompare(start, length, srcText.fArray, srcStart, srcLength);
sl@0
  3317
  }
sl@0
  3318
}
sl@0
  3319
sl@0
  3320
inline UBool
sl@0
  3321
UnicodeString::operator== (const UnicodeString& text) const
sl@0
  3322
{
sl@0
  3323
  if(isBogus()) {
sl@0
  3324
    return text.isBogus();
sl@0
  3325
  } else {
sl@0
  3326
    return
sl@0
  3327
      !text.isBogus() &&
sl@0
  3328
      fLength == text.fLength &&
sl@0
  3329
      doCompare(0, fLength, text, 0, text.fLength) == 0;
sl@0
  3330
  }
sl@0
  3331
}
sl@0
  3332
sl@0
  3333
inline UBool
sl@0
  3334
UnicodeString::operator!= (const UnicodeString& text) const
sl@0
  3335
{ return (! operator==(text)); }
sl@0
  3336
sl@0
  3337
inline UBool
sl@0
  3338
UnicodeString::operator> (const UnicodeString& text) const
sl@0
  3339
{ return doCompare(0, fLength, text, 0, text.fLength) == 1; }
sl@0
  3340
sl@0
  3341
inline UBool
sl@0
  3342
UnicodeString::operator< (const UnicodeString& text) const
sl@0
  3343
{ return doCompare(0, fLength, text, 0, text.fLength) == -1; }
sl@0
  3344
sl@0
  3345
inline UBool
sl@0
  3346
UnicodeString::operator>= (const UnicodeString& text) const
sl@0
  3347
{ return doCompare(0, fLength, text, 0, text.fLength) != -1; }
sl@0
  3348
sl@0
  3349
inline UBool
sl@0
  3350
UnicodeString::operator<= (const UnicodeString& text) const
sl@0
  3351
{ return doCompare(0, fLength, text, 0, text.fLength) != 1; }
sl@0
  3352
sl@0
  3353
inline int8_t
sl@0
  3354
UnicodeString::compare(const UnicodeString& text) const
sl@0
  3355
{ return doCompare(0, fLength, text, 0, text.fLength); }
sl@0
  3356
sl@0
  3357
inline int8_t
sl@0
  3358
UnicodeString::compare(int32_t start,
sl@0
  3359
               int32_t _length,
sl@0
  3360
               const UnicodeString& srcText) const
sl@0
  3361
{ return doCompare(start, _length, srcText, 0, srcText.fLength); }
sl@0
  3362
sl@0
  3363
inline int8_t
sl@0
  3364
UnicodeString::compare(const UChar *srcChars,
sl@0
  3365
               int32_t srcLength) const
sl@0
  3366
{ return doCompare(0, fLength, srcChars, 0, srcLength); }
sl@0
  3367
sl@0
  3368
inline int8_t
sl@0
  3369
UnicodeString::compare(int32_t start,
sl@0
  3370
               int32_t _length,
sl@0
  3371
               const UnicodeString& srcText,
sl@0
  3372
               int32_t srcStart,
sl@0
  3373
               int32_t srcLength) const
sl@0
  3374
{ return doCompare(start, _length, srcText, srcStart, srcLength); }
sl@0
  3375
sl@0
  3376
inline int8_t
sl@0
  3377
UnicodeString::compare(int32_t start,
sl@0
  3378
               int32_t _length,
sl@0
  3379
               const UChar *srcChars) const
sl@0
  3380
{ return doCompare(start, _length, srcChars, 0, _length); }
sl@0
  3381
sl@0
  3382
inline int8_t
sl@0
  3383
UnicodeString::compare(int32_t start,
sl@0
  3384
               int32_t _length,
sl@0
  3385
               const UChar *srcChars,
sl@0
  3386
               int32_t srcStart,
sl@0
  3387
               int32_t srcLength) const
sl@0
  3388
{ return doCompare(start, _length, srcChars, srcStart, srcLength); }
sl@0
  3389
sl@0
  3390
inline int8_t
sl@0
  3391
UnicodeString::compareBetween(int32_t start,
sl@0
  3392
                  int32_t limit,
sl@0
  3393
                  const UnicodeString& srcText,
sl@0
  3394
                  int32_t srcStart,
sl@0
  3395
                  int32_t srcLimit) const
sl@0
  3396
{ return doCompare(start, limit - start,
sl@0
  3397
           srcText, srcStart, srcLimit - srcStart); }
sl@0
  3398
sl@0
  3399
inline int8_t
sl@0
  3400
UnicodeString::doCompareCodePointOrder(int32_t start,
sl@0
  3401
                                       int32_t length,
sl@0
  3402
                                       const UnicodeString& srcText,
sl@0
  3403
                                       int32_t srcStart,
sl@0
  3404
                                       int32_t srcLength) const
sl@0
  3405
{
sl@0
  3406
  if(srcText.isBogus()) {
sl@0
  3407
    return (int8_t)!isBogus(); // 0 if both are bogus, 1 otherwise
sl@0
  3408
  } else {
sl@0
  3409
    srcText.pinIndices(srcStart, srcLength);
sl@0
  3410
    return doCompareCodePointOrder(start, length, srcText.fArray, srcStart, srcLength);
sl@0
  3411
  }
sl@0
  3412
}
sl@0
  3413
sl@0
  3414
inline int8_t
sl@0
  3415
UnicodeString::compareCodePointOrder(const UnicodeString& text) const
sl@0
  3416
{ return doCompareCodePointOrder(0, fLength, text, 0, text.fLength); }
sl@0
  3417
sl@0
  3418
inline int8_t
sl@0
  3419
UnicodeString::compareCodePointOrder(int32_t start,
sl@0
  3420
                                     int32_t _length,
sl@0
  3421
                                     const UnicodeString& srcText) const
sl@0
  3422
{ return doCompareCodePointOrder(start, _length, srcText, 0, srcText.fLength); }
sl@0
  3423
sl@0
  3424
inline int8_t
sl@0
  3425
UnicodeString::compareCodePointOrder(const UChar *srcChars,
sl@0
  3426
                                     int32_t srcLength) const
sl@0
  3427
{ return doCompareCodePointOrder(0, fLength, srcChars, 0, srcLength); }
sl@0
  3428
sl@0
  3429
inline int8_t
sl@0
  3430
UnicodeString::compareCodePointOrder(int32_t start,
sl@0
  3431
                                     int32_t _length,
sl@0
  3432
                                     const UnicodeString& srcText,
sl@0
  3433
                                     int32_t srcStart,
sl@0
  3434
                                     int32_t srcLength) const
sl@0
  3435
{ return doCompareCodePointOrder(start, _length, srcText, srcStart, srcLength); }
sl@0
  3436
sl@0
  3437
inline int8_t
sl@0
  3438
UnicodeString::compareCodePointOrder(int32_t start,
sl@0
  3439
                                     int32_t _length,
sl@0
  3440
                                     const UChar *srcChars) const
sl@0
  3441
{ return doCompareCodePointOrder(start, _length, srcChars, 0, _length); }
sl@0
  3442
sl@0
  3443
inline int8_t
sl@0
  3444
UnicodeString::compareCodePointOrder(int32_t start,
sl@0
  3445
                                     int32_t _length,
sl@0
  3446
                                     const UChar *srcChars,
sl@0
  3447
                                     int32_t srcStart,
sl@0
  3448
                                     int32_t srcLength) const
sl@0
  3449
{ return doCompareCodePointOrder(start, _length, srcChars, srcStart, srcLength); }
sl@0
  3450
sl@0
  3451
inline int8_t
sl@0
  3452
UnicodeString::compareCodePointOrderBetween(int32_t start,
sl@0
  3453
                                            int32_t limit,
sl@0
  3454
                                            const UnicodeString& srcText,
sl@0
  3455
                                            int32_t srcStart,
sl@0
  3456
                                            int32_t srcLimit) const
sl@0
  3457
{ return doCompareCodePointOrder(start, limit - start,
sl@0
  3458
           srcText, srcStart, srcLimit - srcStart); }
sl@0
  3459
sl@0
  3460
inline int8_t
sl@0
  3461
UnicodeString::doCaseCompare(int32_t start,
sl@0
  3462
                             int32_t length,
sl@0
  3463
                             const UnicodeString &srcText,
sl@0
  3464
                             int32_t srcStart,
sl@0
  3465
                             int32_t srcLength,
sl@0
  3466
                             uint32_t options) const
sl@0
  3467
{
sl@0
  3468
  if(srcText.isBogus()) {
sl@0
  3469
    return (int8_t)!isBogus(); // 0 if both are bogus, 1 otherwise
sl@0
  3470
  } else {
sl@0
  3471
    srcText.pinIndices(srcStart, srcLength);
sl@0
  3472
    return doCaseCompare(start, length, srcText.fArray, srcStart, srcLength, options);
sl@0
  3473
  }
sl@0
  3474
}
sl@0
  3475
sl@0
  3476
inline int8_t
sl@0
  3477
UnicodeString::caseCompare(const UnicodeString &text, uint32_t options) const {
sl@0
  3478
  return doCaseCompare(0, fLength, text, 0, text.fLength, options);
sl@0
  3479
}
sl@0
  3480
sl@0
  3481
inline int8_t
sl@0
  3482
UnicodeString::caseCompare(int32_t start,
sl@0
  3483
                           int32_t _length,
sl@0
  3484
                           const UnicodeString &srcText,
sl@0
  3485
                           uint32_t options) const {
sl@0
  3486
  return doCaseCompare(start, _length, srcText, 0, srcText.fLength, options);
sl@0
  3487
}
sl@0
  3488
sl@0
  3489
inline int8_t
sl@0
  3490
UnicodeString::caseCompare(const UChar *srcChars,
sl@0
  3491
                           int32_t srcLength,
sl@0
  3492
                           uint32_t options) const {
sl@0
  3493
  return doCaseCompare(0, fLength, srcChars, 0, srcLength, options);
sl@0
  3494
}
sl@0
  3495
sl@0
  3496
inline int8_t
sl@0
  3497
UnicodeString::caseCompare(int32_t start,
sl@0
  3498
                           int32_t _length,
sl@0
  3499
                           const UnicodeString &srcText,
sl@0
  3500
                           int32_t srcStart,
sl@0
  3501
                           int32_t srcLength,
sl@0
  3502
                           uint32_t options) const {
sl@0
  3503
  return doCaseCompare(start, _length, srcText, srcStart, srcLength, options);
sl@0
  3504
}
sl@0
  3505
sl@0
  3506
inline int8_t
sl@0
  3507
UnicodeString::caseCompare(int32_t start,
sl@0
  3508
                           int32_t _length,
sl@0
  3509
                           const UChar *srcChars,
sl@0
  3510
                           uint32_t options) const {
sl@0
  3511
  return doCaseCompare(start, _length, srcChars, 0, _length, options);
sl@0
  3512
}
sl@0
  3513
sl@0
  3514
inline int8_t
sl@0
  3515
UnicodeString::caseCompare(int32_t start,
sl@0
  3516
                           int32_t _length,
sl@0
  3517
                           const UChar *srcChars,
sl@0
  3518
                           int32_t srcStart,
sl@0
  3519
                           int32_t srcLength,
sl@0
  3520
                           uint32_t options) const {
sl@0
  3521
  return doCaseCompare(start, _length, srcChars, srcStart, srcLength, options);
sl@0
  3522
}
sl@0
  3523
sl@0
  3524
inline int8_t
sl@0
  3525
UnicodeString::caseCompareBetween(int32_t start,
sl@0
  3526
                                  int32_t limit,
sl@0
  3527
                                  const UnicodeString &srcText,
sl@0
  3528
                                  int32_t srcStart,
sl@0
  3529
                                  int32_t srcLimit,
sl@0
  3530
                                  uint32_t options) const {
sl@0
  3531
  return doCaseCompare(start, limit - start, srcText, srcStart, srcLimit - srcStart, options);
sl@0
  3532
}
sl@0
  3533
sl@0
  3534
inline int32_t
sl@0
  3535
UnicodeString::indexOf(const UnicodeString& srcText,
sl@0
  3536
               int32_t srcStart,
sl@0
  3537
               int32_t srcLength,
sl@0
  3538
               int32_t start,
sl@0
  3539
               int32_t _length) const
sl@0
  3540
{
sl@0
  3541
  if(!srcText.isBogus()) {
sl@0
  3542
    srcText.pinIndices(srcStart, srcLength);
sl@0
  3543
    if(srcLength > 0) {
sl@0
  3544
      return indexOf(srcText.getArrayStart(), srcStart, srcLength, start, _length);
sl@0
  3545
    }
sl@0
  3546
  }
sl@0
  3547
  return -1;
sl@0
  3548
}
sl@0
  3549
sl@0
  3550
inline int32_t
sl@0
  3551
UnicodeString::indexOf(const UnicodeString& text) const
sl@0
  3552
{ return indexOf(text, 0, text.fLength, 0, fLength); }
sl@0
  3553
sl@0
  3554
inline int32_t
sl@0
  3555
UnicodeString::indexOf(const UnicodeString& text,
sl@0
  3556
               int32_t start) const {
sl@0
  3557
  pinIndex(start);
sl@0
  3558
  return indexOf(text, 0, text.fLength, start, fLength - start);
sl@0
  3559
}
sl@0
  3560
sl@0
  3561
inline int32_t
sl@0
  3562
UnicodeString::indexOf(const UnicodeString& text,
sl@0
  3563
               int32_t start,
sl@0
  3564
               int32_t _length) const
sl@0
  3565
{ return indexOf(text, 0, text.fLength, start, _length); }
sl@0
  3566
sl@0
  3567
inline int32_t
sl@0
  3568
UnicodeString::indexOf(const UChar *srcChars,
sl@0
  3569
               int32_t srcLength,
sl@0
  3570
               int32_t start) const {
sl@0
  3571
  pinIndex(start);
sl@0
  3572
  return indexOf(srcChars, 0, srcLength, start, fLength - start);
sl@0
  3573
}
sl@0
  3574
sl@0
  3575
inline int32_t
sl@0
  3576
UnicodeString::indexOf(const UChar *srcChars,
sl@0
  3577
               int32_t srcLength,
sl@0
  3578
               int32_t start,
sl@0
  3579
               int32_t _length) const
sl@0
  3580
{ return indexOf(srcChars, 0, srcLength, start, _length); }
sl@0
  3581
sl@0
  3582
inline int32_t
sl@0
  3583
UnicodeString::indexOf(UChar c,
sl@0
  3584
               int32_t start,
sl@0
  3585
               int32_t _length) const
sl@0
  3586
{ return doIndexOf(c, start, _length); }
sl@0
  3587
sl@0
  3588
inline int32_t
sl@0
  3589
UnicodeString::indexOf(UChar32 c,
sl@0
  3590
               int32_t start,
sl@0
  3591
               int32_t _length) const
sl@0
  3592
{ return doIndexOf(c, start, _length); }
sl@0
  3593
sl@0
  3594
inline int32_t
sl@0
  3595
UnicodeString::indexOf(UChar c) const
sl@0
  3596
{ return doIndexOf(c, 0, fLength); }
sl@0
  3597
sl@0
  3598
inline int32_t
sl@0
  3599
UnicodeString::indexOf(UChar32 c) const
sl@0
  3600
{ return indexOf(c, 0, fLength); }
sl@0
  3601
sl@0
  3602
inline int32_t
sl@0
  3603
UnicodeString::indexOf(UChar c,
sl@0
  3604
               int32_t start) const {
sl@0
  3605
  pinIndex(start);
sl@0
  3606
  return doIndexOf(c, start, fLength - start);
sl@0
  3607
}
sl@0
  3608
sl@0
  3609
inline int32_t
sl@0
  3610
UnicodeString::indexOf(UChar32 c,
sl@0
  3611
               int32_t start) const {
sl@0
  3612
  pinIndex(start);
sl@0
  3613
  return indexOf(c, start, fLength - start);
sl@0
  3614
}
sl@0
  3615
sl@0
  3616
inline int32_t
sl@0
  3617
UnicodeString::lastIndexOf(const UChar *srcChars,
sl@0
  3618
               int32_t srcLength,
sl@0
  3619
               int32_t start,
sl@0
  3620
               int32_t _length) const
sl@0
  3621
{ return lastIndexOf(srcChars, 0, srcLength, start, _length); }
sl@0
  3622
sl@0
  3623
inline int32_t
sl@0
  3624
UnicodeString::lastIndexOf(const UChar *srcChars,
sl@0
  3625
               int32_t srcLength,
sl@0
  3626
               int32_t start) const {
sl@0
  3627
  pinIndex(start);
sl@0
  3628
  return lastIndexOf(srcChars, 0, srcLength, start, fLength - start);
sl@0
  3629
}
sl@0
  3630
sl@0
  3631
inline int32_t
sl@0
  3632
UnicodeString::lastIndexOf(const UnicodeString& srcText,
sl@0
  3633
               int32_t srcStart,
sl@0
  3634
               int32_t srcLength,
sl@0
  3635
               int32_t start,
sl@0
  3636
               int32_t _length) const
sl@0
  3637
{
sl@0
  3638
  if(!srcText.isBogus()) {
sl@0
  3639
    srcText.pinIndices(srcStart, srcLength);
sl@0
  3640
    if(srcLength > 0) {
sl@0
  3641
      return lastIndexOf(srcText.getArrayStart(), srcStart, srcLength, start, _length);
sl@0
  3642
    }
sl@0
  3643
  }
sl@0
  3644
  return -1;
sl@0
  3645
}
sl@0
  3646
sl@0
  3647
inline int32_t
sl@0
  3648
UnicodeString::lastIndexOf(const UnicodeString& text,
sl@0
  3649
               int32_t start,
sl@0
  3650
               int32_t _length) const
sl@0
  3651
{ return lastIndexOf(text, 0, text.fLength, start, _length); }
sl@0
  3652
sl@0
  3653
inline int32_t
sl@0
  3654
UnicodeString::lastIndexOf(const UnicodeString& text,
sl@0
  3655
               int32_t start) const {
sl@0
  3656
  pinIndex(start);
sl@0
  3657
  return lastIndexOf(text, 0, text.fLength, start, fLength - start);
sl@0
  3658
}
sl@0
  3659
sl@0
  3660
inline int32_t
sl@0
  3661
UnicodeString::lastIndexOf(const UnicodeString& text) const
sl@0
  3662
{ return lastIndexOf(text, 0, text.fLength, 0, fLength); }
sl@0
  3663
sl@0
  3664
inline int32_t
sl@0
  3665
UnicodeString::lastIndexOf(UChar c,
sl@0
  3666
               int32_t start,
sl@0
  3667
               int32_t _length) const
sl@0
  3668
{ return doLastIndexOf(c, start, _length); }
sl@0
  3669
sl@0
  3670
inline int32_t
sl@0
  3671
UnicodeString::lastIndexOf(UChar32 c,
sl@0
  3672
               int32_t start,
sl@0
  3673
               int32_t _length) const {
sl@0
  3674
  return doLastIndexOf(c, start, _length);
sl@0
  3675
}
sl@0
  3676
sl@0
  3677
inline int32_t
sl@0
  3678
UnicodeString::lastIndexOf(UChar c) const
sl@0
  3679
{ return doLastIndexOf(c, 0, fLength); }
sl@0
  3680
sl@0
  3681
inline int32_t
sl@0
  3682
UnicodeString::lastIndexOf(UChar32 c) const {
sl@0
  3683
  return lastIndexOf(c, 0, fLength);
sl@0
  3684
}
sl@0
  3685
sl@0
  3686
inline int32_t
sl@0
  3687
UnicodeString::lastIndexOf(UChar c,
sl@0
  3688
               int32_t start) const {
sl@0
  3689
  pinIndex(start);
sl@0
  3690
  return doLastIndexOf(c, start, fLength - start);
sl@0
  3691
}
sl@0
  3692
sl@0
  3693
inline int32_t
sl@0
  3694
UnicodeString::lastIndexOf(UChar32 c,
sl@0
  3695
               int32_t start) const {
sl@0
  3696
  pinIndex(start);
sl@0
  3697
  return lastIndexOf(c, start, fLength - start);
sl@0
  3698
}
sl@0
  3699
sl@0
  3700
inline UBool
sl@0
  3701
UnicodeString::startsWith(const UnicodeString& text) const
sl@0
  3702
{ return compare(0, text.fLength, text, 0, text.fLength) == 0; }
sl@0
  3703
sl@0
  3704
inline UBool
sl@0
  3705
UnicodeString::startsWith(const UnicodeString& srcText,
sl@0
  3706
              int32_t srcStart,
sl@0
  3707
              int32_t srcLength) const
sl@0
  3708
{ return doCompare(0, srcLength, srcText, srcStart, srcLength) == 0; }
sl@0
  3709
sl@0
  3710
inline UBool
sl@0
  3711
UnicodeString::startsWith(const UChar *srcChars,
sl@0
  3712
              int32_t srcLength) const
sl@0
  3713
{ return doCompare(0, srcLength, srcChars, 0, srcLength) == 0; }
sl@0
  3714
sl@0
  3715
inline UBool
sl@0
  3716
UnicodeString::startsWith(const UChar *srcChars,
sl@0
  3717
              int32_t srcStart,
sl@0
  3718
              int32_t srcLength) const
sl@0
  3719
{ return doCompare(0, srcLength, srcChars, srcStart, srcLength) == 0;}
sl@0
  3720
sl@0
  3721
inline UBool
sl@0
  3722
UnicodeString::endsWith(const UnicodeString& text) const
sl@0
  3723
{ return doCompare(fLength - text.fLength, text.fLength,
sl@0
  3724
           text, 0, text.fLength) == 0; }
sl@0
  3725
sl@0
  3726
inline UBool
sl@0
  3727
UnicodeString::endsWith(const UnicodeString& srcText,
sl@0
  3728
            int32_t srcStart,
sl@0
  3729
            int32_t srcLength) const {
sl@0
  3730
  srcText.pinIndices(srcStart, srcLength);
sl@0
  3731
  return doCompare(fLength - srcLength, srcLength,
sl@0
  3732
                   srcText, srcStart, srcLength) == 0;
sl@0
  3733
}
sl@0
  3734
sl@0
  3735
inline UBool
sl@0
  3736
UnicodeString::endsWith(const UChar *srcChars,
sl@0
  3737
            int32_t srcLength) const {
sl@0
  3738
  if(srcLength < 0) {
sl@0
  3739
    srcLength = u_strlen(srcChars);
sl@0
  3740
  }
sl@0
  3741
  return doCompare(fLength - srcLength, srcLength,
sl@0
  3742
                   srcChars, 0, srcLength) == 0;
sl@0
  3743
}
sl@0
  3744
sl@0
  3745
inline UBool
sl@0
  3746
UnicodeString::endsWith(const UChar *srcChars,
sl@0
  3747
            int32_t srcStart,
sl@0
  3748
            int32_t srcLength) const {
sl@0
  3749
  if(srcLength < 0) {
sl@0
  3750
    srcLength = u_strlen(srcChars + srcStart);
sl@0
  3751
  }
sl@0
  3752
  return doCompare(fLength - srcLength, srcLength,
sl@0
  3753
                   srcChars, srcStart, srcLength) == 0;
sl@0
  3754
}
sl@0
  3755
sl@0
  3756
//========================================
sl@0
  3757
// replace
sl@0
  3758
//========================================
sl@0
  3759
inline UnicodeString&
sl@0
  3760
UnicodeString::replace(int32_t start,
sl@0
  3761
               int32_t _length,
sl@0
  3762
               const UnicodeString& srcText)
sl@0
  3763
{ return doReplace(start, _length, srcText, 0, srcText.fLength); }
sl@0
  3764
sl@0
  3765
inline UnicodeString&
sl@0
  3766
UnicodeString::replace(int32_t start,
sl@0
  3767
               int32_t _length,
sl@0
  3768
               const UnicodeString& srcText,
sl@0
  3769
               int32_t srcStart,
sl@0
  3770
               int32_t srcLength)
sl@0
  3771
{ return doReplace(start, _length, srcText, srcStart, srcLength); }
sl@0
  3772
sl@0
  3773
inline UnicodeString&
sl@0
  3774
UnicodeString::replace(int32_t start,
sl@0
  3775
               int32_t _length,
sl@0
  3776
               const UChar *srcChars,
sl@0
  3777
               int32_t srcLength)
sl@0
  3778
{ return doReplace(start, _length, srcChars, 0, srcLength); }
sl@0
  3779
sl@0
  3780
inline UnicodeString&
sl@0
  3781
UnicodeString::replace(int32_t start,
sl@0
  3782
               int32_t _length,
sl@0
  3783
               const UChar *srcChars,
sl@0
  3784
               int32_t srcStart,
sl@0
  3785
               int32_t srcLength)
sl@0
  3786
{ return doReplace(start, _length, srcChars, srcStart, srcLength); }
sl@0
  3787
sl@0
  3788
inline UnicodeString&
sl@0
  3789
UnicodeString::replace(int32_t start,
sl@0
  3790
               int32_t _length,
sl@0
  3791
               UChar srcChar)
sl@0
  3792
{ return doReplace(start, _length, &srcChar, 0, 1); }
sl@0
  3793
sl@0
  3794
inline UnicodeString&
sl@0
  3795
UnicodeString::replace(int32_t start,
sl@0
  3796
               int32_t _length,
sl@0
  3797
               UChar32 srcChar) {
sl@0
  3798
  UChar buffer[U16_MAX_LENGTH];
sl@0
  3799
  int32_t count = 0;
sl@0
  3800
  UBool isError = FALSE;
sl@0
  3801
  U16_APPEND(buffer, count, U16_MAX_LENGTH, srcChar, isError);
sl@0
  3802
  return doReplace(start, _length, buffer, 0, count);
sl@0
  3803
}
sl@0
  3804
sl@0
  3805
inline UnicodeString&
sl@0
  3806
UnicodeString::replaceBetween(int32_t start,
sl@0
  3807
                  int32_t limit,
sl@0
  3808
                  const UnicodeString& srcText)
sl@0
  3809
{ return doReplace(start, limit - start, srcText, 0, srcText.fLength); }
sl@0
  3810
sl@0
  3811
inline UnicodeString&
sl@0
  3812
UnicodeString::replaceBetween(int32_t start,
sl@0
  3813
                  int32_t limit,
sl@0
  3814
                  const UnicodeString& srcText,
sl@0
  3815
                  int32_t srcStart,
sl@0
  3816
                  int32_t srcLimit)
sl@0
  3817
{ return doReplace(start, limit - start, srcText, srcStart, srcLimit - srcStart); }
sl@0
  3818
sl@0
  3819
inline UnicodeString&
sl@0
  3820
UnicodeString::findAndReplace(const UnicodeString& oldText,
sl@0
  3821
                  const UnicodeString& newText)
sl@0
  3822
{ return findAndReplace(0, fLength, oldText, 0, oldText.fLength,
sl@0
  3823
            newText, 0, newText.fLength); }
sl@0
  3824
sl@0
  3825
inline UnicodeString&
sl@0
  3826
UnicodeString::findAndReplace(int32_t start,
sl@0
  3827
                  int32_t _length,
sl@0
  3828
                  const UnicodeString& oldText,
sl@0
  3829
                  const UnicodeString& newText)
sl@0
  3830
{ return findAndReplace(start, _length, oldText, 0, oldText.fLength,
sl@0
  3831
            newText, 0, newText.fLength); }
sl@0
  3832
sl@0
  3833
// ============================
sl@0
  3834
// extract
sl@0
  3835
// ============================
sl@0
  3836
inline void
sl@0
  3837
UnicodeString::doExtract(int32_t start,
sl@0
  3838
             int32_t _length,
sl@0
  3839
             UnicodeString& target) const
sl@0
  3840
{ target.replace(0, target.fLength, *this, start, _length); }
sl@0
  3841
sl@0
  3842
inline void
sl@0
  3843
UnicodeString::extract(int32_t start,
sl@0
  3844
               int32_t _length,
sl@0
  3845
               UChar *target,
sl@0
  3846
               int32_t targetStart) const
sl@0
  3847
{ doExtract(start, _length, target, targetStart); }
sl@0
  3848
sl@0
  3849
inline void
sl@0
  3850
UnicodeString::extract(int32_t start,
sl@0
  3851
               int32_t _length,
sl@0
  3852
               UnicodeString& target) const
sl@0
  3853
{ doExtract(start, _length, target); }
sl@0
  3854
sl@0
  3855
#if !UCONFIG_NO_CONVERSION
sl@0
  3856
sl@0
  3857
inline int32_t
sl@0
  3858
UnicodeString::extract(int32_t start,
sl@0
  3859
               int32_t _length,
sl@0
  3860
               char *dst,
sl@0
  3861
               const char *codepage) const
sl@0
  3862
sl@0
  3863
{
sl@0
  3864
  // This dstSize value will be checked explicitly
sl@0
  3865
  return extract(start, _length, dst, dst!=0 ? 0xffffffff : 0, codepage);
sl@0
  3866
}
sl@0
  3867
sl@0
  3868
#endif
sl@0
  3869
sl@0
  3870
inline void
sl@0
  3871
UnicodeString::extractBetween(int32_t start,
sl@0
  3872
                  int32_t limit,
sl@0
  3873
                  UChar *dst,
sl@0
  3874
                  int32_t dstStart) const {
sl@0
  3875
  pinIndex(start);
sl@0
  3876
  pinIndex(limit);
sl@0
  3877
  doExtract(start, limit - start, dst, dstStart);
sl@0
  3878
}
sl@0
  3879
sl@0
  3880
inline UChar
sl@0
  3881
UnicodeString::doCharAt(int32_t offset) const
sl@0
  3882
{
sl@0
  3883
  if((uint32_t)offset < (uint32_t)fLength) {
sl@0
  3884
    return fArray[offset];
sl@0
  3885
  } else {
sl@0
  3886
    return kInvalidUChar;
sl@0
  3887
  }
sl@0
  3888
}
sl@0
  3889
sl@0
  3890
inline UChar
sl@0
  3891
UnicodeString::charAt(int32_t offset) const
sl@0
  3892
{ return doCharAt(offset); }
sl@0
  3893
sl@0
  3894
inline UChar
sl@0
  3895
UnicodeString::operator[] (int32_t offset) const
sl@0
  3896
{ return doCharAt(offset); }
sl@0
  3897
sl@0
  3898
inline UChar32
sl@0
  3899
UnicodeString::char32At(int32_t offset) const
sl@0
  3900
{
sl@0
  3901
  if((uint32_t)offset < (uint32_t)fLength) {
sl@0
  3902
    UChar32 c;
sl@0
  3903
    U16_GET(fArray, 0, offset, fLength, c);
sl@0
  3904
    return c;
sl@0
  3905
  } else {
sl@0
  3906
    return kInvalidUChar;
sl@0
  3907
  }
sl@0
  3908
}
sl@0
  3909
sl@0
  3910
inline int32_t
sl@0
  3911
UnicodeString::getChar32Start(int32_t offset) const {
sl@0
  3912
  if((uint32_t)offset < (uint32_t)fLength) {
sl@0
  3913
    U16_SET_CP_START(fArray, 0, offset);
sl@0
  3914
    return offset;
sl@0
  3915
  } else {
sl@0
  3916
    return 0;
sl@0
  3917
  }
sl@0
  3918
}
sl@0
  3919
sl@0
  3920
inline int32_t
sl@0
  3921
UnicodeString::getChar32Limit(int32_t offset) const {
sl@0
  3922
  if((uint32_t)offset < (uint32_t)fLength) {
sl@0
  3923
    U16_SET_CP_LIMIT(fArray, 0, offset, fLength);
sl@0
  3924
    return offset;
sl@0
  3925
  } else {
sl@0
  3926
    return fLength;
sl@0
  3927
  }
sl@0
  3928
}
sl@0
  3929
sl@0
  3930
inline UBool
sl@0
  3931
UnicodeString::isEmpty() const {
sl@0
  3932
  return fLength == 0;
sl@0
  3933
}
sl@0
  3934
sl@0
  3935
//========================================
sl@0
  3936
// Write implementation methods
sl@0
  3937
//========================================
sl@0
  3938
inline const UChar *
sl@0
  3939
UnicodeString::getTerminatedBuffer() {
sl@0
  3940
  if(fFlags&(kIsBogus|kOpenGetBuffer)) {
sl@0
  3941
    return 0;
sl@0
  3942
  } else if(fLength<fCapacity && fArray[fLength]==0) {
sl@0
  3943
    return fArray;
sl@0
  3944
  } else if(cloneArrayIfNeeded(fLength+1)) {
sl@0
  3945
    fArray[fLength]=0;
sl@0
  3946
    return fArray;
sl@0
  3947
  } else {
sl@0
  3948
    return 0;
sl@0
  3949
  }
sl@0
  3950
}
sl@0
  3951
sl@0
  3952
inline UnicodeString&
sl@0
  3953
UnicodeString::operator= (UChar ch)
sl@0
  3954
{ return doReplace(0, fLength, &ch, 0, 1); }
sl@0
  3955
sl@0
  3956
inline UnicodeString&
sl@0
  3957
UnicodeString::operator= (UChar32 ch)
sl@0
  3958
{ return replace(0, fLength, ch); }
sl@0
  3959
sl@0
  3960
inline UnicodeString&
sl@0
  3961
UnicodeString::setTo(const UnicodeString& srcText,
sl@0
  3962
             int32_t srcStart,
sl@0
  3963
             int32_t srcLength)
sl@0
  3964
{
sl@0
  3965
  unBogus();
sl@0
  3966
  return doReplace(0, fLength, srcText, srcStart, srcLength);
sl@0
  3967
}
sl@0
  3968
sl@0
  3969
inline UnicodeString&
sl@0
  3970
UnicodeString::setTo(const UnicodeString& srcText,
sl@0
  3971
             int32_t srcStart)
sl@0
  3972
{
sl@0
  3973
  unBogus();
sl@0
  3974
  srcText.pinIndex(srcStart);
sl@0
  3975
  return doReplace(0, fLength, srcText, srcStart, srcText.fLength - srcStart);
sl@0
  3976
}
sl@0
  3977
sl@0
  3978
inline UnicodeString&
sl@0
  3979
UnicodeString::setTo(const UnicodeString& srcText)
sl@0
  3980
{
sl@0
  3981
  unBogus();
sl@0
  3982
  return doReplace(0, fLength, srcText, 0, srcText.fLength);
sl@0
  3983
}
sl@0
  3984
sl@0
  3985
inline UnicodeString&
sl@0
  3986
UnicodeString::setTo(const UChar *srcChars,
sl@0
  3987
             int32_t srcLength)
sl@0
  3988
{
sl@0
  3989
  unBogus();
sl@0
  3990
  return doReplace(0, fLength, srcChars, 0, srcLength);
sl@0
  3991
}
sl@0
  3992
sl@0
  3993
inline UnicodeString&
sl@0
  3994
UnicodeString::setTo(UChar srcChar)
sl@0
  3995
{
sl@0
  3996
  unBogus();
sl@0
  3997
  return doReplace(0, fLength, &srcChar, 0, 1);
sl@0
  3998
}
sl@0
  3999
sl@0
  4000
inline UnicodeString&
sl@0
  4001
UnicodeString::setTo(UChar32 srcChar)
sl@0
  4002
{
sl@0
  4003
  unBogus();
sl@0
  4004
  return replace(0, fLength, srcChar);
sl@0
  4005
}
sl@0
  4006
sl@0
  4007
inline UnicodeString&
sl@0
  4008
UnicodeString::operator+= (UChar ch)
sl@0
  4009
{ return doReplace(fLength, 0, &ch, 0, 1); }
sl@0
  4010
sl@0
  4011
inline UnicodeString&
sl@0
  4012
UnicodeString::operator+= (UChar32 ch) {
sl@0
  4013
  UChar buffer[U16_MAX_LENGTH];
sl@0
  4014
  int32_t _length = 0;
sl@0
  4015
  UBool isError = FALSE;
sl@0
  4016
  U16_APPEND(buffer, _length, U16_MAX_LENGTH, ch, isError);
sl@0
  4017
  return doReplace(fLength, 0, buffer, 0, _length);
sl@0
  4018
}
sl@0
  4019
sl@0
  4020
inline UnicodeString&
sl@0
  4021
UnicodeString::operator+= (const UnicodeString& srcText)
sl@0
  4022
{ return doReplace(fLength, 0, srcText, 0, srcText.fLength); }
sl@0
  4023
sl@0
  4024
inline UnicodeString&
sl@0
  4025
UnicodeString::append(const UnicodeString& srcText,
sl@0
  4026
              int32_t srcStart,
sl@0
  4027
              int32_t srcLength)
sl@0
  4028
{ return doReplace(fLength, 0, srcText, srcStart, srcLength); }
sl@0
  4029
sl@0
  4030
inline UnicodeString&
sl@0
  4031
UnicodeString::append(const UnicodeString& srcText)
sl@0
  4032
{ return doReplace(fLength, 0, srcText, 0, srcText.fLength); }
sl@0
  4033
sl@0
  4034
inline UnicodeString&
sl@0
  4035
UnicodeString::append(const UChar *srcChars,
sl@0
  4036
              int32_t srcStart,
sl@0
  4037
              int32_t srcLength)
sl@0
  4038
{ return doReplace(fLength, 0, srcChars, srcStart, srcLength); }
sl@0
  4039
sl@0
  4040
inline UnicodeString&
sl@0
  4041
UnicodeString::append(const UChar *srcChars,
sl@0
  4042
              int32_t srcLength)
sl@0
  4043
{ return doReplace(fLength, 0, srcChars, 0, srcLength); }
sl@0
  4044
sl@0
  4045
inline UnicodeString&
sl@0
  4046
UnicodeString::append(UChar srcChar)
sl@0
  4047
{ return doReplace(fLength, 0, &srcChar, 0, 1); }
sl@0
  4048
sl@0
  4049
inline UnicodeString&
sl@0
  4050
UnicodeString::append(UChar32 srcChar) {
sl@0
  4051
  UChar buffer[U16_MAX_LENGTH];
sl@0
  4052
  int32_t _length = 0;
sl@0
  4053
  UBool isError = FALSE;
sl@0
  4054
  U16_APPEND(buffer, _length, U16_MAX_LENGTH, srcChar, isError);
sl@0
  4055
  return doReplace(fLength, 0, buffer, 0, _length);
sl@0
  4056
}
sl@0
  4057
sl@0
  4058
inline UnicodeString&
sl@0
  4059
UnicodeString::insert(int32_t start,
sl@0
  4060
              const UnicodeString& srcText,
sl@0
  4061
              int32_t srcStart,
sl@0
  4062
              int32_t srcLength)
sl@0
  4063
{ return doReplace(start, 0, srcText, srcStart, srcLength); }
sl@0
  4064
sl@0
  4065
inline UnicodeString&
sl@0
  4066
UnicodeString::insert(int32_t start,
sl@0
  4067
              const UnicodeString& srcText)
sl@0
  4068
{ return doReplace(start, 0, srcText, 0, srcText.fLength); }
sl@0
  4069
sl@0
  4070
inline UnicodeString&
sl@0
  4071
UnicodeString::insert(int32_t start,
sl@0
  4072
              const UChar *srcChars,
sl@0
  4073
              int32_t srcStart,
sl@0
  4074
              int32_t srcLength)
sl@0
  4075
{ return doReplace(start, 0, srcChars, srcStart, srcLength); }
sl@0
  4076
sl@0
  4077
inline UnicodeString&
sl@0
  4078
UnicodeString::insert(int32_t start,
sl@0
  4079
              const UChar *srcChars,
sl@0
  4080
              int32_t srcLength)
sl@0
  4081
{ return doReplace(start, 0, srcChars, 0, srcLength); }
sl@0
  4082
sl@0
  4083
inline UnicodeString&
sl@0
  4084
UnicodeString::insert(int32_t start,
sl@0
  4085
              UChar srcChar)
sl@0
  4086
{ return doReplace(start, 0, &srcChar, 0, 1); }
sl@0
  4087
sl@0
  4088
inline UnicodeString&
sl@0
  4089
UnicodeString::insert(int32_t start,
sl@0
  4090
              UChar32 srcChar)
sl@0
  4091
{ return replace(start, 0, srcChar); }
sl@0
  4092
sl@0
  4093
sl@0
  4094
inline UnicodeString&
sl@0
  4095
UnicodeString::remove()
sl@0
  4096
{
sl@0
  4097
  // remove() of a bogus string makes the string empty and non-bogus
sl@0
  4098
  if(isBogus()) {
sl@0
  4099
    unBogus();
sl@0
  4100
  } else {
sl@0
  4101
    fLength = 0;
sl@0
  4102
  }
sl@0
  4103
  return *this;
sl@0
  4104
}
sl@0
  4105
sl@0
  4106
inline UnicodeString&
sl@0
  4107
UnicodeString::remove(int32_t start,
sl@0
  4108
             int32_t _length)
sl@0
  4109
{
sl@0
  4110
  if(start <= 0 && _length == INT32_MAX) {
sl@0
  4111
    // remove(guaranteed everything) of a bogus string makes the string empty and non-bogus
sl@0
  4112
    return remove();
sl@0
  4113
  } else {
sl@0
  4114
    return doReplace(start, _length, NULL, 0, 0);
sl@0
  4115
  }
sl@0
  4116
}
sl@0
  4117
sl@0
  4118
inline UnicodeString&
sl@0
  4119
UnicodeString::removeBetween(int32_t start,
sl@0
  4120
                int32_t limit)
sl@0
  4121
{ return doReplace(start, limit - start, NULL, 0, 0); }
sl@0
  4122
sl@0
  4123
inline UBool
sl@0
  4124
UnicodeString::truncate(int32_t targetLength)
sl@0
  4125
{
sl@0
  4126
  if(isBogus() && targetLength == 0) {
sl@0
  4127
    // truncate(0) of a bogus string makes the string empty and non-bogus
sl@0
  4128
    unBogus();
sl@0
  4129
    return FALSE;
sl@0
  4130
  } else if((uint32_t)targetLength < (uint32_t)fLength) {
sl@0
  4131
    fLength = targetLength;
sl@0
  4132
    return TRUE;
sl@0
  4133
  } else {
sl@0
  4134
    return FALSE;
sl@0
  4135
  }
sl@0
  4136
}
sl@0
  4137
sl@0
  4138
inline UnicodeString&
sl@0
  4139
UnicodeString::reverse()
sl@0
  4140
{ return doReverse(0, fLength); }
sl@0
  4141
sl@0
  4142
inline UnicodeString&
sl@0
  4143
UnicodeString::reverse(int32_t start,
sl@0
  4144
               int32_t _length)
sl@0
  4145
{ return doReverse(start, _length); }
sl@0
  4146
sl@0
  4147
U_NAMESPACE_END
sl@0
  4148
sl@0
  4149
#endif