36 class StringThreadTest;
38 #ifndef U_COMPARE_CODE_POINT_ORDER
45 #define U_COMPARE_CODE_POINT_ORDER 0x8000
75 #define US_INV U_NAMESPACE_QUALIFIER UnicodeString::kInvariant
94 #if defined(U_DECLARE_UTF16)
95 # define UNICODE_STRING(cs, _length) U_NAMESPACE_QUALIFIER UnicodeString(TRUE, (const UChar *)U_DECLARE_UTF16(cs), _length)
96 #elif U_SIZEOF_WCHAR_T==U_SIZEOF_UCHAR && (U_CHARSET_FAMILY==U_ASCII_FAMILY || (U_SIZEOF_UCHAR == 2 && defined(U_WCHAR_IS_UTF16)))
97 # define UNICODE_STRING(cs, _length) U_NAMESPACE_QUALIFIER UnicodeString(TRUE, (const UChar *)L ## cs, _length)
98 #elif U_SIZEOF_UCHAR==1 && U_CHARSET_FAMILY==U_ASCII_FAMILY
99 # define UNICODE_STRING(cs, _length) U_NAMESPACE_QUALIFIER UnicodeString(TRUE, (const UChar *)cs, _length)
101 # define UNICODE_STRING(cs, _length) U_NAMESPACE_QUALIFIER UnicodeString(cs, _length, US_INV)
117 #define UNICODE_STRING_SIMPLE(cs) UNICODE_STRING(cs, -1)
295 inline int8_t compare(int32_t start,
316 inline int8_t compare(int32_t start,
320 int32_t srcLength)
const;
334 inline int8_t compare(
const UChar *srcChars,
335 int32_t srcLength)
const;
351 inline int8_t compare(int32_t start,
353 const UChar *srcChars)
const;
372 inline int8_t compare(int32_t start,
374 const UChar *srcChars,
376 int32_t srcLength)
const;
395 inline int8_t compareBetween(int32_t start,
399 int32_t srcLimit)
const;
418 inline int8_t compareCodePointOrder(
const UnicodeString& text)
const;
439 inline int8_t compareCodePointOrder(int32_t start,
464 inline int8_t compareCodePointOrder(int32_t start,
468 int32_t srcLength)
const;
488 inline int8_t compareCodePointOrder(
const UChar *srcChars,
489 int32_t srcLength)
const;
510 inline int8_t compareCodePointOrder(int32_t start,
512 const UChar *srcChars)
const;
535 inline int8_t compareCodePointOrder(int32_t start,
537 const UChar *srcChars,
539 int32_t srcLength)
const;
562 inline int8_t compareCodePointOrderBetween(int32_t start,
566 int32_t srcLimit)
const;
586 inline int8_t caseCompare(
const UnicodeString& text, uint32_t options)
const;
608 inline int8_t caseCompare(int32_t start,
611 uint32_t options)
const;
635 inline int8_t caseCompare(int32_t start,
640 uint32_t options)
const;
661 inline int8_t caseCompare(
const UChar *srcChars,
663 uint32_t options)
const;
685 inline int8_t caseCompare(int32_t start,
687 const UChar *srcChars,
688 uint32_t options)
const;
712 inline int8_t caseCompare(int32_t start,
714 const UChar *srcChars,
717 uint32_t options)
const;
741 inline int8_t caseCompareBetween(int32_t start,
746 uint32_t options)
const;
769 int32_t srcLength)
const;
779 inline UBool startsWith(
const UChar *srcChars,
780 int32_t srcLength)
const;
791 inline UBool startsWith(
const UChar *srcChars,
793 int32_t srcLength)
const;
816 int32_t srcLength)
const;
827 int32_t srcLength)
const;
841 int32_t srcLength)
const;
866 int32_t start)
const;
881 int32_t length)
const;
903 int32_t length)
const;
916 inline int32_t indexOf(
const UChar *srcChars,
918 int32_t start)
const;
932 inline int32_t indexOf(
const UChar *srcChars,
935 int32_t length)
const;
953 int32_t indexOf(
const UChar *srcChars,
957 int32_t length)
const;
966 inline int32_t indexOf(
UChar c)
const;
976 inline int32_t indexOf(
UChar32 c)
const;
986 inline int32_t indexOf(
UChar c,
987 int32_t start)
const;
998 inline int32_t indexOf(
UChar32 c,
999 int32_t start)
const;
1011 inline int32_t indexOf(
UChar c,
1013 int32_t length)
const;
1026 inline int32_t indexOf(
UChar32 c,
1028 int32_t length)
const;
1038 inline int32_t lastIndexOf(
const UnicodeString& text)
const;
1050 int32_t start)
const;
1065 int32_t length)
const;
1087 int32_t length)
const;
1099 inline int32_t lastIndexOf(
const UChar *srcChars,
1101 int32_t start)
const;
1115 inline int32_t lastIndexOf(
const UChar *srcChars,
1118 int32_t length)
const;
1136 int32_t lastIndexOf(
const UChar *srcChars,
1140 int32_t length)
const;
1149 inline int32_t lastIndexOf(
UChar c)
const;
1159 inline int32_t lastIndexOf(
UChar32 c)
const;
1169 inline int32_t lastIndexOf(
UChar c,
1170 int32_t start)
const;
1181 inline int32_t lastIndexOf(
UChar32 c,
1182 int32_t start)
const;
1194 inline int32_t lastIndexOf(
UChar c,
1196 int32_t length)
const;
1209 inline int32_t lastIndexOf(
UChar32 c,
1211 int32_t length)
const;
1233 inline UChar operator[] (int32_t offset)
const;
1263 inline int32_t getChar32Start(int32_t offset)
const;
1281 inline int32_t getChar32Limit(int32_t offset)
const;
1333 int32_t moveIndex32(int32_t index, int32_t delta)
const;
1352 inline void extract(int32_t start,
1355 int32_t dstStart = 0)
const;
1379 extract(
UChar *dest, int32_t destCapacity,
1392 inline void extract(int32_t start,
1410 int32_t dstStart = 0)
const;
1446 int32_t extract(int32_t start,
1447 int32_t startLength,
1449 int32_t targetCapacity,
1450 enum EInvariant inv)
const;
1452 #if U_CHARSET_IS_UTF8 || !UCONFIG_NO_CONVERSION
1473 int32_t extract(int32_t start,
1474 int32_t startLength,
1476 uint32_t targetLength)
const;
1480 #if !UCONFIG_NO_CONVERSION
1507 inline int32_t extract(int32_t start,
1508 int32_t startLength,
1510 const char *codepage = 0)
const;
1541 int32_t extract(int32_t start,
1542 int32_t startLength,
1544 uint32_t targetLength,
1545 const char *codepage)
const;
1564 int32_t extract(
char *dest, int32_t destCapacity,
1610 #if U_HAVE_STD_STRING
1624 template<
typename StringClass>
1625 StringClass &toUTF8String(StringClass &result)
const {
1626 StringByteSink<StringClass> sbs(&result);
1660 inline int32_t
length(
void)
const;
1676 countChar32(int32_t start=0, int32_t length=
INT32_MAX)
const;
1702 hasMoreChar32Than(int32_t start, int32_t length, int32_t number)
const;
1709 inline UBool isEmpty(
void)
const;
1720 inline int32_t getCapacity(
void)
const;
1729 inline int32_t hashCode(
void)
const;
1743 inline UBool isBogus(
void)
const;
1895 int32_t textLength);
1918 int32_t buffCapacity);
2120 const UChar *srcChars,
2134 const UChar *srcChars,
2220 const UChar *srcChars,
2238 const UChar *srcChars,
2340 virtual void copy(int32_t start, int32_t limit, int32_t dest);
2453 UBool padLeading(int32_t targetLength,
2454 UChar padChar = 0x0020);
2467 UBool padTrailing(int32_t targetLength,
2468 UChar padChar = 0x0020);
2476 inline UBool truncate(int32_t targetLength);
2540 #if !UCONFIG_NO_BREAK_ITERATION
2694 UChar *getBuffer(int32_t minCapacity);
2716 void releaseBuffer(int32_t newLength=-1);
2748 inline const UChar *getBuffer()
const;
2783 inline const UChar *getTerminatedBuffer();
2837 int32_t textLength);
2860 int32_t textLength);
2882 #if U_CHARSET_IS_UTF8 || !UCONFIG_NO_CONVERSION
2898 UnicodeString(
const char *codepageData, int32_t dataLength);
2902 #if !UCONFIG_NO_CONVERSION
2921 UnicodeString(
const char *codepageData,
const char *codepage);
2940 UnicodeString(
const char *codepageData, int32_t dataLength,
const char *codepage);
2964 const char *src, int32_t srcLength,
2994 UnicodeString(
const char *src, int32_t length,
enum EInvariant inv);
3129 UChar32 unescapeAt(int32_t &offset)
const;
3179 toUTF8(int32_t start, int32_t len,
3180 char *target, int32_t capacity)
const;
3184 doCompare(int32_t start,
3188 int32_t srcLength)
const;
3190 int8_t doCompare(int32_t start,
3192 const UChar *srcChars,
3194 int32_t srcLength)
const;
3197 doCompareCodePointOrder(int32_t start,
3201 int32_t srcLength)
const;
3203 int8_t doCompareCodePointOrder(int32_t start,
3205 const UChar *srcChars,
3207 int32_t srcLength)
const;
3210 doCaseCompare(int32_t start,
3215 uint32_t options)
const;
3218 doCaseCompare(int32_t start,
3220 const UChar *srcChars,
3223 uint32_t options)
const;
3225 int32_t doIndexOf(
UChar c,
3227 int32_t length)
const;
3231 int32_t length)
const;
3233 int32_t doLastIndexOf(
UChar c,
3235 int32_t length)
const;
3237 int32_t doLastIndexOf(
UChar32 c,
3239 int32_t length)
const;
3241 void doExtract(int32_t start,
3244 int32_t dstStart)
const;
3246 inline void doExtract(int32_t start,
3250 inline UChar doCharAt(int32_t offset)
const;
3260 const UChar *srcChars,
3268 int32_t doHashCode(
void)
const;
3272 inline UChar* getArrayStart(
void);
3273 inline const UChar* getArrayStart(
void)
const;
3277 inline UBool isWritable()
const;
3280 inline UBool isBufferWritable()
const;
3283 inline void setLength(int32_t len);
3284 inline void setToEmpty();
3285 inline void setArray(
UChar *array, int32_t len, int32_t capacity);
3291 UBool allocate(int32_t capacity);
3294 void releaseArray(
void);
3303 inline void pinIndex(int32_t& start)
const;
3304 inline void pinIndices(int32_t& start,
3305 int32_t& length)
const;
3307 #if !UCONFIG_NO_CONVERSION
3310 int32_t doExtract(int32_t start, int32_t length,
3311 char *dest, int32_t destCapacity,
3325 void doCodepageCreate(
const char *codepageData,
3327 const char *codepage);
3334 doCodepageCreate(
const char *codepageData,
3352 UBool cloneArrayIfNeeded(int32_t newCapacity = -1,
3353 int32_t growCapacity = -1,
3355 int32_t **pBufferToDelete = 0,
3363 int32_t toWhichCase);
3367 int32_t removeRef(
void);
3368 int32_t refCount(
void)
const;
3374 US_STACKBUF_SIZE=
sizeof(
void *)==4 ? 13 : 15,
3375 kInvalidUChar=0xffff,
3382 kUsingStackBuffer=2,
3384 kBufferIsReadonly=8,
3389 kShortString=kUsingStackBuffer,
3390 kLongString=kRefCounted,
3391 kReadonlyAlias=kBufferIsReadonly,
3395 friend class StringThreadTest;
3398 union StackBufferOrFields;
3399 friend union StackBufferOrFields;
3436 union StackBufferOrFields {
3439 UChar fStackBuffer[8];
3446 UChar fRestOfStackBuffer[US_STACKBUF_SIZE-8];
3447 int8_t fShortLength;
3471 UnicodeString::pinIndex(int32_t& start)
const
3476 }
else if(start >
length()) {
3482 UnicodeString::pinIndices(int32_t& start,
3483 int32_t& _length)
const
3489 }
else if(start > len) {
3494 }
else if(_length > (len - start)) {
3495 _length = (len - start);
3500 UnicodeString::getArrayStart()
3501 {
return (fFlags&kUsingStackBuffer) ? fUnion.fStackBuffer : fUnion.fFields.fArray; }
3504 UnicodeString::getArrayStart()
const
3505 {
return (fFlags&kUsingStackBuffer) ? fUnion.fStackBuffer : fUnion.fFields.fArray; }
3512 {
return fShortLength>=0 ? fShortLength : fUnion.fFields.fLength; }
3516 {
return (fFlags&kUsingStackBuffer) ? US_STACKBUF_SIZE : fUnion.fFields.fCapacity; }
3520 {
return doHashCode(); }
3524 {
return (
UBool)(fFlags & kIsBogus); }
3527 UnicodeString::isWritable()
const
3528 {
return (
UBool)!(fFlags&(kOpenGetBuffer|kIsBogus)); }
3531 UnicodeString::isBufferWritable()
const
3534 !(fFlags&(kOpenGetBuffer|kIsBogus|kBufferIsReadonly)) &&
3535 (!(fFlags&kRefCounted) || refCount()==1));
3538 inline const UChar *
3540 if(fFlags&(kIsBogus|kOpenGetBuffer)) {
3542 }
else if(fFlags&kUsingStackBuffer) {
3543 return fUnion.fStackBuffer;
3545 return fUnion.fFields.fArray;
3553 UnicodeString::doCompare(int32_t start,
3557 int32_t srcLength)
const
3560 return (int8_t)!isBogus();
3562 srcText.pinIndices(srcStart, srcLength);
3563 return doCompare(start, thisLength, srcText.getArrayStart(), srcStart, srcLength);
3576 len == textLength &&
3577 doCompare(0, len, text, 0, textLength) == 0;
3583 {
return (!
operator==(text)); }
3587 {
return doCompare(0,
length(), text, 0, text.
length()) == 1; }
3591 {
return doCompare(0,
length(), text, 0, text.
length()) == -1; }
3595 {
return doCompare(0,
length(), text, 0, text.
length()) != -1; }
3599 {
return doCompare(0,
length(), text, 0, text.
length()) != 1; }
3603 {
return doCompare(0,
length(), text, 0, text.
length()); }
3609 {
return doCompare(start, _length, srcText, 0, srcText.
length()); }
3613 int32_t srcLength)
const
3614 {
return doCompare(0,
length(), srcChars, 0, srcLength); }
3621 int32_t srcLength)
const
3622 {
return doCompare(start, _length, srcText, srcStart, srcLength); }
3627 const UChar *srcChars)
const
3628 {
return doCompare(start, _length, srcChars, 0, _length); }
3633 const UChar *srcChars,
3635 int32_t srcLength)
const
3636 {
return doCompare(start, _length, srcChars, srcStart, srcLength); }
3643 int32_t srcLimit)
const
3644 {
return doCompare(start, limit - start,
3645 srcText, srcStart, srcLimit - srcStart); }
3648 UnicodeString::doCompareCodePointOrder(int32_t start,
3652 int32_t srcLength)
const
3655 return (int8_t)!isBogus();
3657 srcText.pinIndices(srcStart, srcLength);
3658 return doCompareCodePointOrder(start, thisLength, srcText.getArrayStart(), srcStart, srcLength);
3664 {
return doCompareCodePointOrder(0,
length(), text, 0, text.
length()); }
3670 {
return doCompareCodePointOrder(start, _length, srcText, 0, srcText.
length()); }
3674 int32_t srcLength)
const
3675 {
return doCompareCodePointOrder(0,
length(), srcChars, 0, srcLength); }
3682 int32_t srcLength)
const
3683 {
return doCompareCodePointOrder(start, _length, srcText, srcStart, srcLength); }
3688 const UChar *srcChars)
const
3689 {
return doCompareCodePointOrder(start, _length, srcChars, 0, _length); }
3694 const UChar *srcChars,
3696 int32_t srcLength)
const
3697 {
return doCompareCodePointOrder(start, _length, srcChars, srcStart, srcLength); }
3704 int32_t srcLimit)
const
3705 {
return doCompareCodePointOrder(start, limit - start,
3706 srcText, srcStart, srcLimit - srcStart); }
3709 UnicodeString::doCaseCompare(int32_t start,
3714 uint32_t options)
const
3717 return (int8_t)!isBogus();
3719 srcText.pinIndices(srcStart, srcLength);
3720 return doCaseCompare(start, thisLength, srcText.getArrayStart(), srcStart, srcLength, options);
3726 return doCaseCompare(0,
length(), text, 0, text.
length(), options);
3733 uint32_t options)
const {
3734 return doCaseCompare(start, _length, srcText, 0, srcText.
length(), options);
3740 uint32_t options)
const {
3741 return doCaseCompare(0,
length(), srcChars, 0, srcLength, options);
3750 uint32_t options)
const {
3751 return doCaseCompare(start, _length, srcText, srcStart, srcLength, options);
3757 const UChar *srcChars,
3758 uint32_t options)
const {
3759 return doCaseCompare(start, _length, srcChars, 0, _length, options);
3765 const UChar *srcChars,
3768 uint32_t options)
const {
3769 return doCaseCompare(start, _length, srcChars, srcStart, srcLength, options);
3778 uint32_t options)
const {
3779 return doCaseCompare(start, limit - start, srcText, srcStart, srcLimit - srcStart, options);
3787 int32_t _length)
const
3790 srcText.pinIndices(srcStart, srcLength);
3792 return indexOf(srcText.getArrayStart(), srcStart, srcLength, start, _length);
3800 {
return indexOf(text, 0, text.
length(), 0,
length()); }
3804 int32_t start)
const {
3806 return indexOf(text, 0, text.
length(), start,
length() - start);
3812 int32_t _length)
const
3813 {
return indexOf(text, 0, text.
length(), start, _length); }
3818 int32_t start)
const {
3820 return indexOf(srcChars, 0, srcLength, start,
length() - start);
3827 int32_t _length)
const
3828 {
return indexOf(srcChars, 0, srcLength, start, _length); }
3833 int32_t _length)
const
3834 {
return doIndexOf(c, start, _length); }
3839 int32_t _length)
const
3840 {
return doIndexOf(c, start, _length); }
3844 {
return doIndexOf(c, 0,
length()); }
3848 {
return indexOf(c, 0,
length()); }
3852 int32_t start)
const {
3854 return doIndexOf(c, start,
length() - start);
3859 int32_t start)
const {
3861 return indexOf(c, start,
length() - start);
3868 int32_t _length)
const
3869 {
return lastIndexOf(srcChars, 0, srcLength, start, _length); }
3874 int32_t start)
const {
3876 return lastIndexOf(srcChars, 0, srcLength, start,
length() - start);
3884 int32_t _length)
const
3887 srcText.pinIndices(srcStart, srcLength);
3889 return lastIndexOf(srcText.getArrayStart(), srcStart, srcLength, start, _length);
3898 int32_t _length)
const
3899 {
return lastIndexOf(text, 0, text.
length(), start, _length); }
3903 int32_t start)
const {
3905 return lastIndexOf(text, 0, text.
length(), start,
length() - start);
3910 {
return lastIndexOf(text, 0, text.
length(), 0,
length()); }
3915 int32_t _length)
const
3916 {
return doLastIndexOf(c, start, _length); }
3921 int32_t _length)
const {
3922 return doLastIndexOf(c, start, _length);
3927 {
return doLastIndexOf(c, 0,
length()); }
3931 return lastIndexOf(c, 0,
length());
3936 int32_t start)
const {
3938 return doLastIndexOf(c, start,
length() - start);
3943 int32_t start)
const {
3945 return lastIndexOf(c, start,
length() - start);
3950 {
return compare(0, text.
length(), text, 0, text.
length()) == 0; }
3955 int32_t srcLength)
const
3956 {
return doCompare(0, srcLength, srcText, srcStart, srcLength) == 0; }
3963 return doCompare(0, srcLength, srcChars, 0, srcLength) == 0;
3971 return doCompare(0, srcLength, srcChars, srcStart, srcLength) == 0;
3977 text, 0, text.
length()) == 0; }
3982 int32_t srcLength)
const {
3983 srcText.pinIndices(srcStart, srcLength);
3984 return doCompare(
length() - srcLength, srcLength,
3985 srcText, srcStart, srcLength) == 0;
3990 int32_t srcLength)
const {
3994 return doCompare(
length() - srcLength, srcLength,
3995 srcChars, 0, srcLength) == 0;
4001 int32_t srcLength)
const {
4003 srcLength =
u_strlen(srcChars + srcStart);
4005 return doCompare(
length() - srcLength, srcLength,
4006 srcChars, srcStart, srcLength) == 0;
4016 {
return doReplace(start, _length, srcText, 0, srcText.
length()); }
4024 {
return doReplace(start, _length, srcText, srcStart, srcLength); }
4029 const UChar *srcChars,
4031 {
return doReplace(start, _length, srcChars, 0, srcLength); }
4036 const UChar *srcChars,
4039 {
return doReplace(start, _length, srcChars, srcStart, srcLength); }
4045 {
return doReplace(start, _length, &srcChar, 0, 1); }
4055 return doReplace(start, _length, buffer, 0, count);
4062 {
return doReplace(start, limit - start, srcText, 0, srcText.
length()); }
4070 {
return doReplace(start, limit - start, srcText, srcStart, srcLimit - srcStart); }
4075 {
return findAndReplace(0,
length(), oldText, 0, oldText.
length(),
4076 newText, 0, newText.
length()); }
4083 {
return findAndReplace(start, _length, oldText, 0, oldText.
length(),
4084 newText, 0, newText.
length()); }
4090 UnicodeString::doExtract(int32_t start,
4093 { target.
replace(0, target.
length(), *
this, start, _length); }
4099 int32_t targetStart)
const
4100 { doExtract(start, _length, target, targetStart); }
4106 { doExtract(start, _length, target); }
4108 #if !UCONFIG_NO_CONVERSION
4114 const char *codepage)
const
4118 return extract(start, _length, dst, dst!=0 ? 0xffffffff : 0, codepage);
4127 int32_t dstStart)
const {
4130 doExtract(start, limit - start, dst, dstStart);
4135 return tempSubString(start, limit - start);
4139 UnicodeString::doCharAt(int32_t offset)
const
4141 if((uint32_t)offset < (uint32_t)
length()) {
4142 return getArrayStart()[offset];
4144 return kInvalidUChar;
4150 {
return doCharAt(offset); }
4154 {
return doCharAt(offset); }
4160 if((uint32_t)offset < (uint32_t)len) {
4161 const UChar *array = getArrayStart();
4163 U16_GET(array, 0, offset, len, c);
4166 return kInvalidUChar;
4172 if((uint32_t)offset < (uint32_t)
length()) {
4173 const UChar *array = getArrayStart();
4184 if((uint32_t)offset < (uint32_t)len) {
4185 const UChar *array = getArrayStart();
4195 return fShortLength == 0;
4202 UnicodeString::setLength(int32_t len) {
4204 fShortLength = (
int8_t)len;
4206 fShortLength = (
int8_t)-1;
4207 fUnion.fFields.fLength = len;
4212 UnicodeString::setToEmpty() {
4214 fFlags = kShortString;
4218 UnicodeString::setArray(
UChar *array, int32_t len, int32_t capacity) {
4220 fUnion.fFields.fArray = array;
4221 fUnion.fFields.fCapacity = capacity;
4224 inline const UChar *
4229 UChar *array = getArrayStart();
4231 if(len < getCapacity() && ((fFlags&kRefCounted) == 0 || refCount() == 1)) {
4238 if(!(fFlags&kBufferIsReadonly)) {
4256 }
else if(cloneArrayIfNeeded(len+1)) {
4257 array = getArrayStart();
4268 {
return doReplace(0,
length(), &ch, 0, 1); }
4272 {
return replace(0,
length(), ch); }
4280 return doReplace(0,
length(), srcText, srcStart, srcLength);
4288 srcText.pinIndex(srcStart);
4289 return doReplace(0,
length(), srcText, srcStart, srcText.
length() - srcStart);
4295 return copyFrom(srcText);
4303 return doReplace(0,
length(), srcChars, 0, srcLength);
4310 return doReplace(0,
length(), &srcChar, 0, 1);
4317 return replace(0,
length(), srcChar);
4324 {
return doReplace(
length(), 0, srcText, srcStart, srcLength); }
4328 {
return doReplace(
length(), 0, srcText, 0, srcText.
length()); }
4334 {
return doReplace(
length(), 0, srcChars, srcStart, srcLength); }
4339 {
return doReplace(
length(), 0, srcChars, 0, srcLength); }
4343 {
return doReplace(
length(), 0, &srcChar, 0, 1); }
4348 int32_t _length = 0;
4351 return doReplace(
length(), 0, buffer, 0, _length);
4356 {
return doReplace(
length(), 0, &ch, 0, 1); }
4365 {
return doReplace(
length(), 0, srcText, 0, srcText.
length()); }
4372 {
return doReplace(start, 0, srcText, srcStart, srcLength); }
4377 {
return doReplace(start, 0, srcText, 0, srcText.
length()); }
4381 const UChar *srcChars,
4384 {
return doReplace(start, 0, srcChars, srcStart, srcLength); }
4388 const UChar *srcChars,
4390 {
return doReplace(start, 0, srcChars, 0, srcLength); }
4395 {
return doReplace(start, 0, &srcChar, 0, 1); }
4400 {
return replace(start, 0, srcChar); }
4409 if(fFlags & (kIsBogus|kBufferIsReadonly)) {
4421 if(start <= 0 && _length ==
INT32_MAX) {
4425 return doReplace(start, _length,
NULL, 0, 0);
4431 {
return doReplace(start, limit - start,
NULL, 0, 0); }
4436 return doReplace(0, start,
NULL, 0, 0);
4442 if(isBogus() && targetLength == 0) {
4446 }
else if((uint32_t)targetLength < (uint32_t)
length()) {
4447 setLength(targetLength);
4448 if(fFlags&kBufferIsReadonly) {
4449 fUnion.fFields.fCapacity = targetLength;
4459 {
return doReverse(0,
length()); }
4464 {
return doReverse(start, _length); }
void extract(int32_t start, int32_t length, UChar *dst, int32_t dstStart=0) const
Copy the characters in the range [start, start + length) into the array dst, beginning at dstStart...
int32_t getChar32Start(int32_t offset) const
Adjust a random-access offset so that it points to the beginning of a Unicode character.
int8_t caseCompareBetween(int32_t start, int32_t limit, const UnicodeString &srcText, int32_t srcStart, int32_t srcLimit, uint32_t options) const
Compare two strings case-insensitively using full case folding.
int8_t caseCompare(const UnicodeString &text, uint32_t options) const
Compare two strings case-insensitively using full case folding.
The BreakIterator class implements methods for finding the location of boundaries in text...
A ByteSink can be filled with bytes.
#define U16_GET(s, start, i, length, c)
Get a code point from a string at a random-access offset, without changing the offset.
int32_t hashCode(void) const
Generate a hash code for this object.
UBool operator>(const UnicodeString &text) const
Greater than operator.
const UChar * getBuffer() const
Get a read-only pointer to the internal buffer.
int32_t length() const
Returns the number of 16-bit code units in the text.
#define U16_SET_CP_START(s, start, i)
Adjust a random-access offset to a code point boundary at the start of a code point.
UnicodeString tempSubStringBetween(int32_t start, int32_t limit=INT32_MAX) const
Create a temporary substring for the specified range.
UBool operator!=(const UnicodeString &text) const
Inequality operator.
A string-like object that points to a sized piece of memory.
virtual UChar32 getChar32At(int32_t offset) const =0
Virtual version of char32At().
UnicodeString & reverse(void)
Reverse this UnicodeString in place.
int32_t getCapacity(void) const
Return the capacity of the internal buffer of the UnicodeString object.
An Appendable implementation which writes to a UnicodeString.
UnicodeString & replace(int32_t start, int32_t length, const UnicodeString &srcText, int32_t srcStart, int32_t srcLength)
Replace the characters in the range [start, start + length) with the characters in srcText in the ran...
Replaceable is an abstract base class representing a string of characters that supports the replaceme...
int8_t compareCodePointOrder(const UnicodeString &text) const
Compare two Unicode strings in code point order.
U_EXPORT UBool operator==(const StringPiece &x, const StringPiece &y)
Global operator == for StringPiece.
virtual int32_t getLength() const =0
Virtual version of length().
UChar operator[](int32_t offset) const
Return the code unit at offset offset.
UBool truncate(int32_t targetLength)
Truncate this UnicodeString to the targetLength.
EInvariant
Constant to be used in the UnicodeString(char *, int32_t, EInvariant) constructor which constructs a ...
UChar charAt(int32_t offset) const
Return the code unit at offset offset.
UnicodeString & append(const UnicodeString &srcText, int32_t srcStart, int32_t srcLength)
Append the characters in srcText in the range [srcStart, srcStart + srcLength) to the UnicodeString o...
int8_t compareCodePointOrderBetween(int32_t start, int32_t limit, const UnicodeString &srcText, int32_t srcStart, int32_t srcLimit) const
Compare two Unicode strings in code point order.
UnicodeString & findAndReplace(const UnicodeString &oldText, const UnicodeString &newText)
Replace all occurrences of characters in oldText with the characters in newText.
virtual void extractBetween(int32_t start, int32_t limit, UnicodeString &target) const =0
Copies characters in the range [start, limit) into the UnicodeString target.
virtual void copy(int32_t start, int32_t limit, int32_t dest)=0
Copies a substring of this object, retaining metadata.
C++ API: StringPiece: Read-only byte string wrapper class.
UnicodeString & remove(void)
Remove all characters from the UnicodeString object.
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
C++ API: Interface for writing bytes, and implementation classes.
#define U16_MAX_LENGTH
The maximum number of 16-bit code units per Unicode code point (U+0000..U+10ffff).
int8_t compare(const UnicodeString &text) const
Compare the characters bitwise in this UnicodeString to the characters in text.
int32_t getChar32Limit(int32_t offset) const
Adjust a random-access offset so that it points behind a Unicode character.
#define U16_SET_CP_LIMIT(s, start, i, length)
Adjust a random-access offset to a code point boundary after a code point.
int32_t lastIndexOf(const UnicodeString &text) const
Locate in this the last occurrence of the characters in text, using bitwise comparison.
int32_t indexOf(const UnicodeString &text) const
Locate in this the first occurrence of the characters in text, using bitwise comparison.
virtual Replaceable * clone() const
Clone this object, an instance of a subclass of Replaceable.
UnicodeString & retainBetween(int32_t start, int32_t limit=INT32_MAX)
Retain only the characters in the range [start, limit) from the UnicodeString object.
int32_t UChar32
Define UChar32 as a type for single Unicode code points.
virtual UChar getCharAt(int32_t offset) const =0
Virtual version of charAt().
#define NULL
Define NULL if necessary, to 0 for C++ and to ((void *)0) for C.
UBool isBogus(void) const
Determine if this object contains a valid string.
C++ API: Central ICU header for including the C++ standard <string> header and for related definition...
UBool startsWith(const UnicodeString &text) const
Determine if this starts with the characters in text
UnicodeString & removeBetween(int32_t start, int32_t limit=(int32_t) INT32_MAX)
Remove the characters in the range [start, limit) from the UnicodeString object.
UnicodeString & operator+=(UChar ch)
Append operator.
virtual UBool hasMetaData() const
Returns true if this object contains metadata.
int32_t length(void) const
Return the length of the UnicodeString object.
#define TRUE
The TRUE value of a UBool.
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
UBool endsWith(const UnicodeString &text) const
Determine if this ends with the characters in text
U_COMMON_API UnicodeString operator+(const UnicodeString &s1, const UnicodeString &s2)
Create a new UnicodeString with the concatenation of two others.
UBool operator!=(const StringPiece &x, const StringPiece &y)
Global operator != for StringPiece.
A concrete subclass of CharacterIterator that iterates over the characters (code units or code points...
uint16_t UChar
Define UChar to be wchar_t if that is 16 bits wide; always assumed to be unsigned.
int8_t compareBetween(int32_t start, int32_t limit, const UnicodeString &srcText, int32_t srcStart, int32_t srcLimit) const
Compare the characters bitwise in the range [start, limit) with the characters in srcText in the rang...
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
virtual void handleReplaceBetween(int32_t start, int32_t limit, const UnicodeString &text)=0
Replaces a substring of this object with the given text.
UBool operator<=(const UnicodeString &text) const
Less than or equal operator.
signed char int8_t
Define 64 bit limits.
const UChar * getTerminatedBuffer()
Get a read-only pointer to the internal buffer, making sure that it is NUL-terminated.
UnicodeString & operator=(const UnicodeString &srcText)
Assignment operator.
struct UConverter UConverter
#define INT32_MAX
The largest value a 32 bit signed integer can hold.
void * UClassID
UClassID is used to identify classes without using RTTI, since RTTI is not yet supported by all C++ c...
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers...
UChar32 char32At(int32_t offset) const
Return the code point that contains the code unit at offset offset.
UChar charAt(int32_t offset) const
Returns the 16-bit code unit at the given offset into the text.
UnicodeString & insert(int32_t start, const UnicodeString &srcText, int32_t srcStart, int32_t srcLength)
Insert the characters in srcText in the range [srcStart, srcStart + srcLength) into the UnicodeString...
UnicodeString & setTo(const UnicodeString &srcText, int32_t srcStart)
Set the text in the UnicodeString object to the characters in srcText in the range [srcStart...
UBool operator<(const UnicodeString &text) const
Less than operator.
Basic definitions for ICU, for both C and C++ APIs.
UBool isEmpty(void) const
Determine if this string is empty.
int32_t u_strlen(const UChar *s)
Determine the length of an array of UChar.
#define FALSE
The FALSE value of a UBool.
#define U_COMMON_API
Set to export library symbols from inside the common library, and to import them from outside...
#define U16_APPEND(s, i, capacity, c, isError)
Append a code point to a string, overwriting 1 or 2 code units.
UChar32 char32At(int32_t offset) const
Returns the 32-bit code point at the given 16-bit offset into the text.
A Locale object represents a specific geographical, political, or cultural region.
UBool operator==(const UnicodeString &text) const
Equality operator.
virtual UClassID getDynamicClassID() const =0
ICU4C "poor man's RTTI", returns a UClassID for the actual ICU class.
UBool operator>=(const UnicodeString &text) const
Greater than or equal operator.
void extractBetween(int32_t start, int32_t limit, UChar *dst, int32_t dstStart=0) const
Copy the characters in the range [start, limit) into the array dst, beginning at dstStart.
signed int int32_t
Define 64 bit limits.
#define U_STABLE
This is used to declare a function as a stable public ICU C API.
int8_t UBool
The ICU boolean type.
UnicodeString & replaceBetween(int32_t start, int32_t limit, const UnicodeString &srcText)
Replace the characters in the range [start, limit) with the characters in srcText.
C++ API: Replaceable String.