41 #ifndef U_COMPARE_CODE_POINT_ORDER 48 #define U_COMPARE_CODE_POINT_ORDER 0x8000 61 #if !UCONFIG_NO_BREAK_ITERATION 80 char16_t *dest, int32_t destCapacity,
81 const char16_t *src, int32_t srcLength,
88 class StringCharacterIterator;
89 class UnicodeStringAppendable;
103 #define US_INV icu::UnicodeString::kInvariant 122 #if !U_CHAR16_IS_TYPEDEF 123 # define UNICODE_STRING(cs, _length) icu::UnicodeString(TRUE, u ## cs, _length) 125 # define UNICODE_STRING(cs, _length) icu::UnicodeString(TRUE, (const char16_t*)u ## cs, _length) 141 #define UNICODE_STRING_SIMPLE(cs) UNICODE_STRING(cs, -1) 150 #ifndef UNISTR_FROM_CHAR_EXPLICIT 151 # if defined(U_COMBINED_IMPLEMENTATION) || defined(U_COMMON_IMPLEMENTATION) || defined(U_I18N_IMPLEMENTATION) || defined(U_IO_IMPLEMENTATION) 153 # define UNISTR_FROM_CHAR_EXPLICIT explicit 156 # define UNISTR_FROM_CHAR_EXPLICIT 170 #ifndef UNISTR_FROM_STRING_EXPLICIT 171 # if defined(U_COMBINED_IMPLEMENTATION) || defined(U_COMMON_IMPLEMENTATION) || defined(U_I18N_IMPLEMENTATION) || defined(U_IO_IMPLEMENTATION) 173 # define UNISTR_FROM_STRING_EXPLICIT explicit 176 # define UNISTR_FROM_STRING_EXPLICIT 213 #ifndef UNISTR_OBJECT_SIZE 214 # define UNISTR_OBJECT_SIZE 64 404 inline int8_t compare(int32_t start,
425 inline int8_t compare(int32_t start,
429 int32_t srcLength)
const;
444 int32_t srcLength)
const;
460 inline int8_t compare(int32_t start,
462 const char16_t *srcChars)
const;
481 inline int8_t compare(int32_t start,
483 const char16_t *srcChars,
485 int32_t srcLength)
const;
504 inline int8_t compareBetween(int32_t start,
508 int32_t srcLimit)
const;
527 inline int8_t compareCodePointOrder(
const UnicodeString& text)
const;
548 inline int8_t compareCodePointOrder(int32_t start,
573 inline int8_t compareCodePointOrder(int32_t start,
577 int32_t srcLength)
const;
598 int32_t srcLength)
const;
619 inline int8_t compareCodePointOrder(int32_t start,
621 const char16_t *srcChars)
const;
644 inline int8_t compareCodePointOrder(int32_t start,
646 const char16_t *srcChars,
648 int32_t srcLength)
const;
671 inline int8_t compareCodePointOrderBetween(int32_t start,
675 int32_t srcLimit)
const;
695 inline int8_t caseCompare(
const UnicodeString& text, uint32_t options)
const;
717 inline int8_t caseCompare(int32_t start,
720 uint32_t options)
const;
744 inline int8_t caseCompare(int32_t start,
749 uint32_t options)
const;
772 uint32_t options)
const;
794 inline int8_t caseCompare(int32_t start,
796 const char16_t *srcChars,
797 uint32_t options)
const;
821 inline int8_t caseCompare(int32_t start,
823 const char16_t *srcChars,
826 uint32_t options)
const;
850 inline int8_t caseCompareBetween(int32_t start,
855 uint32_t options)
const;
878 int32_t srcLength)
const;
889 int32_t srcLength)
const;
900 inline UBool startsWith(
const char16_t *srcChars,
902 int32_t srcLength)
const;
925 int32_t srcLength)
const;
936 int32_t srcLength)
const;
948 inline UBool endsWith(
const char16_t *srcChars,
950 int32_t srcLength)
const;
975 int32_t start)
const;
990 int32_t length)
const;
1012 int32_t length)
const;
1025 inline int32_t indexOf(
const char16_t *srcChars,
1027 int32_t start)
const;
1044 int32_t length)
const;
1062 int32_t indexOf(
const char16_t *srcChars,
1066 int32_t length)
const;
1075 inline int32_t indexOf(char16_t c)
const;
1085 inline int32_t indexOf(
UChar32 c)
const;
1095 inline int32_t indexOf(char16_t c,
1096 int32_t start)
const;
1107 inline int32_t indexOf(
UChar32 c,
1108 int32_t start)
const;
1120 inline int32_t indexOf(char16_t c,
1122 int32_t length)
const;
1135 inline int32_t indexOf(
UChar32 c,
1137 int32_t length)
const;
1147 inline int32_t lastIndexOf(
const UnicodeString& text)
const;
1159 int32_t start)
const;
1174 int32_t length)
const;
1196 int32_t length)
const;
1208 inline int32_t lastIndexOf(
const char16_t *srcChars,
1210 int32_t start)
const;
1227 int32_t length)
const;
1245 int32_t lastIndexOf(
const char16_t *srcChars,
1249 int32_t length)
const;
1258 inline int32_t lastIndexOf(char16_t c)
const;
1268 inline int32_t lastIndexOf(
UChar32 c)
const;
1278 inline int32_t lastIndexOf(char16_t c,
1279 int32_t start)
const;
1290 inline int32_t lastIndexOf(
UChar32 c,
1291 int32_t start)
const;
1303 inline int32_t lastIndexOf(char16_t c,
1305 int32_t length)
const;
1318 inline int32_t lastIndexOf(
UChar32 c,
1320 int32_t length)
const;
1333 inline char16_t
charAt(int32_t offset)
const;
1342 inline char16_t operator[] (int32_t offset)
const;
1372 int32_t getChar32Start(int32_t offset)
const;
1390 int32_t getChar32Limit(int32_t offset)
const;
1442 int32_t moveIndex32(int32_t index, int32_t delta)
const;
1461 inline void extract(int32_t start,
1464 int32_t dstStart = 0)
const;
1488 extract(
Char16Ptr dest, int32_t destCapacity,
1501 inline void extract(int32_t start,
1519 int32_t dstStart = 0)
const;
1555 int32_t extract(int32_t start,
1556 int32_t startLength,
1558 int32_t targetCapacity,
1561 #if U_CHARSET_IS_UTF8 || !UCONFIG_NO_CONVERSION 1582 int32_t extract(int32_t start,
1583 int32_t startLength,
1585 uint32_t targetLength)
const;
1589 #if !UCONFIG_NO_CONVERSION 1616 inline int32_t extract(int32_t start,
1617 int32_t startLength,
1619 const char *codepage = 0)
const;
1650 int32_t extract(int32_t start,
1651 int32_t startLength,
1653 uint32_t targetLength,
1654 const char *codepage)
const;
1673 int32_t extract(
char *dest, int32_t destCapacity,
1731 template<
typename StringClass>
1765 inline int32_t
length(
void)
const;
1781 countChar32(int32_t start=0, int32_t length=
INT32_MAX)
const;
1807 hasMoreChar32Than(int32_t start, int32_t length, int32_t number)
const;
1814 inline UBool isEmpty(
void)
const;
1825 inline int32_t getCapacity(
void)
const;
1834 inline int32_t hashCode(
void)
const;
1848 inline UBool isBogus(
void)
const;
1904 #if U_HAVE_RVALUE_REFERENCES 1914 return moveFrom(src);
2063 int32_t textLength);
2086 int32_t buffCapacity);
2288 const char16_t *srcChars,
2388 const char16_t *srcChars,
2506 virtual void copy(int32_t start, int32_t limit, int32_t dest);
2592 inline UnicodeString& removeBetween(int32_t start,
2604 inline UnicodeString &retainBetween(int32_t start, int32_t limit = INT32_MAX);
2619 UBool padLeading(int32_t targetLength,
2620 char16_t padChar = 0x0020);
2633 UBool padTrailing(int32_t targetLength,
2634 char16_t padChar = 0x0020);
2642 inline UBool truncate(int32_t targetLength);
2649 UnicodeString& trim(
void);
2659 inline UnicodeString& reverse(
void);
2669 inline UnicodeString& reverse(int32_t start,
2678 UnicodeString& toUpper(
void);
2687 UnicodeString& toUpper(
const Locale& locale);
2695 UnicodeString& toLower(
void);
2704 UnicodeString& toLower(
const Locale& locale);
2706 #if !UCONFIG_NO_BREAK_ITERATION 2813 UnicodeString &foldCase(uint32_t options=0 );
2862 char16_t *getBuffer(int32_t minCapacity);
2884 void releaseBuffer(int32_t newLength=-1);
2916 inline const char16_t *getBuffer()
const;
2951 const char16_t *getTerminatedBuffer();
2960 inline UnicodeString();
2973 UnicodeString(int32_t capacity,
UChar32 c, int32_t count);
3013 #if !U_CHAR16_IS_TYPEDEF 3032 #if U_SIZEOF_WCHAR_T==2 || defined(U_IN_DOXYGEN) 3071 UnicodeString(
const char16_t *text,
3072 int32_t textLength);
3078 #if !U_CHAR16_IS_TYPEDEF 3094 #if U_SIZEOF_WCHAR_T==2 || defined(U_IN_DOXYGEN) 3118 inline UnicodeString(
const std::nullptr_t text, int32_t length);
3142 UnicodeString(
UBool isTerminated,
3144 int32_t textLength);
3164 UnicodeString(char16_t *buffer, int32_t buffLength, int32_t buffCapacity);
3170 #if !U_CHAR16_IS_TYPEDEF 3180 UnicodeString(
Char16Ptr(buffer), buffLength, buffCapacity) {}
3187 #if U_SIZEOF_WCHAR_T==2 || defined(U_IN_DOXYGEN) 3198 UnicodeString(
Char16Ptr(buffer), buffLength, buffCapacity) {}
3213 inline UnicodeString(std::nullptr_t buffer, int32_t buffLength, int32_t buffCapacity);
3215 #if U_CHARSET_IS_UTF8 || !UCONFIG_NO_CONVERSION 3246 UnicodeString(
const char *codepageData, int32_t dataLength);
3250 #if !UCONFIG_NO_CONVERSION 3269 UnicodeString(
const char *codepageData,
const char *codepage);
3288 UnicodeString(
const char *codepageData, int32_t dataLength,
const char *codepage);
3312 const char *src, int32_t srcLength,
3342 UnicodeString(
const char *src, int32_t length,
enum EInvariant inv);
3361 UnicodeString(
const UnicodeString& that);
3363 #if U_HAVE_RVALUE_REFERENCES 3370 UnicodeString(UnicodeString &&src)
U_NOEXCEPT;
3379 UnicodeString(
const UnicodeString& src, int32_t srcStart);
3388 UnicodeString(
const UnicodeString& src, int32_t srcStart, int32_t srcLength);
3411 virtual ~UnicodeString();
3439 static UnicodeString fromUTF32(
const UChar32 *utf32, int32_t length);
3477 UnicodeString unescape()
const;
3498 UChar32 unescapeAt(int32_t &offset)
const;
3505 static UClassID U_EXPORT2 getStaticClassID();
3530 virtual char16_t
getCharAt(int32_t offset)
const;
3548 toUTF8(int32_t start, int32_t len,
3549 char *target, int32_t capacity)
const;
3555 UBool doEquals(
const UnicodeString &text, int32_t len)
const;
3558 doCompare(int32_t start,
3560 const UnicodeString& srcText,
3562 int32_t srcLength)
const;
3564 int8_t doCompare(int32_t start,
3566 const char16_t *srcChars,
3568 int32_t srcLength)
const;
3571 doCompareCodePointOrder(int32_t start,
3573 const UnicodeString& srcText,
3575 int32_t srcLength)
const;
3577 int8_t doCompareCodePointOrder(int32_t start,
3579 const char16_t *srcChars,
3581 int32_t srcLength)
const;
3584 doCaseCompare(int32_t start,
3586 const UnicodeString &srcText,
3589 uint32_t options)
const;
3592 doCaseCompare(int32_t start,
3594 const char16_t *srcChars,
3597 uint32_t options)
const;
3599 int32_t doIndexOf(char16_t c,
3601 int32_t length)
const;
3605 int32_t length)
const;
3607 int32_t doLastIndexOf(char16_t c,
3609 int32_t length)
const;
3611 int32_t doLastIndexOf(
UChar32 c,
3613 int32_t length)
const;
3615 void doExtract(int32_t start,
3618 int32_t dstStart)
const;
3620 inline void doExtract(int32_t start,
3622 UnicodeString& target)
const;
3624 inline char16_t doCharAt(int32_t offset)
const;
3626 UnicodeString& doReplace(int32_t start,
3628 const UnicodeString& srcText,
3632 UnicodeString& doReplace(int32_t start,
3634 const char16_t *srcChars,
3638 UnicodeString& doAppend(
const UnicodeString& src, int32_t srcStart, int32_t srcLength);
3639 UnicodeString& doAppend(
const char16_t *srcChars, int32_t srcStart, int32_t srcLength);
3641 UnicodeString& doReverse(int32_t start,
3645 int32_t doHashCode(
void)
const;
3649 inline char16_t* getArrayStart(
void);
3650 inline const char16_t* getArrayStart(
void)
const;
3652 inline UBool hasShortLength()
const;
3653 inline int32_t getShortLength()
const;
3657 inline UBool isWritable()
const;
3660 inline UBool isBufferWritable()
const;
3663 inline void setZeroLength();
3664 inline void setShortLength(int32_t len);
3665 inline void setLength(int32_t len);
3666 inline void setToEmpty();
3667 inline void setArray(char16_t *array, int32_t len, int32_t capacity);
3674 UBool allocate(int32_t capacity);
3677 void releaseArray(
void);
3683 UnicodeString ©From(
const UnicodeString &src,
UBool fastCopy=
FALSE);
3686 void copyFieldsFrom(UnicodeString &src,
UBool setSrcToBogus)
U_NOEXCEPT;
3689 inline void pinIndex(int32_t& start)
const;
3690 inline void pinIndices(int32_t& start,
3691 int32_t& length)
const;
3693 #if !UCONFIG_NO_CONVERSION 3696 int32_t doExtract(int32_t start, int32_t length,
3697 char *dest, int32_t destCapacity,
3711 void doCodepageCreate(
const char *codepageData,
3713 const char *codepage);
3720 doCodepageCreate(
const char *codepageData,
3738 UBool cloneArrayIfNeeded(int32_t newCapacity = -1,
3739 int32_t growCapacity = -1,
3741 int32_t **pBufferToDelete = 0,
3750 caseMap(int32_t caseLocale, uint32_t options,
3758 int32_t removeRef(
void);
3759 int32_t refCount(
void)
const;
3769 kInvalidUChar=0xffff,
3775 kUsingStackBuffer=2,
3777 kBufferIsReadonly=8,
3780 kAllStorageFlags=0x1f,
3783 kLength1=1<<kLengthShift,
3784 kMaxShortLength=0x3ff,
3785 kLengthIsLarge=0xffe0,
3788 kShortString=kUsingStackBuffer,
3789 kLongString=kRefCounted,
3790 kReadonlyAlias=kBufferIsReadonly,
3796 union StackBufferOrFields;
3797 friend union StackBufferOrFields;
3840 union StackBufferOrFields {
3844 int16_t fLengthAndFlags;
3845 char16_t fBuffer[US_STACKBUF_SIZE];
3848 int16_t fLengthAndFlags;
3878 UnicodeString::pinIndex(int32_t& start)
const 3883 }
else if(start > length()) {
3889 UnicodeString::pinIndices(int32_t& start,
3890 int32_t& _length)
const 3893 int32_t len = length();
3896 }
else if(start > len) {
3901 }
else if(_length > (len - start)) {
3902 _length = (len - start);
3907 UnicodeString::getArrayStart() {
3908 return (fUnion.fFields.fLengthAndFlags&kUsingStackBuffer) ?
3909 fUnion.fStackFields.fBuffer : fUnion.fFields.fArray;
3912 inline const char16_t*
3913 UnicodeString::getArrayStart()
const {
3914 return (fUnion.fFields.fLengthAndFlags&kUsingStackBuffer) ?
3915 fUnion.fStackFields.fBuffer : fUnion.fFields.fArray;
3923 UnicodeString::UnicodeString() {
3924 fUnion.fStackFields.fLengthAndFlags=kShortString;
3927 inline UnicodeString::UnicodeString(
const std::nullptr_t ) {
3928 fUnion.fStackFields.fLengthAndFlags=kShortString;
3931 inline UnicodeString::UnicodeString(
const std::nullptr_t , int32_t ) {
3932 fUnion.fStackFields.fLengthAndFlags=kShortString;
3935 inline UnicodeString::UnicodeString(std::nullptr_t , int32_t , int32_t ) {
3936 fUnion.fStackFields.fLengthAndFlags=kShortString;
3943 UnicodeString::hasShortLength()
const {
3944 return fUnion.fFields.fLengthAndFlags>=0;
3948 UnicodeString::getShortLength()
const {
3951 return fUnion.fFields.fLengthAndFlags>>kLengthShift;
3955 UnicodeString::length()
const {
3956 return hasShortLength() ? getShortLength() : fUnion.fFields.fLength;
3960 UnicodeString::getCapacity()
const {
3961 return (fUnion.fFields.fLengthAndFlags&kUsingStackBuffer) ?
3962 US_STACKBUF_SIZE : fUnion.fFields.fCapacity;
3966 UnicodeString::hashCode()
const 3967 {
return doHashCode(); }
3970 UnicodeString::isBogus()
const 3971 {
return (
UBool)(fUnion.fFields.fLengthAndFlags & kIsBogus); }
3974 UnicodeString::isWritable()
const 3975 {
return (
UBool)!(fUnion.fFields.fLengthAndFlags&(kOpenGetBuffer|kIsBogus)); }
3978 UnicodeString::isBufferWritable()
const 3981 !(fUnion.fFields.fLengthAndFlags&(kOpenGetBuffer|kIsBogus|kBufferIsReadonly)) &&
3982 (!(fUnion.fFields.fLengthAndFlags&kRefCounted) || refCount()==1));
3985 inline const char16_t *
3986 UnicodeString::getBuffer()
const {
3987 if(fUnion.fFields.fLengthAndFlags&(kIsBogus|kOpenGetBuffer)) {
3989 }
else if(fUnion.fFields.fLengthAndFlags&kUsingStackBuffer) {
3990 return fUnion.fStackFields.fBuffer;
3992 return fUnion.fFields.fArray;
4000 UnicodeString::doCompare(int32_t start,
4004 int32_t srcLength)
const 4007 return (int8_t)!isBogus();
4009 srcText.pinIndices(srcStart, srcLength);
4010 return doCompare(start, thisLength, srcText.getArrayStart(), srcStart, srcLength);
4020 int32_t len = length(), textLength = text.
length();
4021 return !text.
isBogus() && len == textLength && doEquals(text, len);
4027 {
return (!
operator==(text)); }
4031 {
return doCompare(0, length(), text, 0, text.
length()) == 1; }
4035 {
return doCompare(0, length(), text, 0, text.
length()) == -1; }
4039 {
return doCompare(0, length(), text, 0, text.
length()) != -1; }
4043 {
return doCompare(0, length(), text, 0, text.
length()) != 1; }
4047 {
return doCompare(0, length(), text, 0, text.
length()); }
4050 UnicodeString::compare(int32_t start,
4053 {
return doCompare(start, _length, srcText, 0, srcText.
length()); }
4057 int32_t srcLength)
const 4058 {
return doCompare(0, length(), srcChars, 0, srcLength); }
4061 UnicodeString::compare(int32_t start,
4065 int32_t srcLength)
const 4066 {
return doCompare(start, _length, srcText, srcStart, srcLength); }
4069 UnicodeString::compare(int32_t start,
4071 const char16_t *srcChars)
const 4072 {
return doCompare(start, _length, srcChars, 0, _length); }
4075 UnicodeString::compare(int32_t start,
4077 const char16_t *srcChars,
4079 int32_t srcLength)
const 4080 {
return doCompare(start, _length, srcChars, srcStart, srcLength); }
4083 UnicodeString::compareBetween(int32_t start,
4087 int32_t srcLimit)
const 4088 {
return doCompare(start, limit - start,
4089 srcText, srcStart, srcLimit - srcStart); }
4092 UnicodeString::doCompareCodePointOrder(int32_t start,
4096 int32_t srcLength)
const 4099 return (int8_t)!isBogus();
4101 srcText.pinIndices(srcStart, srcLength);
4102 return doCompareCodePointOrder(start, thisLength, srcText.getArrayStart(), srcStart, srcLength);
4108 {
return doCompareCodePointOrder(0, length(), text, 0, text.
length()); }
4111 UnicodeString::compareCodePointOrder(int32_t start,
4114 {
return doCompareCodePointOrder(start, _length, srcText, 0, srcText.
length()); }
4118 int32_t srcLength)
const 4119 {
return doCompareCodePointOrder(0, length(), srcChars, 0, srcLength); }
4122 UnicodeString::compareCodePointOrder(int32_t start,
4126 int32_t srcLength)
const 4127 {
return doCompareCodePointOrder(start, _length, srcText, srcStart, srcLength); }
4130 UnicodeString::compareCodePointOrder(int32_t start,
4132 const char16_t *srcChars)
const 4133 {
return doCompareCodePointOrder(start, _length, srcChars, 0, _length); }
4136 UnicodeString::compareCodePointOrder(int32_t start,
4138 const char16_t *srcChars,
4140 int32_t srcLength)
const 4141 {
return doCompareCodePointOrder(start, _length, srcChars, srcStart, srcLength); }
4144 UnicodeString::compareCodePointOrderBetween(int32_t start,
4148 int32_t srcLimit)
const 4149 {
return doCompareCodePointOrder(start, limit - start,
4150 srcText, srcStart, srcLimit - srcStart); }
4153 UnicodeString::doCaseCompare(int32_t start,
4158 uint32_t options)
const 4161 return (int8_t)!isBogus();
4163 srcText.pinIndices(srcStart, srcLength);
4164 return doCaseCompare(start, thisLength, srcText.getArrayStart(), srcStart, srcLength, options);
4170 return doCaseCompare(0, length(), text, 0, text.
length(), options);
4174 UnicodeString::caseCompare(int32_t start,
4177 uint32_t options)
const {
4178 return doCaseCompare(start, _length, srcText, 0, srcText.
length(), options);
4184 uint32_t options)
const {
4185 return doCaseCompare(0, length(), srcChars, 0, srcLength, options);
4189 UnicodeString::caseCompare(int32_t start,
4194 uint32_t options)
const {
4195 return doCaseCompare(start, _length, srcText, srcStart, srcLength, options);
4199 UnicodeString::caseCompare(int32_t start,
4201 const char16_t *srcChars,
4202 uint32_t options)
const {
4203 return doCaseCompare(start, _length, srcChars, 0, _length, options);
4207 UnicodeString::caseCompare(int32_t start,
4209 const char16_t *srcChars,
4212 uint32_t options)
const {
4213 return doCaseCompare(start, _length, srcChars, srcStart, srcLength, options);
4217 UnicodeString::caseCompareBetween(int32_t start,
4222 uint32_t options)
const {
4223 return doCaseCompare(start, limit - start, srcText, srcStart, srcLimit - srcStart, options);
4231 int32_t _length)
const 4234 srcText.pinIndices(srcStart, srcLength);
4236 return indexOf(srcText.getArrayStart(), srcStart, srcLength, start, _length);
4244 {
return indexOf(text, 0, text.
length(), 0, length()); }
4248 int32_t start)
const {
4250 return indexOf(text, 0, text.
length(), start, length() - start);
4256 int32_t _length)
const 4257 {
return indexOf(text, 0, text.
length(), start, _length); }
4260 UnicodeString::indexOf(
const char16_t *srcChars,
4262 int32_t start)
const {
4264 return indexOf(srcChars, 0, srcLength, start, length() - start);
4271 int32_t _length)
const 4272 {
return indexOf(srcChars, 0, srcLength, start, _length); }
4275 UnicodeString::indexOf(char16_t c,
4277 int32_t _length)
const 4278 {
return doIndexOf(c, start, _length); }
4283 int32_t _length)
const 4284 {
return doIndexOf(c, start, _length); }
4287 UnicodeString::indexOf(char16_t c)
const 4288 {
return doIndexOf(c, 0, length()); }
4292 {
return indexOf(c, 0, length()); }
4295 UnicodeString::indexOf(char16_t c,
4296 int32_t start)
const {
4298 return doIndexOf(c, start, length() - start);
4303 int32_t start)
const {
4305 return indexOf(c, start, length() - start);
4312 int32_t _length)
const 4313 {
return lastIndexOf(srcChars, 0, srcLength, start, _length); }
4316 UnicodeString::lastIndexOf(
const char16_t *srcChars,
4318 int32_t start)
const {
4320 return lastIndexOf(srcChars, 0, srcLength, start, length() - start);
4328 int32_t _length)
const 4331 srcText.pinIndices(srcStart, srcLength);
4333 return lastIndexOf(srcText.getArrayStart(), srcStart, srcLength, start, _length);
4342 int32_t _length)
const 4343 {
return lastIndexOf(text, 0, text.
length(), start, _length); }
4347 int32_t start)
const {
4349 return lastIndexOf(text, 0, text.
length(), start, length() - start);
4354 {
return lastIndexOf(text, 0, text.
length(), 0, length()); }
4357 UnicodeString::lastIndexOf(char16_t c,
4359 int32_t _length)
const 4360 {
return doLastIndexOf(c, start, _length); }
4365 int32_t _length)
const {
4366 return doLastIndexOf(c, start, _length);
4370 UnicodeString::lastIndexOf(char16_t c)
const 4371 {
return doLastIndexOf(c, 0, length()); }
4375 return lastIndexOf(c, 0, length());
4379 UnicodeString::lastIndexOf(char16_t c,
4380 int32_t start)
const {
4382 return doLastIndexOf(c, start, length() - start);
4387 int32_t start)
const {
4389 return lastIndexOf(c, start, length() - start);
4394 {
return compare(0, text.
length(), text, 0, text.
length()) == 0; }
4399 int32_t srcLength)
const 4400 {
return doCompare(0, srcLength, srcText, srcStart, srcLength) == 0; }
4407 return doCompare(0, srcLength, srcChars, 0, srcLength) == 0;
4411 UnicodeString::startsWith(
const char16_t *srcChars, int32_t srcStart, int32_t srcLength)
const {
4415 return doCompare(0, srcLength, srcChars, srcStart, srcLength) == 0;
4420 {
return doCompare(length() - text.
length(), text.
length(),
4421 text, 0, text.
length()) == 0; }
4426 int32_t srcLength)
const {
4427 srcText.pinIndices(srcStart, srcLength);
4428 return doCompare(length() - srcLength, srcLength,
4429 srcText, srcStart, srcLength) == 0;
4434 int32_t srcLength)
const {
4438 return doCompare(length() - srcLength, srcLength,
4439 srcChars, 0, srcLength) == 0;
4443 UnicodeString::endsWith(
const char16_t *srcChars,
4445 int32_t srcLength)
const {
4449 return doCompare(length() - srcLength, srcLength,
4450 srcChars, srcStart, srcLength) == 0;
4457 UnicodeString::replace(int32_t start,
4460 {
return doReplace(start, _length, srcText, 0, srcText.
length()); }
4463 UnicodeString::replace(int32_t start,
4468 {
return doReplace(start, _length, srcText, srcStart, srcLength); }
4471 UnicodeString::replace(int32_t start,
4475 {
return doReplace(start, _length, srcChars, 0, srcLength); }
4478 UnicodeString::replace(int32_t start,
4480 const char16_t *srcChars,
4483 {
return doReplace(start, _length, srcChars, srcStart, srcLength); }
4486 UnicodeString::replace(int32_t start,
4489 {
return doReplace(start, _length, &srcChar, 0, 1); }
4492 UnicodeString::replaceBetween(int32_t start,
4495 {
return doReplace(start, limit - start, srcText, 0, srcText.
length()); }
4498 UnicodeString::replaceBetween(int32_t start,
4503 {
return doReplace(start, limit - start, srcText, srcStart, srcLimit - srcStart); }
4508 {
return findAndReplace(0, length(), oldText, 0, oldText.
length(),
4509 newText, 0, newText.
length()); }
4512 UnicodeString::findAndReplace(int32_t start,
4516 {
return findAndReplace(start, _length, oldText, 0, oldText.
length(),
4517 newText, 0, newText.
length()); }
4523 UnicodeString::doExtract(int32_t start,
4526 { target.
replace(0, target.
length(), *
this, start, _length); }
4529 UnicodeString::extract(int32_t start,
4532 int32_t targetStart)
const 4533 { doExtract(start, _length, target, targetStart); }
4536 UnicodeString::extract(int32_t start,
4539 { doExtract(start, _length, target); }
4541 #if !UCONFIG_NO_CONVERSION 4544 UnicodeString::extract(int32_t start,
4547 const char *codepage)
const 4551 return extract(start, _length, dst, dst!=0 ? 0xffffffff : 0, codepage);
4557 UnicodeString::extractBetween(int32_t start,
4560 int32_t dstStart)
const {
4563 doExtract(start, limit - start, dst, dstStart);
4567 UnicodeString::tempSubStringBetween(int32_t start, int32_t limit)
const {
4568 return tempSubString(start, limit - start);
4572 UnicodeString::doCharAt(int32_t offset)
const 4574 if((uint32_t)offset < (uint32_t)length()) {
4575 return getArrayStart()[offset];
4577 return kInvalidUChar;
4582 UnicodeString::charAt(int32_t offset)
const 4583 {
return doCharAt(offset); }
4586 UnicodeString::operator[] (int32_t offset)
const 4587 {
return doCharAt(offset); }
4590 UnicodeString::isEmpty()
const {
4592 return (fUnion.fFields.fLengthAndFlags>>kLengthShift) == 0;
4599 UnicodeString::setZeroLength() {
4600 fUnion.fFields.fLengthAndFlags &= kAllStorageFlags;
4604 UnicodeString::setShortLength(int32_t len) {
4606 fUnion.fFields.fLengthAndFlags =
4607 (int16_t)((fUnion.fFields.fLengthAndFlags & kAllStorageFlags) | (len << kLengthShift));
4611 UnicodeString::setLength(int32_t len) {
4612 if(len <= kMaxShortLength) {
4613 setShortLength(len);
4615 fUnion.fFields.fLengthAndFlags |= kLengthIsLarge;
4616 fUnion.fFields.fLength = len;
4621 UnicodeString::setToEmpty() {
4622 fUnion.fFields.fLengthAndFlags = kShortString;
4626 UnicodeString::setArray(char16_t *array, int32_t len, int32_t capacity) {
4628 fUnion.fFields.fArray = array;
4629 fUnion.fFields.fCapacity = capacity;
4633 UnicodeString::operator= (char16_t ch)
4634 {
return doReplace(0, length(), &ch, 0, 1); }
4638 {
return replace(0, length(), ch); }
4646 return doReplace(0, length(), srcText, srcStart, srcLength);
4654 srcText.pinIndex(srcStart);
4655 return doReplace(0, length(), srcText, srcStart, srcText.
length() - srcStart);
4661 return copyFrom(srcText);
4665 UnicodeString::setTo(
const char16_t *srcChars,
4669 return doReplace(0, length(), srcChars, 0, srcLength);
4673 UnicodeString::setTo(char16_t srcChar)
4676 return doReplace(0, length(), &srcChar, 0, 1);
4683 return replace(0, length(), srcChar);
4690 {
return doAppend(srcText, srcStart, srcLength); }
4694 {
return doAppend(srcText, 0, srcText.
length()); }
4697 UnicodeString::append(
const char16_t *srcChars,
4700 {
return doAppend(srcChars, srcStart, srcLength); }
4705 {
return doAppend(srcChars, 0, srcLength); }
4708 UnicodeString::append(char16_t srcChar)
4709 {
return doAppend(&srcChar, 0, 1); }
4712 UnicodeString::operator+= (char16_t ch)
4713 {
return doAppend(&ch, 0, 1); }
4722 {
return doAppend(srcText, 0, srcText.
length()); }
4725 UnicodeString::insert(int32_t start,
4729 {
return doReplace(start, 0, srcText, srcStart, srcLength); }
4732 UnicodeString::insert(int32_t start,
4734 {
return doReplace(start, 0, srcText, 0, srcText.
length()); }
4737 UnicodeString::insert(int32_t start,
4738 const char16_t *srcChars,
4741 {
return doReplace(start, 0, srcChars, srcStart, srcLength); }
4744 UnicodeString::insert(int32_t start,
4747 {
return doReplace(start, 0, srcChars, 0, srcLength); }
4750 UnicodeString::insert(int32_t start,
4752 {
return doReplace(start, 0, &srcChar, 0, 1); }
4755 UnicodeString::insert(int32_t start,
4757 {
return replace(start, 0, srcChar); }
4761 UnicodeString::remove()
4773 UnicodeString::remove(int32_t start,
4776 if(start <= 0 && _length ==
INT32_MAX) {
4780 return doReplace(start, _length,
NULL, 0, 0);
4784 UnicodeString::removeBetween(int32_t start,
4786 {
return doReplace(start, limit - start,
NULL, 0, 0); }
4789 UnicodeString::retainBetween(int32_t start, int32_t limit) {
4791 return doReplace(0, start,
NULL, 0, 0);
4795 UnicodeString::truncate(int32_t targetLength)
4797 if(isBogus() && targetLength == 0) {
4801 }
else if((uint32_t)targetLength < (uint32_t)length()) {
4802 setLength(targetLength);
4810 UnicodeString::reverse()
4811 {
return doReverse(0, length()); }
4814 UnicodeString::reverse(int32_t start,
4816 {
return doReverse(start, _length); }
#define UNISTR_OBJECT_SIZE
Desired sizeof(UnicodeString) in bytes.
An Appendable implementation which writes to a UnicodeString.
EInvariant
Constant to be used in the UnicodeString(char *, int32_t, EInvariant) constructor which constructs a ...
UnicodeString & operator=(UnicodeString &&src) U_NOEXCEPT
Move assignment operator, might leave src in bogus state.
UnicodeString(wchar_t *buffer, int32_t buffLength, int32_t buffCapacity)
Writable-aliasing wchar_t * constructor.
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.
UNISTR_FROM_STRING_EXPLICIT UnicodeString(const uint16_t *text)
uint16_t * constructor.
UNISTR_FROM_STRING_EXPLICIT UnicodeString(const wchar_t *text)
wchar_t * constructor.
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
UnicodeString(const wchar_t *text, int32_t length)
wchar_t * constructor.
#define U_SIZEOF_UCHAR
Number of bytes in a UChar.
UnicodeString(const uint16_t *text, int32_t length)
uint16_t * constructor.
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().
int32_t UStringCaseMapper(int32_t caseLocale, uint32_t options, icu::BreakIterator *iter, char16_t *dest, int32_t destCapacity, const char16_t *src, int32_t srcLength, icu::Edits *edits, UErrorCode &errorCode)
Internal string case mapping function type.
#define UCONFIG_NO_BREAK_ITERATION
This switch turns off break iteration.
UBool isBogus(void) const
Determine if this object contains a valid string.
Records lengths of string edits but not replacement text.
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 nullptr 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...
const UChar * toUCharPtr(const char16_t *p)
Converts from const char16_t * to const UChar *.
virtual char16_t getCharAt(int32_t offset) const =0
Virtual version of charAt().
#define TRUE
The TRUE value of a UBool.
uint16_t UChar
The base type for UTF-16 code units and pointers.
UnicodeString(uint16_t *buffer, int32_t buffLength, int32_t buffCapacity)
Writable-aliasing uint16_t * constructor.
#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...
char16_t charAt(int32_t offset) const
Returns the 16-bit code unit at the given offset into the text.
int32_t length(void) const
Return the length of the UnicodeString object.
char16_t * wrapper with implicit conversion from distinct but bit-compatible pointer types...
const char16_t * wrapper with implicit conversion from distinct but bit-compatible pointer types...
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.
C++ API: char16_t pointer wrappers with implicit conversion from bit-compatible raw pointer types...
A Locale object represents a specific geographical, political, or cultural region.
C++ API: Replaceable String.