40 #ifndef U_COMPARE_CODE_POINT_ORDER 47 #define U_COMPARE_CODE_POINT_ORDER 0x8000 62 #ifndef U_STRING_CASE_MAPPER_DEFINED 63 #define U_STRING_CASE_MAPPER_DEFINED 71 UChar *dest, int32_t destCapacity,
72 const UChar *src, int32_t srcLength,
79 #if !UCONFIG_NO_BREAK_ITERATION 83 class StringCharacterIterator;
84 class UnicodeStringAppendable;
98 #define US_INV icu::UnicodeString::kInvariant 117 #if defined(U_DECLARE_UTF16) 118 # define UNICODE_STRING(cs, _length) icu::UnicodeString(TRUE, (const UChar *)U_DECLARE_UTF16(cs), _length) 119 #elif U_SIZEOF_WCHAR_T==U_SIZEOF_UCHAR && (U_CHARSET_FAMILY==U_ASCII_FAMILY || (U_SIZEOF_UCHAR == 2 && defined(U_WCHAR_IS_UTF16))) 120 # define UNICODE_STRING(cs, _length) icu::UnicodeString(TRUE, (const UChar *)L ## cs, _length) 121 #elif U_SIZEOF_UCHAR==1 && U_CHARSET_FAMILY==U_ASCII_FAMILY 122 # define UNICODE_STRING(cs, _length) icu::UnicodeString(TRUE, (const UChar *)cs, _length) 124 # define UNICODE_STRING(cs, _length) icu::UnicodeString(cs, _length, US_INV) 140 #define UNICODE_STRING_SIMPLE(cs) UNICODE_STRING(cs, -1) 149 #ifndef UNISTR_FROM_CHAR_EXPLICIT 150 # if defined(U_COMBINED_IMPLEMENTATION) || defined(U_COMMON_IMPLEMENTATION) || defined(U_I18N_IMPLEMENTATION) || defined(U_IO_IMPLEMENTATION) 152 # define UNISTR_FROM_CHAR_EXPLICIT explicit 155 # define UNISTR_FROM_CHAR_EXPLICIT 169 #ifndef UNISTR_FROM_STRING_EXPLICIT 170 # if defined(U_COMBINED_IMPLEMENTATION) || defined(U_COMMON_IMPLEMENTATION) || defined(U_I18N_IMPLEMENTATION) || defined(U_IO_IMPLEMENTATION) 172 # define UNISTR_FROM_STRING_EXPLICIT explicit 175 # define UNISTR_FROM_STRING_EXPLICIT 212 #ifndef UNISTR_OBJECT_SIZE 213 # define UNISTR_OBJECT_SIZE 64 403 inline int8_t compare(int32_t start,
424 inline int8_t compare(int32_t start,
428 int32_t srcLength)
const;
442 inline int8_t compare(
const UChar *srcChars,
443 int32_t srcLength)
const;
459 inline int8_t compare(int32_t start,
461 const UChar *srcChars)
const;
480 inline int8_t compare(int32_t start,
482 const UChar *srcChars,
484 int32_t srcLength)
const;
503 inline int8_t compareBetween(int32_t start,
507 int32_t srcLimit)
const;
526 inline int8_t compareCodePointOrder(
const UnicodeString& text)
const;
547 inline int8_t compareCodePointOrder(int32_t start,
572 inline int8_t compareCodePointOrder(int32_t start,
576 int32_t srcLength)
const;
596 inline int8_t compareCodePointOrder(
const UChar *srcChars,
597 int32_t srcLength)
const;
618 inline int8_t compareCodePointOrder(int32_t start,
620 const UChar *srcChars)
const;
643 inline int8_t compareCodePointOrder(int32_t start,
645 const UChar *srcChars,
647 int32_t srcLength)
const;
670 inline int8_t compareCodePointOrderBetween(int32_t start,
674 int32_t srcLimit)
const;
694 inline int8_t caseCompare(
const UnicodeString& text, uint32_t options)
const;
716 inline int8_t caseCompare(int32_t start,
719 uint32_t options)
const;
743 inline int8_t caseCompare(int32_t start,
748 uint32_t options)
const;
769 inline int8_t caseCompare(
const UChar *srcChars,
771 uint32_t options)
const;
793 inline int8_t caseCompare(int32_t start,
795 const UChar *srcChars,
796 uint32_t options)
const;
820 inline int8_t caseCompare(int32_t start,
822 const UChar *srcChars,
825 uint32_t options)
const;
849 inline int8_t caseCompareBetween(int32_t start,
854 uint32_t options)
const;
877 int32_t srcLength)
const;
887 inline UBool startsWith(
const UChar *srcChars,
888 int32_t srcLength)
const;
899 inline UBool startsWith(
const UChar *srcChars,
901 int32_t srcLength)
const;
924 int32_t srcLength)
const;
935 int32_t srcLength)
const;
949 int32_t srcLength)
const;
974 int32_t start)
const;
989 int32_t length)
const;
1011 int32_t length)
const;
1024 inline int32_t indexOf(
const UChar *srcChars,
1026 int32_t start)
const;
1040 inline int32_t indexOf(
const UChar *srcChars,
1043 int32_t length)
const;
1061 int32_t indexOf(
const UChar *srcChars,
1065 int32_t length)
const;
1074 inline int32_t indexOf(
UChar c)
const;
1084 inline int32_t indexOf(
UChar32 c)
const;
1094 inline int32_t indexOf(
UChar c,
1095 int32_t start)
const;
1106 inline int32_t indexOf(
UChar32 c,
1107 int32_t start)
const;
1119 inline int32_t indexOf(
UChar c,
1121 int32_t length)
const;
1134 inline int32_t indexOf(
UChar32 c,
1136 int32_t length)
const;
1146 inline int32_t lastIndexOf(
const UnicodeString& text)
const;
1158 int32_t start)
const;
1173 int32_t length)
const;
1195 int32_t length)
const;
1207 inline int32_t lastIndexOf(
const UChar *srcChars,
1209 int32_t start)
const;
1223 inline int32_t lastIndexOf(
const UChar *srcChars,
1226 int32_t length)
const;
1244 int32_t lastIndexOf(
const UChar *srcChars,
1248 int32_t length)
const;
1257 inline int32_t lastIndexOf(
UChar c)
const;
1267 inline int32_t lastIndexOf(
UChar32 c)
const;
1277 inline int32_t lastIndexOf(
UChar c,
1278 int32_t start)
const;
1289 inline int32_t lastIndexOf(
UChar32 c,
1290 int32_t start)
const;
1302 inline int32_t lastIndexOf(
UChar c,
1304 int32_t length)
const;
1317 inline int32_t lastIndexOf(
UChar32 c,
1319 int32_t length)
const;
1341 inline UChar operator[] (int32_t offset)
const;
1371 int32_t getChar32Start(int32_t offset)
const;
1389 int32_t getChar32Limit(int32_t offset)
const;
1441 int32_t moveIndex32(int32_t index, int32_t delta)
const;
1460 inline void extract(int32_t start,
1463 int32_t dstStart = 0)
const;
1487 extract(
UChar *dest, int32_t destCapacity,
1500 inline void extract(int32_t start,
1518 int32_t dstStart = 0)
const;
1554 int32_t extract(int32_t start,
1555 int32_t startLength,
1557 int32_t targetCapacity,
1560 #if U_CHARSET_IS_UTF8 || !UCONFIG_NO_CONVERSION 1581 int32_t extract(int32_t start,
1582 int32_t startLength,
1584 uint32_t targetLength)
const;
1588 #if !UCONFIG_NO_CONVERSION 1615 inline int32_t extract(int32_t start,
1616 int32_t startLength,
1618 const char *codepage = 0)
const;
1649 int32_t extract(int32_t start,
1650 int32_t startLength,
1652 uint32_t targetLength,
1653 const char *codepage)
const;
1672 int32_t extract(
char *dest, int32_t destCapacity,
1718 #if U_HAVE_STD_STRING 1732 template<
typename StringClass>
1768 inline int32_t
length(
void)
const;
1784 countChar32(int32_t start=0, int32_t length=
INT32_MAX)
const;
1810 hasMoreChar32Than(int32_t start, int32_t length, int32_t number)
const;
1817 inline UBool isEmpty(
void)
const;
1828 inline int32_t getCapacity(
void)
const;
1837 inline int32_t hashCode(
void)
const;
1851 inline UBool isBogus(
void)
const;
1907 #if U_HAVE_RVALUE_REFERENCES 1917 return moveFrom(src);
2066 int32_t textLength);
2089 int32_t buffCapacity);
2291 const UChar *srcChars,
2305 const UChar *srcChars,
2391 const UChar *srcChars,
2409 const UChar *srcChars,
2509 virtual void copy(int32_t start, int32_t limit, int32_t dest);
2595 inline UnicodeString& removeBetween(int32_t start,
2607 inline UnicodeString &retainBetween(int32_t start, int32_t limit = INT32_MAX);
2622 UBool padLeading(int32_t targetLength,
2623 UChar padChar = 0x0020);
2636 UBool padTrailing(int32_t targetLength,
2637 UChar padChar = 0x0020);
2645 inline UBool truncate(int32_t targetLength);
2652 UnicodeString& trim(
void);
2662 inline UnicodeString& reverse(
void);
2672 inline UnicodeString& reverse(int32_t start,
2681 UnicodeString& toUpper(
void);
2690 UnicodeString& toUpper(
const Locale& locale);
2698 UnicodeString& toLower(
void);
2707 UnicodeString& toLower(
const Locale& locale);
2709 #if !UCONFIG_NO_BREAK_ITERATION 2816 UnicodeString &foldCase(uint32_t options=0 );
2865 UChar *getBuffer(int32_t minCapacity);
2887 void releaseBuffer(int32_t newLength=-1);
2919 inline const UChar *getBuffer()
const;
2954 const UChar *getTerminatedBuffer();
2963 inline UnicodeString();
2976 UnicodeString(int32_t capacity,
UChar32 c, int32_t count);
3019 UnicodeString(
const UChar *text,
3020 int32_t textLength);
3044 UnicodeString(
UBool isTerminated,
3046 int32_t textLength);
3066 UnicodeString(
UChar *buffer, int32_t buffLength, int32_t buffCapacity);
3068 #if U_CHARSET_IS_UTF8 || !UCONFIG_NO_CONVERSION 3099 UnicodeString(
const char *codepageData, int32_t dataLength);
3103 #if !UCONFIG_NO_CONVERSION 3122 UnicodeString(
const char *codepageData,
const char *codepage);
3141 UnicodeString(
const char *codepageData, int32_t dataLength,
const char *codepage);
3165 const char *src, int32_t srcLength,
3195 UnicodeString(
const char *src, int32_t length,
enum EInvariant inv);
3214 UnicodeString(
const UnicodeString& that);
3216 #if U_HAVE_RVALUE_REFERENCES 3223 UnicodeString(UnicodeString &&src)
U_NOEXCEPT;
3232 UnicodeString(
const UnicodeString& src, int32_t srcStart);
3241 UnicodeString(
const UnicodeString& src, int32_t srcStart, int32_t srcLength);
3264 virtual ~UnicodeString();
3292 static UnicodeString fromUTF32(
const UChar32 *utf32, int32_t length);
3330 UnicodeString unescape()
const;
3351 UChar32 unescapeAt(int32_t &offset)
const;
3358 static UClassID U_EXPORT2 getStaticClassID();
3401 toUTF8(int32_t start, int32_t len,
3402 char *target, int32_t capacity)
const;
3408 UBool doEquals(
const UnicodeString &text, int32_t len)
const;
3411 doCompare(int32_t start,
3413 const UnicodeString& srcText,
3415 int32_t srcLength)
const;
3417 int8_t doCompare(int32_t start,
3419 const UChar *srcChars,
3421 int32_t srcLength)
const;
3424 doCompareCodePointOrder(int32_t start,
3426 const UnicodeString& srcText,
3428 int32_t srcLength)
const;
3430 int8_t doCompareCodePointOrder(int32_t start,
3432 const UChar *srcChars,
3434 int32_t srcLength)
const;
3437 doCaseCompare(int32_t start,
3439 const UnicodeString &srcText,
3442 uint32_t options)
const;
3445 doCaseCompare(int32_t start,
3447 const UChar *srcChars,
3450 uint32_t options)
const;
3452 int32_t doIndexOf(
UChar c,
3454 int32_t length)
const;
3458 int32_t length)
const;
3460 int32_t doLastIndexOf(
UChar c,
3462 int32_t length)
const;
3464 int32_t doLastIndexOf(
UChar32 c,
3466 int32_t length)
const;
3468 void doExtract(int32_t start,
3471 int32_t dstStart)
const;
3473 inline void doExtract(int32_t start,
3475 UnicodeString& target)
const;
3477 inline UChar doCharAt(int32_t offset)
const;
3479 UnicodeString& doReplace(int32_t start,
3481 const UnicodeString& srcText,
3485 UnicodeString& doReplace(int32_t start,
3487 const UChar *srcChars,
3491 UnicodeString& doAppend(
const UnicodeString& src, int32_t srcStart, int32_t srcLength);
3492 UnicodeString& doAppend(
const UChar *srcChars, int32_t srcStart, int32_t srcLength);
3494 UnicodeString& doReverse(int32_t start,
3498 int32_t doHashCode(
void)
const;
3502 inline UChar* getArrayStart(
void);
3503 inline const UChar* getArrayStart(
void)
const;
3505 inline UBool hasShortLength()
const;
3506 inline int32_t getShortLength()
const;
3510 inline UBool isWritable()
const;
3513 inline UBool isBufferWritable()
const;
3516 inline void setZeroLength();
3517 inline void setShortLength(int32_t len);
3518 inline void setLength(int32_t len);
3519 inline void setToEmpty();
3520 inline void setArray(
UChar *array, int32_t len, int32_t capacity);
3527 UBool allocate(int32_t capacity);
3530 void releaseArray(
void);
3536 UnicodeString ©From(
const UnicodeString &src,
UBool fastCopy=
FALSE);
3539 void copyFieldsFrom(UnicodeString &src,
UBool setSrcToBogus)
U_NOEXCEPT;
3542 inline void pinIndex(int32_t& start)
const;
3543 inline void pinIndices(int32_t& start,
3544 int32_t& length)
const;
3546 #if !UCONFIG_NO_CONVERSION 3549 int32_t doExtract(int32_t start, int32_t length,
3550 char *dest, int32_t destCapacity,
3564 void doCodepageCreate(
const char *codepageData,
3566 const char *codepage);
3573 doCodepageCreate(
const char *codepageData,
3591 UBool cloneArrayIfNeeded(int32_t newCapacity = -1,
3592 int32_t growCapacity = -1,
3594 int32_t **pBufferToDelete = 0,
3607 int32_t removeRef(
void);
3608 int32_t refCount(
void)
const;
3618 kInvalidUChar=0xffff,
3624 kUsingStackBuffer=2,
3626 kBufferIsReadonly=8,
3629 kAllStorageFlags=0x1f,
3632 kLength1=1<<kLengthShift,
3633 kMaxShortLength=0x3ff,
3634 kLengthIsLarge=0xffe0,
3637 kShortString=kUsingStackBuffer,
3638 kLongString=kRefCounted,
3639 kReadonlyAlias=kBufferIsReadonly,
3645 union StackBufferOrFields;
3646 friend union StackBufferOrFields;
3689 union StackBufferOrFields {
3693 int16_t fLengthAndFlags;
3694 UChar fBuffer[US_STACKBUF_SIZE];
3697 int16_t fLengthAndFlags;
3727 UnicodeString::pinIndex(int32_t& start)
const 3732 }
else if(start > length()) {
3738 UnicodeString::pinIndices(int32_t& start,
3739 int32_t& _length)
const 3742 int32_t len = length();
3745 }
else if(start > len) {
3750 }
else if(_length > (len - start)) {
3751 _length = (len - start);
3756 UnicodeString::getArrayStart() {
3757 return (fUnion.fFields.fLengthAndFlags&kUsingStackBuffer) ?
3758 fUnion.fStackFields.fBuffer : fUnion.fFields.fArray;
3762 UnicodeString::getArrayStart()
const {
3763 return (fUnion.fFields.fLengthAndFlags&kUsingStackBuffer) ?
3764 fUnion.fStackFields.fBuffer : fUnion.fFields.fArray;
3772 UnicodeString::UnicodeString() {
3773 fUnion.fStackFields.fLengthAndFlags=kShortString;
3780 UnicodeString::hasShortLength()
const {
3781 return fUnion.fFields.fLengthAndFlags>=0;
3785 UnicodeString::getShortLength()
const {
3788 return fUnion.fFields.fLengthAndFlags>>kLengthShift;
3792 UnicodeString::length()
const {
3793 return hasShortLength() ? getShortLength() : fUnion.fFields.fLength;
3797 UnicodeString::getCapacity()
const {
3798 return (fUnion.fFields.fLengthAndFlags&kUsingStackBuffer) ?
3799 US_STACKBUF_SIZE : fUnion.fFields.fCapacity;
3803 UnicodeString::hashCode()
const 3804 {
return doHashCode(); }
3807 UnicodeString::isBogus()
const 3808 {
return (
UBool)(fUnion.fFields.fLengthAndFlags & kIsBogus); }
3811 UnicodeString::isWritable()
const 3812 {
return (
UBool)!(fUnion.fFields.fLengthAndFlags&(kOpenGetBuffer|kIsBogus)); }
3815 UnicodeString::isBufferWritable()
const 3818 !(fUnion.fFields.fLengthAndFlags&(kOpenGetBuffer|kIsBogus|kBufferIsReadonly)) &&
3819 (!(fUnion.fFields.fLengthAndFlags&kRefCounted) || refCount()==1));
3822 inline const UChar *
3823 UnicodeString::getBuffer()
const {
3824 if(fUnion.fFields.fLengthAndFlags&(kIsBogus|kOpenGetBuffer)) {
3826 }
else if(fUnion.fFields.fLengthAndFlags&kUsingStackBuffer) {
3827 return fUnion.fStackFields.fBuffer;
3829 return fUnion.fFields.fArray;
3837 UnicodeString::doCompare(int32_t start,
3841 int32_t srcLength)
const 3844 return (int8_t)!isBogus();
3846 srcText.pinIndices(srcStart, srcLength);
3847 return doCompare(start, thisLength, srcText.getArrayStart(), srcStart, srcLength);
3857 int32_t len = length(), textLength = text.
length();
3858 return !text.
isBogus() && len == textLength && doEquals(text, len);
3864 {
return (!
operator==(text)); }
3868 {
return doCompare(0, length(), text, 0, text.
length()) == 1; }
3872 {
return doCompare(0, length(), text, 0, text.
length()) == -1; }
3876 {
return doCompare(0, length(), text, 0, text.
length()) != -1; }
3880 {
return doCompare(0, length(), text, 0, text.
length()) != 1; }
3884 {
return doCompare(0, length(), text, 0, text.
length()); }
3887 UnicodeString::compare(int32_t start,
3890 {
return doCompare(start, _length, srcText, 0, srcText.
length()); }
3893 UnicodeString::compare(
const UChar *srcChars,
3894 int32_t srcLength)
const 3895 {
return doCompare(0, length(), srcChars, 0, srcLength); }
3898 UnicodeString::compare(int32_t start,
3902 int32_t srcLength)
const 3903 {
return doCompare(start, _length, srcText, srcStart, srcLength); }
3906 UnicodeString::compare(int32_t start,
3908 const UChar *srcChars)
const 3909 {
return doCompare(start, _length, srcChars, 0, _length); }
3912 UnicodeString::compare(int32_t start,
3914 const UChar *srcChars,
3916 int32_t srcLength)
const 3917 {
return doCompare(start, _length, srcChars, srcStart, srcLength); }
3920 UnicodeString::compareBetween(int32_t start,
3924 int32_t srcLimit)
const 3925 {
return doCompare(start, limit - start,
3926 srcText, srcStart, srcLimit - srcStart); }
3929 UnicodeString::doCompareCodePointOrder(int32_t start,
3933 int32_t srcLength)
const 3936 return (int8_t)!isBogus();
3938 srcText.pinIndices(srcStart, srcLength);
3939 return doCompareCodePointOrder(start, thisLength, srcText.getArrayStart(), srcStart, srcLength);
3945 {
return doCompareCodePointOrder(0, length(), text, 0, text.
length()); }
3948 UnicodeString::compareCodePointOrder(int32_t start,
3951 {
return doCompareCodePointOrder(start, _length, srcText, 0, srcText.
length()); }
3954 UnicodeString::compareCodePointOrder(
const UChar *srcChars,
3955 int32_t srcLength)
const 3956 {
return doCompareCodePointOrder(0, length(), srcChars, 0, srcLength); }
3959 UnicodeString::compareCodePointOrder(int32_t start,
3963 int32_t srcLength)
const 3964 {
return doCompareCodePointOrder(start, _length, srcText, srcStart, srcLength); }
3967 UnicodeString::compareCodePointOrder(int32_t start,
3969 const UChar *srcChars)
const 3970 {
return doCompareCodePointOrder(start, _length, srcChars, 0, _length); }
3973 UnicodeString::compareCodePointOrder(int32_t start,
3975 const UChar *srcChars,
3977 int32_t srcLength)
const 3978 {
return doCompareCodePointOrder(start, _length, srcChars, srcStart, srcLength); }
3981 UnicodeString::compareCodePointOrderBetween(int32_t start,
3985 int32_t srcLimit)
const 3986 {
return doCompareCodePointOrder(start, limit - start,
3987 srcText, srcStart, srcLimit - srcStart); }
3990 UnicodeString::doCaseCompare(int32_t start,
3995 uint32_t options)
const 3998 return (int8_t)!isBogus();
4000 srcText.pinIndices(srcStart, srcLength);
4001 return doCaseCompare(start, thisLength, srcText.getArrayStart(), srcStart, srcLength, options);
4007 return doCaseCompare(0, length(), text, 0, text.
length(), options);
4011 UnicodeString::caseCompare(int32_t start,
4014 uint32_t options)
const {
4015 return doCaseCompare(start, _length, srcText, 0, srcText.
length(), options);
4019 UnicodeString::caseCompare(
const UChar *srcChars,
4021 uint32_t options)
const {
4022 return doCaseCompare(0, length(), srcChars, 0, srcLength, options);
4026 UnicodeString::caseCompare(int32_t start,
4031 uint32_t options)
const {
4032 return doCaseCompare(start, _length, srcText, srcStart, srcLength, options);
4036 UnicodeString::caseCompare(int32_t start,
4038 const UChar *srcChars,
4039 uint32_t options)
const {
4040 return doCaseCompare(start, _length, srcChars, 0, _length, options);
4044 UnicodeString::caseCompare(int32_t start,
4046 const UChar *srcChars,
4049 uint32_t options)
const {
4050 return doCaseCompare(start, _length, srcChars, srcStart, srcLength, options);
4054 UnicodeString::caseCompareBetween(int32_t start,
4059 uint32_t options)
const {
4060 return doCaseCompare(start, limit - start, srcText, srcStart, srcLimit - srcStart, options);
4068 int32_t _length)
const 4071 srcText.pinIndices(srcStart, srcLength);
4073 return indexOf(srcText.getArrayStart(), srcStart, srcLength, start, _length);
4081 {
return indexOf(text, 0, text.
length(), 0, length()); }
4085 int32_t start)
const {
4087 return indexOf(text, 0, text.
length(), start, length() - start);
4093 int32_t _length)
const 4094 {
return indexOf(text, 0, text.
length(), start, _length); }
4097 UnicodeString::indexOf(
const UChar *srcChars,
4099 int32_t start)
const {
4101 return indexOf(srcChars, 0, srcLength, start, length() - start);
4105 UnicodeString::indexOf(
const UChar *srcChars,
4108 int32_t _length)
const 4109 {
return indexOf(srcChars, 0, srcLength, start, _length); }
4114 int32_t _length)
const 4115 {
return doIndexOf(c, start, _length); }
4120 int32_t _length)
const 4121 {
return doIndexOf(c, start, _length); }
4125 {
return doIndexOf(c, 0, length()); }
4129 {
return indexOf(c, 0, length()); }
4133 int32_t start)
const {
4135 return doIndexOf(c, start, length() - start);
4140 int32_t start)
const {
4142 return indexOf(c, start, length() - start);
4146 UnicodeString::lastIndexOf(
const UChar *srcChars,
4149 int32_t _length)
const 4150 {
return lastIndexOf(srcChars, 0, srcLength, start, _length); }
4153 UnicodeString::lastIndexOf(
const UChar *srcChars,
4155 int32_t start)
const {
4157 return lastIndexOf(srcChars, 0, srcLength, start, length() - start);
4165 int32_t _length)
const 4168 srcText.pinIndices(srcStart, srcLength);
4170 return lastIndexOf(srcText.getArrayStart(), srcStart, srcLength, start, _length);
4179 int32_t _length)
const 4180 {
return lastIndexOf(text, 0, text.
length(), start, _length); }
4184 int32_t start)
const {
4186 return lastIndexOf(text, 0, text.
length(), start, length() - start);
4191 {
return lastIndexOf(text, 0, text.
length(), 0, length()); }
4196 int32_t _length)
const 4197 {
return doLastIndexOf(c, start, _length); }
4202 int32_t _length)
const {
4203 return doLastIndexOf(c, start, _length);
4207 UnicodeString::lastIndexOf(
UChar c)
const 4208 {
return doLastIndexOf(c, 0, length()); }
4212 return lastIndexOf(c, 0, length());
4217 int32_t start)
const {
4219 return doLastIndexOf(c, start, length() - start);
4224 int32_t start)
const {
4226 return lastIndexOf(c, start, length() - start);
4231 {
return compare(0, text.
length(), text, 0, text.
length()) == 0; }
4236 int32_t srcLength)
const 4237 {
return doCompare(0, srcLength, srcText, srcStart, srcLength) == 0; }
4240 UnicodeString::startsWith(
const UChar *srcChars, int32_t srcLength)
const {
4244 return doCompare(0, srcLength, srcChars, 0, srcLength) == 0;
4248 UnicodeString::startsWith(
const UChar *srcChars, int32_t srcStart, int32_t srcLength)
const {
4252 return doCompare(0, srcLength, srcChars, srcStart, srcLength) == 0;
4257 {
return doCompare(length() - text.
length(), text.
length(),
4258 text, 0, text.
length()) == 0; }
4263 int32_t srcLength)
const {
4264 srcText.pinIndices(srcStart, srcLength);
4265 return doCompare(length() - srcLength, srcLength,
4266 srcText, srcStart, srcLength) == 0;
4270 UnicodeString::endsWith(
const UChar *srcChars,
4271 int32_t srcLength)
const {
4275 return doCompare(length() - srcLength, srcLength,
4276 srcChars, 0, srcLength) == 0;
4280 UnicodeString::endsWith(
const UChar *srcChars,
4282 int32_t srcLength)
const {
4284 srcLength =
u_strlen(srcChars + srcStart);
4286 return doCompare(length() - srcLength, srcLength,
4287 srcChars, srcStart, srcLength) == 0;
4294 UnicodeString::replace(int32_t start,
4297 {
return doReplace(start, _length, srcText, 0, srcText.
length()); }
4300 UnicodeString::replace(int32_t start,
4305 {
return doReplace(start, _length, srcText, srcStart, srcLength); }
4308 UnicodeString::replace(int32_t start,
4310 const UChar *srcChars,
4312 {
return doReplace(start, _length, srcChars, 0, srcLength); }
4315 UnicodeString::replace(int32_t start,
4317 const UChar *srcChars,
4320 {
return doReplace(start, _length, srcChars, srcStart, srcLength); }
4323 UnicodeString::replace(int32_t start,
4326 {
return doReplace(start, _length, &srcChar, 0, 1); }
4329 UnicodeString::replaceBetween(int32_t start,
4332 {
return doReplace(start, limit - start, srcText, 0, srcText.
length()); }
4335 UnicodeString::replaceBetween(int32_t start,
4340 {
return doReplace(start, limit - start, srcText, srcStart, srcLimit - srcStart); }
4345 {
return findAndReplace(0, length(), oldText, 0, oldText.
length(),
4346 newText, 0, newText.
length()); }
4349 UnicodeString::findAndReplace(int32_t start,
4353 {
return findAndReplace(start, _length, oldText, 0, oldText.
length(),
4354 newText, 0, newText.
length()); }
4360 UnicodeString::doExtract(int32_t start,
4363 { target.
replace(0, target.
length(), *
this, start, _length); }
4366 UnicodeString::extract(int32_t start,
4369 int32_t targetStart)
const 4370 { doExtract(start, _length, target, targetStart); }
4373 UnicodeString::extract(int32_t start,
4376 { doExtract(start, _length, target); }
4378 #if !UCONFIG_NO_CONVERSION 4381 UnicodeString::extract(int32_t start,
4384 const char *codepage)
const 4388 return extract(start, _length, dst, dst!=0 ? 0xffffffff : 0, codepage);
4394 UnicodeString::extractBetween(int32_t start,
4397 int32_t dstStart)
const {
4400 doExtract(start, limit - start, dst, dstStart);
4404 UnicodeString::tempSubStringBetween(int32_t start, int32_t limit)
const {
4405 return tempSubString(start, limit - start);
4409 UnicodeString::doCharAt(int32_t offset)
const 4411 if((uint32_t)offset < (uint32_t)length()) {
4412 return getArrayStart()[offset];
4414 return kInvalidUChar;
4419 UnicodeString::charAt(int32_t offset)
const 4420 {
return doCharAt(offset); }
4423 UnicodeString::operator[] (int32_t offset)
const 4424 {
return doCharAt(offset); }
4427 UnicodeString::isEmpty()
const {
4429 return (fUnion.fFields.fLengthAndFlags>>kLengthShift) == 0;
4436 UnicodeString::setZeroLength() {
4437 fUnion.fFields.fLengthAndFlags &= kAllStorageFlags;
4441 UnicodeString::setShortLength(int32_t len) {
4443 fUnion.fFields.fLengthAndFlags =
4444 (int16_t)((fUnion.fFields.fLengthAndFlags & kAllStorageFlags) | (len << kLengthShift));
4448 UnicodeString::setLength(int32_t len) {
4449 if(len <= kMaxShortLength) {
4450 setShortLength(len);
4452 fUnion.fFields.fLengthAndFlags |= kLengthIsLarge;
4453 fUnion.fFields.fLength = len;
4458 UnicodeString::setToEmpty() {
4459 fUnion.fFields.fLengthAndFlags = kShortString;
4463 UnicodeString::setArray(
UChar *array, int32_t len, int32_t capacity) {
4465 fUnion.fFields.fArray = array;
4466 fUnion.fFields.fCapacity = capacity;
4471 {
return doReplace(0, length(), &ch, 0, 1); }
4475 {
return replace(0, length(), ch); }
4483 return doReplace(0, length(), srcText, srcStart, srcLength);
4491 srcText.pinIndex(srcStart);
4492 return doReplace(0, length(), srcText, srcStart, srcText.
length() - srcStart);
4498 return copyFrom(srcText);
4502 UnicodeString::setTo(
const UChar *srcChars,
4506 return doReplace(0, length(), srcChars, 0, srcLength);
4513 return doReplace(0, length(), &srcChar, 0, 1);
4520 return replace(0, length(), srcChar);
4527 {
return doAppend(srcText, srcStart, srcLength); }
4531 {
return doAppend(srcText, 0, srcText.
length()); }
4534 UnicodeString::append(
const UChar *srcChars,
4537 {
return doAppend(srcChars, srcStart, srcLength); }
4540 UnicodeString::append(
const UChar *srcChars,
4542 {
return doAppend(srcChars, 0, srcLength); }
4546 {
return doAppend(&srcChar, 0, 1); }
4550 {
return doAppend(&ch, 0, 1); }
4559 {
return doAppend(srcText, 0, srcText.
length()); }
4562 UnicodeString::insert(int32_t start,
4566 {
return doReplace(start, 0, srcText, srcStart, srcLength); }
4569 UnicodeString::insert(int32_t start,
4571 {
return doReplace(start, 0, srcText, 0, srcText.
length()); }
4574 UnicodeString::insert(int32_t start,
4575 const UChar *srcChars,
4578 {
return doReplace(start, 0, srcChars, srcStart, srcLength); }
4581 UnicodeString::insert(int32_t start,
4582 const UChar *srcChars,
4584 {
return doReplace(start, 0, srcChars, 0, srcLength); }
4587 UnicodeString::insert(int32_t start,
4589 {
return doReplace(start, 0, &srcChar, 0, 1); }
4592 UnicodeString::insert(int32_t start,
4594 {
return replace(start, 0, srcChar); }
4598 UnicodeString::remove()
4610 UnicodeString::remove(int32_t start,
4613 if(start <= 0 && _length ==
INT32_MAX) {
4617 return doReplace(start, _length,
NULL, 0, 0);
4621 UnicodeString::removeBetween(int32_t start,
4623 {
return doReplace(start, limit - start,
NULL, 0, 0); }
4626 UnicodeString::retainBetween(int32_t start, int32_t limit) {
4628 return doReplace(0, start,
NULL, 0, 0);
4632 UnicodeString::truncate(int32_t targetLength)
4634 if(isBogus() && targetLength == 0) {
4638 }
else if((uint32_t)targetLength < (uint32_t)length()) {
4639 setLength(targetLength);
4647 UnicodeString::reverse()
4648 {
return doReverse(0, length()); }
4651 UnicodeString::reverse(int32_t start,
4653 {
return doReverse(start, _length); }
#define UNISTR_OBJECT_SIZE
Desired sizeof(UnicodeString) in bytes.
int32_t UStringCaseMapper(const UCaseMap *csm, UChar *dest, int32_t destCapacity, const UChar *src, int32_t srcLength, UErrorCode *pErrorCode)
Internal string case mapping function type.
An Appendable implementation which writes to a UnicodeString.
C API: Unicode case mapping functions using a UCaseMap service object.
EInvariant
Constant to be used in the UnicodeString(char *, int32_t, EInvariant) constructor which constructs a ...
virtual UChar getCharAt(int32_t offset) const =0
Virtual version of charAt().
virtual void copy(int32_t start, int32_t limit, int32_t dest)=0
Copies a substring of this object, retaining metadata.
friend U_COMMON_API void swap(UnicodeString &s1, UnicodeString &s2) U_NOEXCEPT
Non-member UnicodeString swap function.
U_EXPORT UBool operator==(const StringPiece &x, const StringPiece &y)
Global operator == for StringPiece.
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
struct UCaseMap UCaseMap
C typedef for struct UCaseMap.
#define U_SIZEOF_UCHAR
Number of bytes in a UChar.
virtual void extractBetween(int32_t start, int32_t limit, UnicodeString &target) const =0
Copies characters in the range [start, limit) into the UnicodeString target.
A ByteSink can be filled with bytes.
virtual UChar32 getChar32At(int32_t offset) const =0
Virtual version of char32At().
UBool isBogus(void) const
Determine if this object contains a valid string.
C++ API: StringPiece: Read-only byte string wrapper class.
Replaceable is an abstract base class representing a string of characters that supports the replaceme...
#define UNISTR_FROM_CHAR_EXPLICIT
This can be defined to be empty or "explicit".
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
StringClass & toUTF8String(StringClass &result) const
Convert the UnicodeString to UTF-8 and append the result to a standard string.
int32_t length() const
Returns the number of 16-bit code units in the text.
C++ API: Interface for writing bytes, and implementation classes.
U_COMMON_API UnicodeString operator+(const UnicodeString &s1, const UnicodeString &s2)
Create a new UnicodeString with the concatenation of two others.
virtual int32_t getLength() const =0
Virtual version of length().
The BreakIterator class implements methods for finding the location of boundaries in text...
UBool operator!=(const StringPiece &x, const StringPiece &y)
Global operator != for StringPiece.
UChar32 char32At(int32_t offset) const
Returns the 32-bit code point at the given 16-bit offset into the text.
int32_t UChar32
Define UChar32 as a type for single Unicode code points.
#define NULL
Define NULL if necessary, to 0 for C++ and to ((void *)0) for C.
virtual UClassID getDynamicClassID() const
ICU4C "poor man's RTTI", returns a UClassID for the actual ICU class.
C++ API: Central ICU header for including the C++ standard <string> header and for related definition...
#define TRUE
The TRUE value of a UBool.
uint16_t UChar
Define UChar to be UCHAR_TYPE, if that is #defined (for example, to char16_t), or wchar_t if that is ...
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
struct UConverter UConverter
#define INT32_MAX
The largest value a 32 bit signed integer can hold.
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers...
int32_t length(void) const
Return the length of the UnicodeString object.
UChar charAt(int32_t offset) const
Returns the 16-bit code unit at the given offset into the text.
virtual void handleReplaceBetween(int32_t start, int32_t limit, const UnicodeString &text)=0
Replaces a substring of this object with the given text.
Basic definitions for ICU, for both C and C++ APIs.
Implementation of ByteSink that writes to a "string".
int32_t u_strlen(const UChar *s)
Determine the length of an array of UChar.
virtual Replaceable * clone() const
Clone this object, an instance of a subclass of Replaceable.
#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...
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
virtual UBool hasMetaData() const
Returns true if this object contains metadata.
#define UNISTR_FROM_STRING_EXPLICIT
This can be defined to be empty or "explicit".
A string-like object that points to a sized piece of memory.
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...
#define U_STABLE
This is used to declare a function as a stable public ICU C API.
int8_t UBool
The ICU boolean type.
A Locale object represents a specific geographical, political, or cultural region.
C++ API: Replaceable String.