38 #ifndef U_COMPARE_CODE_POINT_ORDER 45 #define U_COMPARE_CODE_POINT_ORDER 0x8000 60 #ifndef U_STRING_CASE_MAPPER_DEFINED 61 #define U_STRING_CASE_MAPPER_DEFINED 69 UChar *dest, int32_t destCapacity,
70 const UChar *src, int32_t srcLength,
79 class StringCharacterIterator;
80 class UnicodeStringAppendable;
94 #define US_INV icu::UnicodeString::kInvariant 113 #if defined(U_DECLARE_UTF16) 114 # define UNICODE_STRING(cs, _length) icu::UnicodeString(TRUE, (const UChar *)U_DECLARE_UTF16(cs), _length) 115 #elif U_SIZEOF_WCHAR_T==U_SIZEOF_UCHAR && (U_CHARSET_FAMILY==U_ASCII_FAMILY || (U_SIZEOF_UCHAR == 2 && defined(U_WCHAR_IS_UTF16))) 116 # define UNICODE_STRING(cs, _length) icu::UnicodeString(TRUE, (const UChar *)L ## cs, _length) 117 #elif U_SIZEOF_UCHAR==1 && U_CHARSET_FAMILY==U_ASCII_FAMILY 118 # define UNICODE_STRING(cs, _length) icu::UnicodeString(TRUE, (const UChar *)cs, _length) 120 # define UNICODE_STRING(cs, _length) icu::UnicodeString(cs, _length, US_INV) 136 #define UNICODE_STRING_SIMPLE(cs) UNICODE_STRING(cs, -1) 145 #ifndef UNISTR_FROM_CHAR_EXPLICIT 146 # if defined(U_COMBINED_IMPLEMENTATION) || defined(U_COMMON_IMPLEMENTATION) || defined(U_I18N_IMPLEMENTATION) || defined(U_IO_IMPLEMENTATION) 148 # define UNISTR_FROM_CHAR_EXPLICIT explicit 151 # define UNISTR_FROM_CHAR_EXPLICIT 165 #ifndef UNISTR_FROM_STRING_EXPLICIT 166 # if defined(U_COMBINED_IMPLEMENTATION) || defined(U_COMMON_IMPLEMENTATION) || defined(U_I18N_IMPLEMENTATION) || defined(U_IO_IMPLEMENTATION) 168 # define UNISTR_FROM_STRING_EXPLICIT explicit 171 # define UNISTR_FROM_STRING_EXPLICIT 210 #ifndef UNISTR_OBJECT_SIZE 211 # define UNISTR_OBJECT_SIZE 64 401 inline int8_t compare(int32_t start,
422 inline int8_t compare(int32_t start,
426 int32_t srcLength)
const;
440 inline int8_t compare(
const UChar *srcChars,
441 int32_t srcLength)
const;
457 inline int8_t compare(int32_t start,
459 const UChar *srcChars)
const;
478 inline int8_t compare(int32_t start,
480 const UChar *srcChars,
482 int32_t srcLength)
const;
501 inline int8_t compareBetween(int32_t start,
505 int32_t srcLimit)
const;
524 inline int8_t compareCodePointOrder(
const UnicodeString& text)
const;
545 inline int8_t compareCodePointOrder(int32_t start,
570 inline int8_t compareCodePointOrder(int32_t start,
574 int32_t srcLength)
const;
594 inline int8_t compareCodePointOrder(
const UChar *srcChars,
595 int32_t srcLength)
const;
616 inline int8_t compareCodePointOrder(int32_t start,
618 const UChar *srcChars)
const;
641 inline int8_t compareCodePointOrder(int32_t start,
643 const UChar *srcChars,
645 int32_t srcLength)
const;
668 inline int8_t compareCodePointOrderBetween(int32_t start,
672 int32_t srcLimit)
const;
692 inline int8_t caseCompare(
const UnicodeString& text, uint32_t options)
const;
714 inline int8_t caseCompare(int32_t start,
717 uint32_t options)
const;
741 inline int8_t caseCompare(int32_t start,
746 uint32_t options)
const;
767 inline int8_t caseCompare(
const UChar *srcChars,
769 uint32_t options)
const;
791 inline int8_t caseCompare(int32_t start,
793 const UChar *srcChars,
794 uint32_t options)
const;
818 inline int8_t caseCompare(int32_t start,
820 const UChar *srcChars,
823 uint32_t options)
const;
847 inline int8_t caseCompareBetween(int32_t start,
852 uint32_t options)
const;
875 int32_t srcLength)
const;
885 inline UBool startsWith(
const UChar *srcChars,
886 int32_t srcLength)
const;
897 inline UBool startsWith(
const UChar *srcChars,
899 int32_t srcLength)
const;
922 int32_t srcLength)
const;
933 int32_t srcLength)
const;
947 int32_t srcLength)
const;
972 int32_t start)
const;
987 int32_t length)
const;
1009 int32_t length)
const;
1022 inline int32_t indexOf(
const UChar *srcChars,
1024 int32_t start)
const;
1038 inline int32_t indexOf(
const UChar *srcChars,
1041 int32_t length)
const;
1059 int32_t indexOf(
const UChar *srcChars,
1063 int32_t length)
const;
1072 inline int32_t indexOf(
UChar c)
const;
1082 inline int32_t indexOf(
UChar32 c)
const;
1092 inline int32_t indexOf(
UChar c,
1093 int32_t start)
const;
1104 inline int32_t indexOf(
UChar32 c,
1105 int32_t start)
const;
1117 inline int32_t indexOf(
UChar c,
1119 int32_t length)
const;
1132 inline int32_t indexOf(
UChar32 c,
1134 int32_t length)
const;
1144 inline int32_t lastIndexOf(
const UnicodeString& text)
const;
1156 int32_t start)
const;
1171 int32_t length)
const;
1193 int32_t length)
const;
1205 inline int32_t lastIndexOf(
const UChar *srcChars,
1207 int32_t start)
const;
1221 inline int32_t lastIndexOf(
const UChar *srcChars,
1224 int32_t length)
const;
1242 int32_t lastIndexOf(
const UChar *srcChars,
1246 int32_t length)
const;
1255 inline int32_t lastIndexOf(
UChar c)
const;
1265 inline int32_t lastIndexOf(
UChar32 c)
const;
1275 inline int32_t lastIndexOf(
UChar c,
1276 int32_t start)
const;
1287 inline int32_t lastIndexOf(
UChar32 c,
1288 int32_t start)
const;
1300 inline int32_t lastIndexOf(
UChar c,
1302 int32_t length)
const;
1315 inline int32_t lastIndexOf(
UChar32 c,
1317 int32_t length)
const;
1339 inline UChar operator[] (int32_t offset)
const;
1369 int32_t getChar32Start(int32_t offset)
const;
1387 int32_t getChar32Limit(int32_t offset)
const;
1439 int32_t moveIndex32(int32_t index, int32_t delta)
const;
1458 inline void extract(int32_t start,
1461 int32_t dstStart = 0)
const;
1485 extract(
UChar *dest, int32_t destCapacity,
1498 inline void extract(int32_t start,
1516 int32_t dstStart = 0)
const;
1552 int32_t extract(int32_t start,
1553 int32_t startLength,
1555 int32_t targetCapacity,
1558 #if U_CHARSET_IS_UTF8 || !UCONFIG_NO_CONVERSION 1579 int32_t extract(int32_t start,
1580 int32_t startLength,
1582 uint32_t targetLength)
const;
1586 #if !UCONFIG_NO_CONVERSION 1613 inline int32_t extract(int32_t start,
1614 int32_t startLength,
1616 const char *codepage = 0)
const;
1647 int32_t extract(int32_t start,
1648 int32_t startLength,
1650 uint32_t targetLength,
1651 const char *codepage)
const;
1670 int32_t extract(
char *dest, int32_t destCapacity,
1716 #if U_HAVE_STD_STRING 1730 template<
typename StringClass>
1766 inline int32_t
length(
void)
const;
1782 countChar32(int32_t start=0, int32_t length=
INT32_MAX)
const;
1808 hasMoreChar32Than(int32_t start, int32_t length, int32_t number)
const;
1815 inline UBool isEmpty(
void)
const;
1826 inline int32_t getCapacity(
void)
const;
1835 inline int32_t hashCode(
void)
const;
1849 inline UBool isBogus(
void)
const;
1905 #ifndef U_HIDE_DRAFT_API 1906 #if U_HAVE_RVALUE_REFERENCES 1916 return moveFrom(src);
2065 int32_t textLength);
2088 int32_t buffCapacity);
2290 const UChar *srcChars,
2304 const UChar *srcChars,
2390 const UChar *srcChars,
2408 const UChar *srcChars,
2508 virtual void copy(int32_t start, int32_t limit, int32_t dest);
2594 inline UnicodeString& removeBetween(int32_t start,
2606 inline UnicodeString &retainBetween(int32_t start, int32_t limit = INT32_MAX);
2621 UBool padLeading(int32_t targetLength,
2622 UChar padChar = 0x0020);
2635 UBool padTrailing(int32_t targetLength,
2636 UChar padChar = 0x0020);
2644 inline UBool truncate(int32_t targetLength);
2651 UnicodeString& trim(
void);
2661 inline UnicodeString& reverse(
void);
2671 inline UnicodeString& reverse(int32_t start,
2680 UnicodeString& toUpper(
void);
2689 UnicodeString& toUpper(
const Locale& locale);
2697 UnicodeString& toLower(
void);
2706 UnicodeString& toLower(
const Locale& locale);
2708 #if !UCONFIG_NO_BREAK_ITERATION 2815 UnicodeString &foldCase(uint32_t options=0 );
2864 UChar *getBuffer(int32_t minCapacity);
2886 void releaseBuffer(int32_t newLength=-1);
2918 inline const UChar *getBuffer()
const;
2953 const UChar *getTerminatedBuffer();
2962 inline UnicodeString();
2975 UnicodeString(int32_t capacity,
UChar32 c, int32_t count);
3018 UnicodeString(
const UChar *text,
3019 int32_t textLength);
3043 UnicodeString(
UBool isTerminated,
3045 int32_t textLength);
3065 UnicodeString(
UChar *buffer, int32_t buffLength, int32_t buffCapacity);
3067 #if U_CHARSET_IS_UTF8 || !UCONFIG_NO_CONVERSION 3098 UnicodeString(
const char *codepageData, int32_t dataLength);
3102 #if !UCONFIG_NO_CONVERSION 3121 UnicodeString(
const char *codepageData,
const char *codepage);
3140 UnicodeString(
const char *codepageData, int32_t dataLength,
const char *codepage);
3164 const char *src, int32_t srcLength,
3194 UnicodeString(
const char *src, int32_t length,
enum EInvariant inv);
3213 UnicodeString(
const UnicodeString& that);
3215 #ifndef U_HIDE_DRAFT_API 3216 #if U_HAVE_RVALUE_REFERENCES 3223 UnicodeString(UnicodeString &&src)
U_NOEXCEPT;
3233 UnicodeString(
const UnicodeString& src, int32_t srcStart);
3242 UnicodeString(
const UnicodeString& src, int32_t srcStart, int32_t srcLength);
3265 virtual ~UnicodeString();
3280 static UnicodeString fromUTF8(
const StringPiece &utf8);
3293 static UnicodeString fromUTF32(
const UChar32 *utf32, int32_t length);
3331 UnicodeString unescape()
const;
3352 UChar32 unescapeAt(int32_t &offset)
const;
3359 static UClassID U_EXPORT2 getStaticClassID();
3395 UnicodeString &setToUTF8(
const StringPiece &utf8);
3402 toUTF8(int32_t start, int32_t len,
3403 char *target, int32_t capacity)
const;
3409 UBool doEquals(
const UnicodeString &text, int32_t len)
const;
3412 doCompare(int32_t start,
3414 const UnicodeString& srcText,
3416 int32_t srcLength)
const;
3418 int8_t doCompare(int32_t start,
3420 const UChar *srcChars,
3422 int32_t srcLength)
const;
3425 doCompareCodePointOrder(int32_t start,
3427 const UnicodeString& srcText,
3429 int32_t srcLength)
const;
3431 int8_t doCompareCodePointOrder(int32_t start,
3433 const UChar *srcChars,
3435 int32_t srcLength)
const;
3438 doCaseCompare(int32_t start,
3440 const UnicodeString &srcText,
3443 uint32_t options)
const;
3446 doCaseCompare(int32_t start,
3448 const UChar *srcChars,
3451 uint32_t options)
const;
3453 int32_t doIndexOf(
UChar c,
3455 int32_t length)
const;
3459 int32_t length)
const;
3461 int32_t doLastIndexOf(
UChar c,
3463 int32_t length)
const;
3465 int32_t doLastIndexOf(
UChar32 c,
3467 int32_t length)
const;
3469 void doExtract(int32_t start,
3472 int32_t dstStart)
const;
3474 inline void doExtract(int32_t start,
3476 UnicodeString& target)
const;
3478 inline UChar doCharAt(int32_t offset)
const;
3480 UnicodeString& doReplace(int32_t start,
3482 const UnicodeString& srcText,
3486 UnicodeString& doReplace(int32_t start,
3488 const UChar *srcChars,
3492 UnicodeString& doAppend(
const UnicodeString& src, int32_t srcStart, int32_t srcLength);
3493 UnicodeString& doAppend(
const UChar *srcChars, int32_t srcStart, int32_t srcLength);
3495 UnicodeString& doReverse(int32_t start,
3499 int32_t doHashCode(
void)
const;
3503 inline UChar* getArrayStart(
void);
3504 inline const UChar* getArrayStart(
void)
const;
3506 inline UBool hasShortLength()
const;
3507 inline int32_t getShortLength()
const;
3511 inline UBool isWritable()
const;
3514 inline UBool isBufferWritable()
const;
3517 inline void setZeroLength();
3518 inline void setShortLength(int32_t len);
3519 inline void setLength(int32_t len);
3520 inline void setToEmpty();
3521 inline void setArray(
UChar *array, int32_t len, int32_t capacity);
3528 UBool allocate(int32_t capacity);
3531 void releaseArray(
void);
3537 UnicodeString ©From(
const UnicodeString &src,
UBool fastCopy=
FALSE);
3540 void copyFieldsFrom(UnicodeString &src,
UBool setSrcToBogus)
U_NOEXCEPT;
3543 inline void pinIndex(int32_t& start)
const;
3544 inline void pinIndices(int32_t& start,
3545 int32_t& length)
const;
3547 #if !UCONFIG_NO_CONVERSION 3550 int32_t doExtract(int32_t start, int32_t length,
3551 char *dest, int32_t destCapacity,
3565 void doCodepageCreate(
const char *codepageData,
3567 const char *codepage);
3574 doCodepageCreate(
const char *codepageData,
3592 UBool cloneArrayIfNeeded(int32_t newCapacity = -1,
3593 int32_t growCapacity = -1,
3595 int32_t **pBufferToDelete = 0,
3608 int32_t removeRef(
void);
3609 int32_t refCount(
void)
const;
3619 kInvalidUChar=0xffff,
3626 kUsingStackBuffer=2,
3628 kBufferIsReadonly=8,
3631 kAllStorageFlags=0x1f,
3634 kLength1=1<<kLengthShift,
3635 kMaxShortLength=0x3ff,
3636 kLengthIsLarge=0xffe0,
3639 kShortString=kUsingStackBuffer,
3640 kLongString=kRefCounted,
3641 kReadonlyAlias=kBufferIsReadonly,
3647 union StackBufferOrFields;
3648 friend union StackBufferOrFields;
3691 union StackBufferOrFields {
3695 int16_t fLengthAndFlags;
3696 UChar fBuffer[US_STACKBUF_SIZE];
3699 int16_t fLengthAndFlags;
3729 UnicodeString::pinIndex(int32_t& start)
const 3734 }
else if(start > length()) {
3740 UnicodeString::pinIndices(int32_t& start,
3741 int32_t& _length)
const 3744 int32_t len = length();
3747 }
else if(start > len) {
3752 }
else if(_length > (len - start)) {
3753 _length = (len - start);
3758 UnicodeString::getArrayStart() {
3759 return (fUnion.fFields.fLengthAndFlags&kUsingStackBuffer) ?
3760 fUnion.fStackFields.fBuffer : fUnion.fFields.fArray;
3764 UnicodeString::getArrayStart()
const {
3765 return (fUnion.fFields.fLengthAndFlags&kUsingStackBuffer) ?
3766 fUnion.fStackFields.fBuffer : fUnion.fFields.fArray;
3774 UnicodeString::UnicodeString() {
3775 fUnion.fStackFields.fLengthAndFlags=kShortString;
3782 UnicodeString::hasShortLength()
const {
3783 return fUnion.fFields.fLengthAndFlags>=0;
3787 UnicodeString::getShortLength()
const {
3790 return fUnion.fFields.fLengthAndFlags>>kLengthShift;
3794 UnicodeString::length()
const {
3795 return hasShortLength() ? getShortLength() : fUnion.fFields.fLength;
3799 UnicodeString::getCapacity()
const {
3800 return (fUnion.fFields.fLengthAndFlags&kUsingStackBuffer) ?
3801 US_STACKBUF_SIZE : fUnion.fFields.fCapacity;
3805 UnicodeString::hashCode()
const 3806 {
return doHashCode(); }
3809 UnicodeString::isBogus()
const 3810 {
return (
UBool)(fUnion.fFields.fLengthAndFlags & kIsBogus); }
3813 UnicodeString::isWritable()
const 3814 {
return (
UBool)!(fUnion.fFields.fLengthAndFlags&(kOpenGetBuffer|kIsBogus)); }
3817 UnicodeString::isBufferWritable()
const 3820 !(fUnion.fFields.fLengthAndFlags&(kOpenGetBuffer|kIsBogus|kBufferIsReadonly)) &&
3821 (!(fUnion.fFields.fLengthAndFlags&kRefCounted) || refCount()==1));
3824 inline const UChar *
3825 UnicodeString::getBuffer()
const {
3826 if(fUnion.fFields.fLengthAndFlags&(kIsBogus|kOpenGetBuffer)) {
3828 }
else if(fUnion.fFields.fLengthAndFlags&kUsingStackBuffer) {
3829 return fUnion.fStackFields.fBuffer;
3831 return fUnion.fFields.fArray;
3839 UnicodeString::doCompare(int32_t start,
3843 int32_t srcLength)
const 3846 return (int8_t)!isBogus();
3848 srcText.pinIndices(srcStart, srcLength);
3849 return doCompare(start, thisLength, srcText.getArrayStart(), srcStart, srcLength);
3859 int32_t len = length(), textLength = text.
length();
3860 return !text.
isBogus() && len == textLength && doEquals(text, len);
3866 {
return (!
operator==(text)); }
3870 {
return doCompare(0, length(), text, 0, text.
length()) == 1; }
3874 {
return doCompare(0, length(), text, 0, text.
length()) == -1; }
3878 {
return doCompare(0, length(), text, 0, text.
length()) != -1; }
3882 {
return doCompare(0, length(), text, 0, text.
length()) != 1; }
3886 {
return doCompare(0, length(), text, 0, text.
length()); }
3889 UnicodeString::compare(int32_t start,
3892 {
return doCompare(start, _length, srcText, 0, srcText.
length()); }
3895 UnicodeString::compare(
const UChar *srcChars,
3896 int32_t srcLength)
const 3897 {
return doCompare(0, length(), srcChars, 0, srcLength); }
3900 UnicodeString::compare(int32_t start,
3904 int32_t srcLength)
const 3905 {
return doCompare(start, _length, srcText, srcStart, srcLength); }
3908 UnicodeString::compare(int32_t start,
3910 const UChar *srcChars)
const 3911 {
return doCompare(start, _length, srcChars, 0, _length); }
3914 UnicodeString::compare(int32_t start,
3916 const UChar *srcChars,
3918 int32_t srcLength)
const 3919 {
return doCompare(start, _length, srcChars, srcStart, srcLength); }
3922 UnicodeString::compareBetween(int32_t start,
3926 int32_t srcLimit)
const 3927 {
return doCompare(start, limit - start,
3928 srcText, srcStart, srcLimit - srcStart); }
3931 UnicodeString::doCompareCodePointOrder(int32_t start,
3935 int32_t srcLength)
const 3938 return (int8_t)!isBogus();
3940 srcText.pinIndices(srcStart, srcLength);
3941 return doCompareCodePointOrder(start, thisLength, srcText.getArrayStart(), srcStart, srcLength);
3947 {
return doCompareCodePointOrder(0, length(), text, 0, text.
length()); }
3950 UnicodeString::compareCodePointOrder(int32_t start,
3953 {
return doCompareCodePointOrder(start, _length, srcText, 0, srcText.
length()); }
3956 UnicodeString::compareCodePointOrder(
const UChar *srcChars,
3957 int32_t srcLength)
const 3958 {
return doCompareCodePointOrder(0, length(), srcChars, 0, srcLength); }
3961 UnicodeString::compareCodePointOrder(int32_t start,
3965 int32_t srcLength)
const 3966 {
return doCompareCodePointOrder(start, _length, srcText, srcStart, srcLength); }
3969 UnicodeString::compareCodePointOrder(int32_t start,
3971 const UChar *srcChars)
const 3972 {
return doCompareCodePointOrder(start, _length, srcChars, 0, _length); }
3975 UnicodeString::compareCodePointOrder(int32_t start,
3977 const UChar *srcChars,
3979 int32_t srcLength)
const 3980 {
return doCompareCodePointOrder(start, _length, srcChars, srcStart, srcLength); }
3983 UnicodeString::compareCodePointOrderBetween(int32_t start,
3987 int32_t srcLimit)
const 3988 {
return doCompareCodePointOrder(start, limit - start,
3989 srcText, srcStart, srcLimit - srcStart); }
3992 UnicodeString::doCaseCompare(int32_t start,
3997 uint32_t options)
const 4000 return (int8_t)!isBogus();
4002 srcText.pinIndices(srcStart, srcLength);
4003 return doCaseCompare(start, thisLength, srcText.getArrayStart(), srcStart, srcLength, options);
4009 return doCaseCompare(0, length(), text, 0, text.
length(), options);
4013 UnicodeString::caseCompare(int32_t start,
4016 uint32_t options)
const {
4017 return doCaseCompare(start, _length, srcText, 0, srcText.
length(), options);
4021 UnicodeString::caseCompare(
const UChar *srcChars,
4023 uint32_t options)
const {
4024 return doCaseCompare(0, length(), srcChars, 0, srcLength, options);
4028 UnicodeString::caseCompare(int32_t start,
4033 uint32_t options)
const {
4034 return doCaseCompare(start, _length, srcText, srcStart, srcLength, options);
4038 UnicodeString::caseCompare(int32_t start,
4040 const UChar *srcChars,
4041 uint32_t options)
const {
4042 return doCaseCompare(start, _length, srcChars, 0, _length, options);
4046 UnicodeString::caseCompare(int32_t start,
4048 const UChar *srcChars,
4051 uint32_t options)
const {
4052 return doCaseCompare(start, _length, srcChars, srcStart, srcLength, options);
4056 UnicodeString::caseCompareBetween(int32_t start,
4061 uint32_t options)
const {
4062 return doCaseCompare(start, limit - start, srcText, srcStart, srcLimit - srcStart, options);
4070 int32_t _length)
const 4073 srcText.pinIndices(srcStart, srcLength);
4075 return indexOf(srcText.getArrayStart(), srcStart, srcLength, start, _length);
4083 {
return indexOf(text, 0, text.
length(), 0, length()); }
4087 int32_t start)
const {
4089 return indexOf(text, 0, text.
length(), start, length() - start);
4095 int32_t _length)
const 4096 {
return indexOf(text, 0, text.
length(), start, _length); }
4099 UnicodeString::indexOf(
const UChar *srcChars,
4101 int32_t start)
const {
4103 return indexOf(srcChars, 0, srcLength, start, length() - start);
4107 UnicodeString::indexOf(
const UChar *srcChars,
4110 int32_t _length)
const 4111 {
return indexOf(srcChars, 0, srcLength, start, _length); }
4116 int32_t _length)
const 4117 {
return doIndexOf(c, start, _length); }
4122 int32_t _length)
const 4123 {
return doIndexOf(c, start, _length); }
4127 {
return doIndexOf(c, 0, length()); }
4131 {
return indexOf(c, 0, length()); }
4135 int32_t start)
const {
4137 return doIndexOf(c, start, length() - start);
4142 int32_t start)
const {
4144 return indexOf(c, start, length() - start);
4148 UnicodeString::lastIndexOf(
const UChar *srcChars,
4151 int32_t _length)
const 4152 {
return lastIndexOf(srcChars, 0, srcLength, start, _length); }
4155 UnicodeString::lastIndexOf(
const UChar *srcChars,
4157 int32_t start)
const {
4159 return lastIndexOf(srcChars, 0, srcLength, start, length() - start);
4167 int32_t _length)
const 4170 srcText.pinIndices(srcStart, srcLength);
4172 return lastIndexOf(srcText.getArrayStart(), srcStart, srcLength, start, _length);
4181 int32_t _length)
const 4182 {
return lastIndexOf(text, 0, text.
length(), start, _length); }
4186 int32_t start)
const {
4188 return lastIndexOf(text, 0, text.
length(), start, length() - start);
4193 {
return lastIndexOf(text, 0, text.
length(), 0, length()); }
4198 int32_t _length)
const 4199 {
return doLastIndexOf(c, start, _length); }
4204 int32_t _length)
const {
4205 return doLastIndexOf(c, start, _length);
4209 UnicodeString::lastIndexOf(
UChar c)
const 4210 {
return doLastIndexOf(c, 0, length()); }
4214 return lastIndexOf(c, 0, length());
4219 int32_t start)
const {
4221 return doLastIndexOf(c, start, length() - start);
4226 int32_t start)
const {
4228 return lastIndexOf(c, start, length() - start);
4233 {
return compare(0, text.
length(), text, 0, text.
length()) == 0; }
4238 int32_t srcLength)
const 4239 {
return doCompare(0, srcLength, srcText, srcStart, srcLength) == 0; }
4242 UnicodeString::startsWith(
const UChar *srcChars, int32_t srcLength)
const {
4246 return doCompare(0, srcLength, srcChars, 0, srcLength) == 0;
4250 UnicodeString::startsWith(
const UChar *srcChars, int32_t srcStart, int32_t srcLength)
const {
4254 return doCompare(0, srcLength, srcChars, srcStart, srcLength) == 0;
4259 {
return doCompare(length() - text.
length(), text.
length(),
4260 text, 0, text.
length()) == 0; }
4265 int32_t srcLength)
const {
4266 srcText.pinIndices(srcStart, srcLength);
4267 return doCompare(length() - srcLength, srcLength,
4268 srcText, srcStart, srcLength) == 0;
4272 UnicodeString::endsWith(
const UChar *srcChars,
4273 int32_t srcLength)
const {
4277 return doCompare(length() - srcLength, srcLength,
4278 srcChars, 0, srcLength) == 0;
4282 UnicodeString::endsWith(
const UChar *srcChars,
4284 int32_t srcLength)
const {
4286 srcLength =
u_strlen(srcChars + srcStart);
4288 return doCompare(length() - srcLength, srcLength,
4289 srcChars, srcStart, srcLength) == 0;
4296 UnicodeString::replace(int32_t start,
4299 {
return doReplace(start, _length, srcText, 0, srcText.
length()); }
4302 UnicodeString::replace(int32_t start,
4307 {
return doReplace(start, _length, srcText, srcStart, srcLength); }
4310 UnicodeString::replace(int32_t start,
4312 const UChar *srcChars,
4314 {
return doReplace(start, _length, srcChars, 0, srcLength); }
4317 UnicodeString::replace(int32_t start,
4319 const UChar *srcChars,
4322 {
return doReplace(start, _length, srcChars, srcStart, srcLength); }
4325 UnicodeString::replace(int32_t start,
4328 {
return doReplace(start, _length, &srcChar, 0, 1); }
4331 UnicodeString::replaceBetween(int32_t start,
4334 {
return doReplace(start, limit - start, srcText, 0, srcText.
length()); }
4337 UnicodeString::replaceBetween(int32_t start,
4342 {
return doReplace(start, limit - start, srcText, srcStart, srcLimit - srcStart); }
4347 {
return findAndReplace(0, length(), oldText, 0, oldText.
length(),
4348 newText, 0, newText.
length()); }
4351 UnicodeString::findAndReplace(int32_t start,
4355 {
return findAndReplace(start, _length, oldText, 0, oldText.
length(),
4356 newText, 0, newText.
length()); }
4362 UnicodeString::doExtract(int32_t start,
4365 { target.
replace(0, target.
length(), *
this, start, _length); }
4368 UnicodeString::extract(int32_t start,
4371 int32_t targetStart)
const 4372 { doExtract(start, _length, target, targetStart); }
4375 UnicodeString::extract(int32_t start,
4378 { doExtract(start, _length, target); }
4380 #if !UCONFIG_NO_CONVERSION 4383 UnicodeString::extract(int32_t start,
4386 const char *codepage)
const 4390 return extract(start, _length, dst, dst!=0 ? 0xffffffff : 0, codepage);
4396 UnicodeString::extractBetween(int32_t start,
4399 int32_t dstStart)
const {
4402 doExtract(start, limit - start, dst, dstStart);
4406 UnicodeString::tempSubStringBetween(int32_t start, int32_t limit)
const {
4407 return tempSubString(start, limit - start);
4411 UnicodeString::doCharAt(int32_t offset)
const 4413 if((uint32_t)offset < (uint32_t)length()) {
4414 return getArrayStart()[offset];
4416 return kInvalidUChar;
4421 UnicodeString::charAt(int32_t offset)
const 4422 {
return doCharAt(offset); }
4425 UnicodeString::operator[] (int32_t offset)
const 4426 {
return doCharAt(offset); }
4429 UnicodeString::isEmpty()
const {
4431 return (fUnion.fFields.fLengthAndFlags>>kLengthShift) == 0;
4438 UnicodeString::setZeroLength() {
4439 fUnion.fFields.fLengthAndFlags &= kAllStorageFlags;
4443 UnicodeString::setShortLength(int32_t len) {
4445 fUnion.fFields.fLengthAndFlags =
4446 (int16_t)((fUnion.fFields.fLengthAndFlags & kAllStorageFlags) | (len << kLengthShift));
4450 UnicodeString::setLength(int32_t len) {
4451 if(len <= kMaxShortLength) {
4452 setShortLength(len);
4454 fUnion.fFields.fLengthAndFlags |= kLengthIsLarge;
4455 fUnion.fFields.fLength = len;
4460 UnicodeString::setToEmpty() {
4461 fUnion.fFields.fLengthAndFlags = kShortString;
4465 UnicodeString::setArray(
UChar *array, int32_t len, int32_t capacity) {
4467 fUnion.fFields.fArray = array;
4468 fUnion.fFields.fCapacity = capacity;
4473 {
return doReplace(0, length(), &ch, 0, 1); }
4477 {
return replace(0, length(), ch); }
4485 return doReplace(0, length(), srcText, srcStart, srcLength);
4493 srcText.pinIndex(srcStart);
4494 return doReplace(0, length(), srcText, srcStart, srcText.
length() - srcStart);
4500 return copyFrom(srcText);
4504 UnicodeString::setTo(
const UChar *srcChars,
4508 return doReplace(0, length(), srcChars, 0, srcLength);
4515 return doReplace(0, length(), &srcChar, 0, 1);
4522 return replace(0, length(), srcChar);
4529 {
return doAppend(srcText, srcStart, srcLength); }
4533 {
return doAppend(srcText, 0, srcText.
length()); }
4536 UnicodeString::append(
const UChar *srcChars,
4539 {
return doAppend(srcChars, srcStart, srcLength); }
4542 UnicodeString::append(
const UChar *srcChars,
4544 {
return doAppend(srcChars, 0, srcLength); }
4548 {
return doAppend(&srcChar, 0, 1); }
4552 {
return doAppend(&ch, 0, 1); }
4561 {
return doAppend(srcText, 0, srcText.
length()); }
4564 UnicodeString::insert(int32_t start,
4568 {
return doReplace(start, 0, srcText, srcStart, srcLength); }
4571 UnicodeString::insert(int32_t start,
4573 {
return doReplace(start, 0, srcText, 0, srcText.
length()); }
4576 UnicodeString::insert(int32_t start,
4577 const UChar *srcChars,
4580 {
return doReplace(start, 0, srcChars, srcStart, srcLength); }
4583 UnicodeString::insert(int32_t start,
4584 const UChar *srcChars,
4586 {
return doReplace(start, 0, srcChars, 0, srcLength); }
4589 UnicodeString::insert(int32_t start,
4591 {
return doReplace(start, 0, &srcChar, 0, 1); }
4594 UnicodeString::insert(int32_t start,
4596 {
return replace(start, 0, srcChar); }
4600 UnicodeString::remove()
4612 UnicodeString::remove(int32_t start,
4615 if(start <= 0 && _length ==
INT32_MAX) {
4619 return doReplace(start, _length,
NULL, 0, 0);
4623 UnicodeString::removeBetween(int32_t start,
4625 {
return doReplace(start, limit - start,
NULL, 0, 0); }
4628 UnicodeString::retainBetween(int32_t start, int32_t limit) {
4630 return doReplace(0, start,
NULL, 0, 0);
4634 UnicodeString::truncate(int32_t targetLength)
4636 if(isBogus() && targetLength == 0) {
4640 }
else if((uint32_t)targetLength < (uint32_t)length()) {
4641 setLength(targetLength);
4649 UnicodeString::reverse()
4650 {
return doReverse(0, length()); }
4653 UnicodeString::reverse(int32_t start,
4655 {
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.