51 #if !UCONFIG_NO_BREAK_ITERATION 70 char16_t *dest, int32_t destCapacity,
71 const char16_t *src, int32_t srcLength,
78 class StringCharacterIterator;
79 class UnicodeStringAppendable;
93 #define US_INV icu::UnicodeString::kInvariant 112 #if !U_CHAR16_IS_TYPEDEF 113 # define UNICODE_STRING(cs, _length) icu::UnicodeString(TRUE, u ## cs, _length) 115 # define UNICODE_STRING(cs, _length) icu::UnicodeString(TRUE, (const char16_t*)u ## cs, _length) 131 #define UNICODE_STRING_SIMPLE(cs) UNICODE_STRING(cs, -1) 140 #ifndef UNISTR_FROM_CHAR_EXPLICIT 141 # if defined(U_COMBINED_IMPLEMENTATION) || defined(U_COMMON_IMPLEMENTATION) || defined(U_I18N_IMPLEMENTATION) || defined(U_IO_IMPLEMENTATION) 143 # define UNISTR_FROM_CHAR_EXPLICIT explicit 146 # define UNISTR_FROM_CHAR_EXPLICIT 160 #ifndef UNISTR_FROM_STRING_EXPLICIT 161 # if defined(U_COMBINED_IMPLEMENTATION) || defined(U_COMMON_IMPLEMENTATION) || defined(U_I18N_IMPLEMENTATION) || defined(U_IO_IMPLEMENTATION) 163 # define UNISTR_FROM_STRING_EXPLICIT explicit 166 # define UNISTR_FROM_STRING_EXPLICIT 203 #ifndef UNISTR_OBJECT_SIZE 204 # define UNISTR_OBJECT_SIZE 64 394 inline int8_t compare(int32_t start,
415 inline int8_t compare(int32_t start,
419 int32_t srcLength)
const;
434 int32_t srcLength)
const;
450 inline int8_t compare(int32_t start,
452 const char16_t *srcChars)
const;
471 inline int8_t compare(int32_t start,
473 const char16_t *srcChars,
475 int32_t srcLength)
const;
494 inline int8_t compareBetween(int32_t start,
498 int32_t srcLimit)
const;
517 inline int8_t compareCodePointOrder(
const UnicodeString& text)
const;
538 inline int8_t compareCodePointOrder(int32_t start,
563 inline int8_t compareCodePointOrder(int32_t start,
567 int32_t srcLength)
const;
588 int32_t srcLength)
const;
609 inline int8_t compareCodePointOrder(int32_t start,
611 const char16_t *srcChars)
const;
634 inline int8_t compareCodePointOrder(int32_t start,
636 const char16_t *srcChars,
638 int32_t srcLength)
const;
661 inline int8_t compareCodePointOrderBetween(int32_t start,
665 int32_t srcLimit)
const;
685 inline int8_t caseCompare(
const UnicodeString& text, uint32_t options)
const;
707 inline int8_t caseCompare(int32_t start,
710 uint32_t options)
const;
734 inline int8_t caseCompare(int32_t start,
739 uint32_t options)
const;
762 uint32_t options)
const;
784 inline int8_t caseCompare(int32_t start,
786 const char16_t *srcChars,
787 uint32_t options)
const;
811 inline int8_t caseCompare(int32_t start,
813 const char16_t *srcChars,
816 uint32_t options)
const;
840 inline int8_t caseCompareBetween(int32_t start,
845 uint32_t options)
const;
868 int32_t srcLength)
const;
879 int32_t srcLength)
const;
890 inline UBool startsWith(
const char16_t *srcChars,
892 int32_t srcLength)
const;
915 int32_t srcLength)
const;
926 int32_t srcLength)
const;
938 inline UBool endsWith(
const char16_t *srcChars,
940 int32_t srcLength)
const;
965 int32_t start)
const;
980 int32_t length)
const;
1002 int32_t length)
const;
1015 inline int32_t indexOf(
const char16_t *srcChars,
1017 int32_t start)
const;
1034 int32_t length)
const;
1052 int32_t indexOf(
const char16_t *srcChars,
1056 int32_t length)
const;
1065 inline int32_t indexOf(char16_t c)
const;
1075 inline int32_t indexOf(
UChar32 c)
const;
1085 inline int32_t indexOf(char16_t c,
1086 int32_t start)
const;
1097 inline int32_t indexOf(
UChar32 c,
1098 int32_t start)
const;
1110 inline int32_t indexOf(char16_t c,
1112 int32_t length)
const;
1125 inline int32_t indexOf(
UChar32 c,
1127 int32_t length)
const;
1137 inline int32_t lastIndexOf(
const UnicodeString& text)
const;
1149 int32_t start)
const;
1164 int32_t length)
const;
1186 int32_t length)
const;
1198 inline int32_t lastIndexOf(
const char16_t *srcChars,
1200 int32_t start)
const;
1217 int32_t length)
const;
1235 int32_t lastIndexOf(
const char16_t *srcChars,
1239 int32_t length)
const;
1248 inline int32_t lastIndexOf(char16_t c)
const;
1258 inline int32_t lastIndexOf(
UChar32 c)
const;
1268 inline int32_t lastIndexOf(char16_t c,
1269 int32_t start)
const;
1280 inline int32_t lastIndexOf(
UChar32 c,
1281 int32_t start)
const;
1293 inline int32_t lastIndexOf(char16_t c,
1295 int32_t length)
const;
1308 inline int32_t lastIndexOf(
UChar32 c,
1310 int32_t length)
const;
1323 inline char16_t
charAt(int32_t offset)
const;
1332 inline char16_t operator[] (int32_t offset)
const;
1362 int32_t getChar32Start(int32_t offset)
const;
1380 int32_t getChar32Limit(int32_t offset)
const;
1432 int32_t moveIndex32(int32_t index, int32_t delta)
const;
1451 inline void extract(int32_t start,
1454 int32_t dstStart = 0)
const;
1478 extract(
Char16Ptr dest, int32_t destCapacity,
1491 inline void extract(int32_t start,
1509 int32_t dstStart = 0)
const;
1545 int32_t extract(int32_t start,
1546 int32_t startLength,
1548 int32_t targetCapacity,
1549 enum EInvariant inv)
const;
1551 #if U_CHARSET_IS_UTF8 || !UCONFIG_NO_CONVERSION 1572 int32_t extract(int32_t start,
1573 int32_t startLength,
1575 uint32_t targetLength)
const;
1579 #if !UCONFIG_NO_CONVERSION 1606 inline int32_t extract(int32_t start,
1607 int32_t startLength,
1609 const char *codepage = 0)
const;
1640 int32_t extract(int32_t start,
1641 int32_t startLength,
1643 uint32_t targetLength,
1644 const char *codepage)
const;
1663 int32_t extract(
char *dest, int32_t destCapacity,
1721 template<
typename StringClass>
1755 inline int32_t
length(
void)
const;
1771 countChar32(int32_t start=0, int32_t length=
INT32_MAX)
const;
1797 hasMoreChar32Than(int32_t start, int32_t length, int32_t number)
const;
1804 inline UBool isEmpty(
void)
const;
1815 inline int32_t getCapacity(
void)
const;
1824 inline int32_t hashCode(
void)
const;
1838 inline UBool isBogus(
void)
const;
1903 return moveFrom(src);
2052 int32_t textLength);
2075 int32_t buffCapacity);
2277 const char16_t *srcChars,
2377 const char16_t *srcChars,
2495 virtual void copy(int32_t start, int32_t limit, int32_t dest);
2608 UBool padLeading(int32_t targetLength,
2609 char16_t padChar = 0x0020);
2622 UBool padTrailing(int32_t targetLength,
2623 char16_t padChar = 0x0020);
2631 inline UBool truncate(int32_t targetLength);
2695 #if !UCONFIG_NO_BREAK_ITERATION 2851 char16_t *getBuffer(int32_t minCapacity);
2873 void releaseBuffer(int32_t newLength=-1);
2905 inline const char16_t *getBuffer()
const;
2940 const char16_t *getTerminatedBuffer();
2998 #if !U_CHAR16_IS_TYPEDEF 3013 #if U_SIZEOF_WCHAR_T==2 || defined(U_IN_DOXYGEN) 3049 int32_t textLength);
3051 #if !U_CHAR16_IS_TYPEDEF 3063 #if U_SIZEOF_WCHAR_T==2 || defined(U_IN_DOXYGEN) 3083 inline UnicodeString(
const std::nullptr_t text, int32_t length);
3109 int32_t textLength);
3129 UnicodeString(char16_t *buffer, int32_t buffLength, int32_t buffCapacity);
3131 #if !U_CHAR16_IS_TYPEDEF 3144 #if U_SIZEOF_WCHAR_T==2 || defined(U_IN_DOXYGEN) 3166 inline UnicodeString(std::nullptr_t buffer, int32_t buffLength, int32_t buffCapacity);
3168 #if U_CHARSET_IS_UTF8 || !UCONFIG_NO_CONVERSION 3199 UnicodeString(
const char *codepageData, int32_t dataLength);
3203 #if !UCONFIG_NO_CONVERSION 3222 UnicodeString(
const char *codepageData,
const char *codepage);
3241 UnicodeString(
const char *codepageData, int32_t dataLength,
const char *codepage);
3265 const char *src, int32_t srcLength,
3295 UnicodeString(
const char *src, int32_t length,
enum EInvariant inv);
3449 UChar32 unescapeAt(int32_t &offset)
const;
3456 static UClassID U_EXPORT2 getStaticClassID();
3481 virtual char16_t
getCharAt(int32_t offset)
const;
3499 toUTF8(int32_t start, int32_t len,
3500 char *target, int32_t capacity)
const;
3509 doCompare(int32_t start,
3513 int32_t srcLength)
const;
3515 int8_t doCompare(int32_t start,
3517 const char16_t *srcChars,
3519 int32_t srcLength)
const;
3522 doCompareCodePointOrder(int32_t start,
3526 int32_t srcLength)
const;
3528 int8_t doCompareCodePointOrder(int32_t start,
3530 const char16_t *srcChars,
3532 int32_t srcLength)
const;
3535 doCaseCompare(int32_t start,
3540 uint32_t options)
const;
3543 doCaseCompare(int32_t start,
3545 const char16_t *srcChars,
3548 uint32_t options)
const;
3550 int32_t doIndexOf(char16_t c,
3552 int32_t length)
const;
3556 int32_t length)
const;
3558 int32_t doLastIndexOf(char16_t c,
3560 int32_t length)
const;
3562 int32_t doLastIndexOf(
UChar32 c,
3564 int32_t length)
const;
3566 void doExtract(int32_t start,
3569 int32_t dstStart)
const;
3571 inline void doExtract(int32_t start,
3575 inline char16_t doCharAt(int32_t offset)
const;
3585 const char16_t *srcChars,
3590 UnicodeString& doAppend(
const char16_t *srcChars, int32_t srcStart, int32_t srcLength);
3596 int32_t doHashCode(
void)
const;
3600 inline char16_t* getArrayStart(
void);
3601 inline const char16_t* getArrayStart(
void)
const;
3603 inline UBool hasShortLength()
const;
3604 inline int32_t getShortLength()
const;
3608 inline UBool isWritable()
const;
3611 inline UBool isBufferWritable()
const;
3614 inline void setZeroLength();
3615 inline void setShortLength(int32_t len);
3616 inline void setLength(int32_t len);
3617 inline void setToEmpty();
3618 inline void setArray(char16_t *array, int32_t len, int32_t capacity);
3625 UBool allocate(int32_t capacity);
3628 void releaseArray(
void);
3640 inline void pinIndex(int32_t& start)
const;
3641 inline void pinIndices(int32_t& start,
3642 int32_t& length)
const;
3644 #if !UCONFIG_NO_CONVERSION 3647 int32_t doExtract(int32_t start, int32_t length,
3648 char *dest, int32_t destCapacity,
3662 void doCodepageCreate(
const char *codepageData,
3664 const char *codepage);
3671 doCodepageCreate(
const char *codepageData,
3689 UBool cloneArrayIfNeeded(int32_t newCapacity = -1,
3690 int32_t growCapacity = -1,
3692 int32_t **pBufferToDelete = 0,
3701 caseMap(int32_t caseLocale, uint32_t options,
3709 int32_t removeRef(
void);
3710 int32_t refCount(
void)
const;
3720 kInvalidUChar=0xffff,
3726 kUsingStackBuffer=2,
3728 kBufferIsReadonly=8,
3731 kAllStorageFlags=0x1f,
3734 kLength1=1<<kLengthShift,
3735 kMaxShortLength=0x3ff,
3736 kLengthIsLarge=0xffe0,
3739 kShortString=kUsingStackBuffer,
3740 kLongString=kRefCounted,
3741 kReadonlyAlias=kBufferIsReadonly,
3745 friend class UnicodeStringAppendable;
3747 union StackBufferOrFields;
3748 friend union StackBufferOrFields;
3791 union StackBufferOrFields {
3795 int16_t fLengthAndFlags;
3796 char16_t fBuffer[US_STACKBUF_SIZE];
3799 int16_t fLengthAndFlags;
3818 operator+ (
const UnicodeString &s1,
const UnicodeString &s2);
3829 UnicodeString::pinIndex(int32_t& start)
const 3834 }
else if(start > length()) {
3840 UnicodeString::pinIndices(int32_t& start,
3841 int32_t& _length)
const 3844 int32_t len = length();
3847 }
else if(start > len) {
3852 }
else if(_length > (len - start)) {
3853 _length = (len - start);
3858 UnicodeString::getArrayStart() {
3859 return (fUnion.fFields.fLengthAndFlags&kUsingStackBuffer) ?
3860 fUnion.fStackFields.fBuffer : fUnion.fFields.fArray;
3863 inline const char16_t*
3864 UnicodeString::getArrayStart()
const {
3865 return (fUnion.fFields.fLengthAndFlags&kUsingStackBuffer) ?
3866 fUnion.fStackFields.fBuffer : fUnion.fFields.fArray;
3874 UnicodeString::UnicodeString() {
3875 fUnion.fStackFields.fLengthAndFlags=kShortString;
3878 inline UnicodeString::UnicodeString(
const std::nullptr_t ) {
3879 fUnion.fStackFields.fLengthAndFlags=kShortString;
3882 inline UnicodeString::UnicodeString(
const std::nullptr_t , int32_t ) {
3883 fUnion.fStackFields.fLengthAndFlags=kShortString;
3886 inline UnicodeString::UnicodeString(std::nullptr_t , int32_t , int32_t ) {
3887 fUnion.fStackFields.fLengthAndFlags=kShortString;
3894 UnicodeString::hasShortLength()
const {
3895 return fUnion.fFields.fLengthAndFlags>=0;
3899 UnicodeString::getShortLength()
const {
3902 return fUnion.fFields.fLengthAndFlags>>kLengthShift;
3906 UnicodeString::length()
const {
3907 return hasShortLength() ? getShortLength() : fUnion.fFields.fLength;
3911 UnicodeString::getCapacity()
const {
3912 return (fUnion.fFields.fLengthAndFlags&kUsingStackBuffer) ?
3913 US_STACKBUF_SIZE : fUnion.fFields.fCapacity;
3917 UnicodeString::hashCode()
const 3918 {
return doHashCode(); }
3921 UnicodeString::isBogus()
const 3922 {
return (
UBool)(fUnion.fFields.fLengthAndFlags & kIsBogus); }
3925 UnicodeString::isWritable()
const 3926 {
return (
UBool)!(fUnion.fFields.fLengthAndFlags&(kOpenGetBuffer|kIsBogus)); }
3929 UnicodeString::isBufferWritable()
const 3932 !(fUnion.fFields.fLengthAndFlags&(kOpenGetBuffer|kIsBogus|kBufferIsReadonly)) &&
3933 (!(fUnion.fFields.fLengthAndFlags&kRefCounted) || refCount()==1));
3936 inline const char16_t *
3937 UnicodeString::getBuffer()
const {
3938 if(fUnion.fFields.fLengthAndFlags&(kIsBogus|kOpenGetBuffer)) {
3940 }
else if(fUnion.fFields.fLengthAndFlags&kUsingStackBuffer) {
3941 return fUnion.fStackFields.fBuffer;
3943 return fUnion.fFields.fArray;
3951 UnicodeString::doCompare(int32_t start,
3955 int32_t srcLength)
const 3958 return (int8_t)!isBogus();
3960 srcText.pinIndices(srcStart, srcLength);
3961 return doCompare(start, thisLength, srcText.getArrayStart(), srcStart, srcLength);
3971 int32_t len = length(), textLength = text.
length();
3972 return !text.
isBogus() && len == textLength && doEquals(text, len);
3978 {
return (!
operator==(text)); }
3982 {
return doCompare(0, length(), text, 0, text.
length()) == 1; }
3986 {
return doCompare(0, length(), text, 0, text.
length()) == -1; }
3990 {
return doCompare(0, length(), text, 0, text.
length()) != -1; }
3994 {
return doCompare(0, length(), text, 0, text.
length()) != 1; }
3998 {
return doCompare(0, length(), text, 0, text.
length()); }
4001 UnicodeString::compare(int32_t start,
4004 {
return doCompare(start, _length, srcText, 0, srcText.
length()); }
4008 int32_t srcLength)
const 4009 {
return doCompare(0, length(), srcChars, 0, srcLength); }
4012 UnicodeString::compare(int32_t start,
4016 int32_t srcLength)
const 4017 {
return doCompare(start, _length, srcText, srcStart, srcLength); }
4020 UnicodeString::compare(int32_t start,
4022 const char16_t *srcChars)
const 4023 {
return doCompare(start, _length, srcChars, 0, _length); }
4026 UnicodeString::compare(int32_t start,
4028 const char16_t *srcChars,
4030 int32_t srcLength)
const 4031 {
return doCompare(start, _length, srcChars, srcStart, srcLength); }
4034 UnicodeString::compareBetween(int32_t start,
4038 int32_t srcLimit)
const 4039 {
return doCompare(start, limit - start,
4040 srcText, srcStart, srcLimit - srcStart); }
4043 UnicodeString::doCompareCodePointOrder(int32_t start,
4047 int32_t srcLength)
const 4050 return (int8_t)!isBogus();
4052 srcText.pinIndices(srcStart, srcLength);
4053 return doCompareCodePointOrder(start, thisLength, srcText.getArrayStart(), srcStart, srcLength);
4059 {
return doCompareCodePointOrder(0, length(), text, 0, text.
length()); }
4062 UnicodeString::compareCodePointOrder(int32_t start,
4065 {
return doCompareCodePointOrder(start, _length, srcText, 0, srcText.
length()); }
4069 int32_t srcLength)
const 4070 {
return doCompareCodePointOrder(0, length(), srcChars, 0, srcLength); }
4073 UnicodeString::compareCodePointOrder(int32_t start,
4077 int32_t srcLength)
const 4078 {
return doCompareCodePointOrder(start, _length, srcText, srcStart, srcLength); }
4081 UnicodeString::compareCodePointOrder(int32_t start,
4083 const char16_t *srcChars)
const 4084 {
return doCompareCodePointOrder(start, _length, srcChars, 0, _length); }
4087 UnicodeString::compareCodePointOrder(int32_t start,
4089 const char16_t *srcChars,
4091 int32_t srcLength)
const 4092 {
return doCompareCodePointOrder(start, _length, srcChars, srcStart, srcLength); }
4095 UnicodeString::compareCodePointOrderBetween(int32_t start,
4099 int32_t srcLimit)
const 4100 {
return doCompareCodePointOrder(start, limit - start,
4101 srcText, srcStart, srcLimit - srcStart); }
4104 UnicodeString::doCaseCompare(int32_t start,
4109 uint32_t options)
const 4112 return (int8_t)!isBogus();
4114 srcText.pinIndices(srcStart, srcLength);
4115 return doCaseCompare(start, thisLength, srcText.getArrayStart(), srcStart, srcLength, options);
4121 return doCaseCompare(0, length(), text, 0, text.
length(), options);
4125 UnicodeString::caseCompare(int32_t start,
4128 uint32_t options)
const {
4129 return doCaseCompare(start, _length, srcText, 0, srcText.
length(), options);
4135 uint32_t options)
const {
4136 return doCaseCompare(0, length(), srcChars, 0, srcLength, options);
4140 UnicodeString::caseCompare(int32_t start,
4145 uint32_t options)
const {
4146 return doCaseCompare(start, _length, srcText, srcStart, srcLength, options);
4150 UnicodeString::caseCompare(int32_t start,
4152 const char16_t *srcChars,
4153 uint32_t options)
const {
4154 return doCaseCompare(start, _length, srcChars, 0, _length, options);
4158 UnicodeString::caseCompare(int32_t start,
4160 const char16_t *srcChars,
4163 uint32_t options)
const {
4164 return doCaseCompare(start, _length, srcChars, srcStart, srcLength, options);
4168 UnicodeString::caseCompareBetween(int32_t start,
4173 uint32_t options)
const {
4174 return doCaseCompare(start, limit - start, srcText, srcStart, srcLimit - srcStart, options);
4182 int32_t _length)
const 4185 srcText.pinIndices(srcStart, srcLength);
4187 return indexOf(srcText.getArrayStart(), srcStart, srcLength, start, _length);
4195 {
return indexOf(text, 0, text.
length(), 0, length()); }
4199 int32_t start)
const {
4201 return indexOf(text, 0, text.
length(), start, length() - start);
4207 int32_t _length)
const 4208 {
return indexOf(text, 0, text.
length(), start, _length); }
4211 UnicodeString::indexOf(
const char16_t *srcChars,
4213 int32_t start)
const {
4215 return indexOf(srcChars, 0, srcLength, start, length() - start);
4222 int32_t _length)
const 4223 {
return indexOf(srcChars, 0, srcLength, start, _length); }
4226 UnicodeString::indexOf(char16_t c,
4228 int32_t _length)
const 4229 {
return doIndexOf(c, start, _length); }
4234 int32_t _length)
const 4235 {
return doIndexOf(c, start, _length); }
4238 UnicodeString::indexOf(char16_t c)
const 4239 {
return doIndexOf(c, 0, length()); }
4243 {
return indexOf(c, 0, length()); }
4246 UnicodeString::indexOf(char16_t c,
4247 int32_t start)
const {
4249 return doIndexOf(c, start, length() - start);
4254 int32_t start)
const {
4256 return indexOf(c, start, length() - start);
4263 int32_t _length)
const 4264 {
return lastIndexOf(srcChars, 0, srcLength, start, _length); }
4267 UnicodeString::lastIndexOf(
const char16_t *srcChars,
4269 int32_t start)
const {
4271 return lastIndexOf(srcChars, 0, srcLength, start, length() - start);
4279 int32_t _length)
const 4282 srcText.pinIndices(srcStart, srcLength);
4284 return lastIndexOf(srcText.getArrayStart(), srcStart, srcLength, start, _length);
4293 int32_t _length)
const 4294 {
return lastIndexOf(text, 0, text.
length(), start, _length); }
4298 int32_t start)
const {
4300 return lastIndexOf(text, 0, text.
length(), start, length() - start);
4305 {
return lastIndexOf(text, 0, text.
length(), 0, length()); }
4308 UnicodeString::lastIndexOf(char16_t c,
4310 int32_t _length)
const 4311 {
return doLastIndexOf(c, start, _length); }
4316 int32_t _length)
const {
4317 return doLastIndexOf(c, start, _length);
4321 UnicodeString::lastIndexOf(char16_t c)
const 4322 {
return doLastIndexOf(c, 0, length()); }
4326 return lastIndexOf(c, 0, length());
4330 UnicodeString::lastIndexOf(char16_t c,
4331 int32_t start)
const {
4333 return doLastIndexOf(c, start, length() - start);
4338 int32_t start)
const {
4340 return lastIndexOf(c, start, length() - start);
4345 {
return compare(0, text.
length(), text, 0, text.
length()) == 0; }
4350 int32_t srcLength)
const 4351 {
return doCompare(0, srcLength, srcText, srcStart, srcLength) == 0; }
4358 return doCompare(0, srcLength, srcChars, 0, srcLength) == 0;
4362 UnicodeString::startsWith(
const char16_t *srcChars, int32_t srcStart, int32_t srcLength)
const {
4366 return doCompare(0, srcLength, srcChars, srcStart, srcLength) == 0;
4371 {
return doCompare(length() - text.
length(), text.
length(),
4372 text, 0, text.
length()) == 0; }
4377 int32_t srcLength)
const {
4378 srcText.pinIndices(srcStart, srcLength);
4379 return doCompare(length() - srcLength, srcLength,
4380 srcText, srcStart, srcLength) == 0;
4385 int32_t srcLength)
const {
4389 return doCompare(length() - srcLength, srcLength,
4390 srcChars, 0, srcLength) == 0;
4394 UnicodeString::endsWith(
const char16_t *srcChars,
4396 int32_t srcLength)
const {
4400 return doCompare(length() - srcLength, srcLength,
4401 srcChars, srcStart, srcLength) == 0;
4408 UnicodeString::replace(int32_t start,
4411 {
return doReplace(start, _length, srcText, 0, srcText.
length()); }
4414 UnicodeString::replace(int32_t start,
4419 {
return doReplace(start, _length, srcText, srcStart, srcLength); }
4422 UnicodeString::replace(int32_t start,
4426 {
return doReplace(start, _length, srcChars, 0, srcLength); }
4429 UnicodeString::replace(int32_t start,
4431 const char16_t *srcChars,
4434 {
return doReplace(start, _length, srcChars, srcStart, srcLength); }
4437 UnicodeString::replace(int32_t start,
4440 {
return doReplace(start, _length, &srcChar, 0, 1); }
4443 UnicodeString::replaceBetween(int32_t start,
4446 {
return doReplace(start, limit - start, srcText, 0, srcText.
length()); }
4449 UnicodeString::replaceBetween(int32_t start,
4454 {
return doReplace(start, limit - start, srcText, srcStart, srcLimit - srcStart); }
4459 {
return findAndReplace(0, length(), oldText, 0, oldText.
length(),
4460 newText, 0, newText.
length()); }
4463 UnicodeString::findAndReplace(int32_t start,
4467 {
return findAndReplace(start, _length, oldText, 0, oldText.
length(),
4468 newText, 0, newText.
length()); }
4474 UnicodeString::doExtract(int32_t start,
4477 { target.
replace(0, target.
length(), *
this, start, _length); }
4480 UnicodeString::extract(int32_t start,
4483 int32_t targetStart)
const 4484 { doExtract(start, _length, target, targetStart); }
4487 UnicodeString::extract(int32_t start,
4490 { doExtract(start, _length, target); }
4492 #if !UCONFIG_NO_CONVERSION 4495 UnicodeString::extract(int32_t start,
4498 const char *codepage)
const 4502 return extract(start, _length, dst, dst!=0 ? 0xffffffff : 0, codepage);
4508 UnicodeString::extractBetween(int32_t start,
4511 int32_t dstStart)
const {
4514 doExtract(start, limit - start, dst, dstStart);
4518 UnicodeString::tempSubStringBetween(int32_t start, int32_t limit)
const {
4519 return tempSubString(start, limit - start);
4523 UnicodeString::doCharAt(int32_t offset)
const 4525 if((uint32_t)offset < (uint32_t)length()) {
4526 return getArrayStart()[offset];
4528 return kInvalidUChar;
4533 UnicodeString::charAt(int32_t offset)
const 4534 {
return doCharAt(offset); }
4537 UnicodeString::operator[] (int32_t offset)
const 4538 {
return doCharAt(offset); }
4541 UnicodeString::isEmpty()
const {
4543 return (fUnion.fFields.fLengthAndFlags>>kLengthShift) == 0;
4550 UnicodeString::setZeroLength() {
4551 fUnion.fFields.fLengthAndFlags &= kAllStorageFlags;
4555 UnicodeString::setShortLength(int32_t len) {
4557 fUnion.fFields.fLengthAndFlags =
4558 (int16_t)((fUnion.fFields.fLengthAndFlags & kAllStorageFlags) | (len << kLengthShift));
4562 UnicodeString::setLength(int32_t len) {
4563 if(len <= kMaxShortLength) {
4564 setShortLength(len);
4566 fUnion.fFields.fLengthAndFlags |= kLengthIsLarge;
4567 fUnion.fFields.fLength = len;
4572 UnicodeString::setToEmpty() {
4573 fUnion.fFields.fLengthAndFlags = kShortString;
4577 UnicodeString::setArray(char16_t *array, int32_t len, int32_t capacity) {
4579 fUnion.fFields.fArray = array;
4580 fUnion.fFields.fCapacity = capacity;
4583 inline UnicodeString&
4584 UnicodeString::operator= (char16_t ch)
4585 {
return doReplace(0, length(), &ch, 0, 1); }
4589 {
return replace(0, length(), ch); }
4597 return doReplace(0, length(), srcText, srcStart, srcLength);
4605 srcText.pinIndex(srcStart);
4606 return doReplace(0, length(), srcText, srcStart, srcText.
length() - srcStart);
4612 return copyFrom(srcText);
4616 UnicodeString::setTo(
const char16_t *srcChars,
4620 return doReplace(0, length(), srcChars, 0, srcLength);
4624 UnicodeString::setTo(char16_t srcChar)
4627 return doReplace(0, length(), &srcChar, 0, 1);
4634 return replace(0, length(), srcChar);
4641 {
return doAppend(srcText, srcStart, srcLength); }
4645 {
return doAppend(srcText, 0, srcText.
length()); }
4648 UnicodeString::append(
const char16_t *srcChars,
4651 {
return doAppend(srcChars, srcStart, srcLength); }
4656 {
return doAppend(srcChars, 0, srcLength); }
4659 UnicodeString::append(char16_t srcChar)
4660 {
return doAppend(&srcChar, 0, 1); }
4663 UnicodeString::operator+= (char16_t ch)
4664 {
return doAppend(&ch, 0, 1); }
4673 {
return doAppend(srcText, 0, srcText.
length()); }
4676 UnicodeString::insert(int32_t start,
4680 {
return doReplace(start, 0, srcText, srcStart, srcLength); }
4683 UnicodeString::insert(int32_t start,
4685 {
return doReplace(start, 0, srcText, 0, srcText.
length()); }
4688 UnicodeString::insert(int32_t start,
4689 const char16_t *srcChars,
4692 {
return doReplace(start, 0, srcChars, srcStart, srcLength); }
4695 UnicodeString::insert(int32_t start,
4698 {
return doReplace(start, 0, srcChars, 0, srcLength); }
4701 UnicodeString::insert(int32_t start,
4703 {
return doReplace(start, 0, &srcChar, 0, 1); }
4706 UnicodeString::insert(int32_t start,
4708 {
return replace(start, 0, srcChar); }
4712 UnicodeString::remove()
4724 UnicodeString::remove(int32_t start,
4727 if(start <= 0 && _length ==
INT32_MAX) {
4731 return doReplace(start, _length,
NULL, 0, 0);
4735 UnicodeString::removeBetween(int32_t start,
4737 {
return doReplace(start, limit - start,
NULL, 0, 0); }
4740 UnicodeString::retainBetween(int32_t start, int32_t limit) {
4742 return doReplace(0, start,
NULL, 0, 0);
4746 UnicodeString::truncate(int32_t targetLength)
4748 if(isBogus() && targetLength == 0) {
4752 }
else if((uint32_t)targetLength < (uint32_t)length()) {
4753 setLength(targetLength);
4761 UnicodeString::reverse()
4762 {
return doReverse(0, length()); }
4765 UnicodeString::reverse(int32_t start,
4767 {
return doReverse(start, _length); }
#define UNISTR_OBJECT_SIZE
Desired sizeof(UnicodeString) in bytes.
EInvariant
Constant to be used in the UnicodeString(char *, int32_t, EInvariant) constructor which constructs a ...
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.
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.
friend U_COMMON_API void swap(UnicodeString &s1, UnicodeString &s2)
Non-member UnicodeString swap function.
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.
UnicodeString & operator=(UnicodeString &&src)
Move assignment operator; might leave src in bogus state.
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.