55static const bool kWideStringDefault =
true;
57static const bool kWideStringDefault =
false;
60static const uint16 kBomUtf16 = 0xFEFF;
61static const char8*
const kBomUtf8 =
"\xEF\xBB\xBF";
62static const int32 kBomUtf8Length = 3;
90extern uint32 hashString8 (
const char8* s, uint32 m);
91extern uint32 hashString16 (
const char16* s, uint32 m);
92inline uint32 hashString (
const tchar* s, uint32 m)
95 return hashString16 (s, m);
97 return hashString8 (s, m);
128 virtual int32
length ()
const {
return static_cast<int32
> (len);}
129 inline bool isEmpty ()
const {
return buffer ==
nullptr || len == 0;}
131 operator const char8* ()
const {
return text8 ();}
132 operator const char16* ()
const {
return text16 ();}
134 inline tchar
operator[] (
long idx)
const {
return getChar (
static_cast<uint32
> (idx));}
135 inline tchar
operator[] (
int idx)
const {
return getChar (
static_cast<uint32
> (idx));}
137 inline tchar
operator[] (
unsigned long idx)
const {
return getChar (
static_cast<uint32
> (idx));}
140 inline virtual const char8*
text8 ()
const;
141 inline virtual const char16*
text16 ()
const;
142 inline virtual const tchar*
text ()
const;
143 inline virtual const void*
ptr ()
const {
return buffer;}
145 inline virtual char8
getChar8 (uint32 index)
const;
146 inline virtual char16
getChar16 (uint32 index)
const;
147 inline tchar
getChar (uint32 index)
const;
148 inline tchar
getCharAt (uint32 index)
const;
150 bool testChar8 (uint32 index, char8 c)
const;
151 bool testChar16 (uint32 index, char16 c)
const;
152 inline bool testChar (uint32 index, char8 c)
const {
return testChar8 (index, c);}
153 inline bool testChar (uint32 index, char16 c)
const {
return testChar16 (index, c);}
155 bool extract (String& result, uint32 idx, int32 n = -1)
const;
156 int32 copyTo8 (char8* str, uint32 idx = 0, int32 n = -1)
const;
157 int32 copyTo16 (char16* str, uint32 idx = 0, int32 n = -1)
const;
158 int32 copyTo (tchar* str, uint32 idx = 0, int32 n = -1)
const;
159 void copyTo (IStringResult* result)
const;
160 void copyTo (IString&
string)
const;
162 inline uint32 hash (uint32 tsize)
const
164 return isWide ? hashString16 (buffer16, tsize) : hashString8 (buffer8, tsize) ;
196 static bool isCharUpper (char8 character);
197 static bool isCharUpper (char16 character);
198 static bool isCharLower (char8 character);
199 static bool isCharLower (char16 character);
205 inline int32 findFirst (char8 c,
CompareMode m =
kCaseSensitive, int32 endIndex = -1)
const {
return findNext (0, c, m, endIndex);}
206 inline int32 findFirst (char16 c,
CompareMode m =
kCaseSensitive, int32 endIndex = -1)
const {
return findNext (0, c, m, endIndex);}
210 int32 findNext (int32 startIndex,
const ConstString& str, int32 n = -1,
CompareMode =
kCaseSensitive, int32 endIndex = -1)
const;
231 bool isDigit (uint32 index)
const;
232 bool scanFloat (
double& value, uint32 offset = 0,
bool scanToEnd =
true)
const;
233 bool scanInt64 (int64& value, uint32 offset = 0,
bool scanToEnd =
true)
const;
234 bool scanUInt64 (uint64& value, uint32 offset = 0,
bool scanToEnd =
true)
const;
235 bool scanInt32 (int32& value, uint32 offset = 0,
bool scanToEnd =
true)
const;
236 bool scanUInt32 (uint32& value, uint32 offset = 0,
bool scanToEnd =
true)
const;
237 bool scanHex (uint8& value, uint32 offset = 0,
bool scanToEnd =
true)
const;
244 static bool scanInt64_8 (
const char8*
text, int64& value,
bool scanToEnd =
true);
245 static bool scanInt64_16 (
const char16*
text, int64& value,
bool scanToEnd =
true);
246 static bool scanInt64 (
const tchar*
text, int64& value,
bool scanToEnd =
true);
248 static bool scanUInt64_8 (
const char8*
text, uint64& value,
bool scanToEnd =
true);
249 static bool scanUInt64_16 (
const char16*
text, uint64& value,
bool scanToEnd =
true);
250 static bool scanUInt64 (
const tchar*
text, uint64& value,
bool scanToEnd =
true);
252 static bool scanInt32_8 (
const char8*
text, int32& value,
bool scanToEnd =
true);
253 static bool scanInt32_16 (
const char16*
text, int32& value,
bool scanToEnd =
true);
254 static bool scanInt32 (
const tchar*
text, int32& value,
bool scanToEnd =
true);
256 static bool scanUInt32_8 (
const char8*
text, uint32& value,
bool scanToEnd =
true);
257 static bool scanUInt32_16 (
const char16*
text, uint32& value,
bool scanToEnd =
true);
258 static bool scanUInt32 (
const tchar*
text, uint32& value,
bool scanToEnd =
true);
260 static bool scanHex_8 (
const char8*
text, uint8& value,
bool scanToEnd =
true);
261 static bool scanHex_16 (
const char16*
text, uint8& value,
bool scanToEnd =
true);
262 static bool scanHex (
const tchar*
text, uint8& value,
bool scanToEnd =
true);
266 void toVariant (FVariant& var)
const;
268 static char8
toLower (char8 c);
269 static char8
toUpper (char8 c);
270 static char16
toLower (char16 c);
271 static char16
toUpper (char16 c);
273 static int32
multiByteToWideString (char16* dest,
const char8* source, int32 wcharCount, uint32 sourceCodePage = kCP_Default);
274 static int32
wideStringToMultiByte (char8* dest,
const char16* source, int32 char8Count, uint32 destCodePage = kCP_Default);
283 operator const wchar_t* ()
const {
return wscast (
text16 ());}
287 virtual void* toCFStringRef (uint32 encoding = 0xFFFF,
bool mutableCFString =
false)
const;
318 String (
const char8* str,
MBCodePage codepage, int32 n = -1,
bool isTerminated =
true);
319 String (
const char8* str, int32 n = -1,
bool isTerminated =
true);
320 String (
const char16* str, int32 n = -1,
bool isTerminated =
true);
327#if SMTG_CPP11_STDLIBSUPPORT
334 const char8*
text8 ()
const SMTG_OVERRIDE;
335 const char16*
text16 ()
const SMTG_OVERRIDE;
336 char8
getChar8 (uint32 index)
const SMTG_OVERRIDE;
337 char16
getChar16 (uint32 index)
const SMTG_OVERRIDE;
339 bool setChar8 (uint32 index, char8 c);
340 bool setChar16 (uint32 index, char16 c);
341 inline bool setChar (uint32 index, char8 c) {
return setChar8 (index, c);}
342 inline bool setChar (uint32 index, char16 c) {
return setChar16 (index, c);}
353 String&
assign (
const ConstString& str, int32 n = -1);
354 String&
assign (
const char8* str, int32 n = -1,
bool isTerminated =
true);
355 String&
assign (
const char16* str, int32 n = -1,
bool isTerminated =
true);
356 String&
assign (char8 c, int32 n = 1);
357 String&
assign (char16 c, int32 n = 1);
361 String&
append (
const ConstString& str, int32 n = -1);
362 String&
append (
const char8* str, int32 n = -1);
363 String&
append (
const char16* str, int32 n = -1);
364 String&
append (
const char8 c, int32 n = 1);
365 String&
append (
const char16 c, int32 n = 1);
367 String&
insertAt (uint32 idx,
const ConstString& str, int32 n = -1);
368 String&
insertAt (uint32 idx,
const char8* str, int32 n = -1);
369 String&
insertAt (uint32 idx,
const char16* str, int32 n = -1);
370 String&
insertAt (uint32 idx, char8 c) {char8 str[] = {c, 0};
return insertAt (idx, str, 1);}
371 String&
insertAt (uint32 idx, char16 c) {char16 str[] = {c, 0};
return insertAt (idx, str, 1);}
373 String& operator+= (
const String& str) {
return append (str);}
374 String& operator+= (
const ConstString& str) {
return append (str);}
375 String& operator+= (
const char8* str) {
return append (str);}
376 String& operator+= (
const char16* str) {
return append (str);}
377 String& operator+= (
const char8 c) {
return append (c);}
378 String& operator+= (
const char16 c) {
return append (c);}
382 String&
replace (uint32 idx, int32 n1,
const ConstString& str, int32 n2 = -1);
383 String&
replace (uint32 idx, int32 n1,
const char8* str, int32 n2 = -1);
384 String&
replace (uint32 idx, int32 n1,
const char16* str, int32 n2 = -1);
389 bool replaceChars8 (
const char8* toReplace, char8 toReplaceBy);
390 bool replaceChars16 (
const char16* toReplace, char16 toReplaceBy);
391 inline bool replaceChars8 (char8 toReplace, char8 toReplaceBy) {char8 str[] = {toReplace, 0};
return replaceChars8 (str, toReplaceBy);}
392 inline bool replaceChars16 (char16 toReplace, char16 toReplaceBy) {char16 str[] = {toReplace, 0};
return replaceChars16 (str, toReplaceBy);}
393 inline bool replaceChars (char8 toReplace, char8 toReplaceBy) {
return replaceChars8 (toReplace, toReplaceBy);}
394 inline bool replaceChars (char16 toReplace, char16 toReplaceBy) {
return replaceChars16 (toReplace, toReplaceBy);}
395 inline bool replaceChars (
const char8* toReplace, char8 toReplaceBy) {
return replaceChars8 (toReplace, toReplaceBy);}
396 inline bool replaceChars (
const char16* toReplace, char16 toReplaceBy) {
return replaceChars16 (toReplace, toReplaceBy);}
400 String&
remove (uint32 index = 0, int32 n = -1);
401 enum CharGroup {kSpace, kNotAlphaNum, kNotAlpha};
402 bool trim (CharGroup mode = kSpace);
412 bool removeSubString (
const ConstString& subString,
bool allOccurences =
true);
416 String&
printf (
const char8* format, ...);
417 String&
printf (
const char16* format, ...);
418 String& vprintf (
const char8* format,
va_list args);
419 String& vprintf (
const char16* format,
va_list args);
423 String& printInt64 (int64 value);
432 String&
printFloat (
double value, uint32 maxPrecision = 6);
435 bool incrementTrailingNumber (uint32 width = 2, tchar separator = STR (
' '), uint32 minNumber = 1,
bool applyOnlyFormat =
false);
440 void toVariant (FVariant& var)
const;
442 bool toAttributes (IAttributes* a, IAttrID attrID);
445 void take (String& str);
446 void take (
void* _buffer,
bool wide);
458 bool toWideString (uint32 sourceCodePage = kCP_Default);
459 bool toMultiByte (uint32 destCodePage = kCP_Default);
461 void fromUTF8 (
const char8* utf8String);
462 bool normalize (UnicodeNormalization = kUnicodeNormC);
465 String (
const wchar_t* str, int32
length = -1,
bool isTerminated =
true) : String (wscast (str),
length,
isTerminated) {}
470 virtual bool fromCFStringRef (
const void*, uint32 encoding = 0xFFFF);
476 bool resize (uint32 newSize,
bool wide,
bool fill =
false);
479 bool _toWideString (
const char8* src, int32
length, uint32 sourceCodePage = kCP_Default);
480 void tryFreeBuffer ();
481 bool checkToMultiByte (uint32 destCodePage = kCP_Default)
const;
485inline String operator+ (
const ConstString& s1,
const ConstString& s2) {
return String (s1).append (s2);}
486inline String operator+ (
const ConstString& s1,
const char8* s2) {
return String (s1).append (s2);}
487inline String operator+ (
const ConstString& s1,
const char16* s2) {
return String (s1).append (s2);}
488inline String operator+ (
const char8* s1,
const ConstString& s2) {
return String (s1).append (s2);}
489inline String operator+ (
const char16* s1,
const ConstString& s2) {
return String (s1).append (s2);}
490inline String operator+ (
const ConstString& s1,
const String& s2) {
return String (s1).append (s2);}
491inline String operator+ (
const String& s1,
const ConstString& s2) {
return String (s1).append (s2);}
492inline String operator+ (
const String& s1,
const String& s2) {
return String (s1).append (s2);}
493inline String operator+ (
const String& s1,
const char8* s2) {
return String (s1).append (s2);}
494inline String operator+ (
const String& s1,
const char16* s2) {
return String (s1).append (s2);}
495inline String operator+ (
const char8* s1,
const String& s2) {
return String (s1).append (s2);}
496inline String operator+ (
const char16* s1,
const String& s2) {
return String (s1).append (s2);}
513 return (!isWide && buffer8) ? buffer8: kEmptyString8;
519 return (isWide && buffer16) ? buffer16 : kEmptyString16;
525 if (index < len && buffer8 && !isWide)
526 return buffer8[index];
533 if (index < len && buffer16 && isWide)
534 return buffer16[index];
556 return static_cast<tchar
> (
getChar8 (index));
681inline bool operator<= (
const ConstString& s1,
const ConstString& s2) {
return (s1.compare (s2) <= 0) ? true :
false;}
682inline bool operator> (
const ConstString& s1,
const ConstString& s2) {
return (s1.compare (s2) > 0) ? true :
false;}
683inline bool operator>= (
const ConstString& s1,
const ConstString& s2) {
return (s1.compare (s2) >= 0) ? true :
false;}
684inline bool operator== (
const ConstString& s1,
const ConstString& s2) {
return (s1.compare (s2) == 0) ? true :
false;}
685inline bool operator!= (
const ConstString& s1,
const ConstString& s2) {
return (s1.compare (s2) != 0) ? true :
false;}
687inline bool operator< (
const ConstString& s1,
const char8* s2) {
return (s1.compare (s2) < 0) ? true :
false;}
688inline bool operator<= (
const ConstString& s1,
const char8* s2) {
return (s1.compare (s2) <= 0) ? true :
false;}
689inline bool operator> (
const ConstString& s1,
const char8* s2) {
return (s1.compare (s2) > 0) ? true :
false;}
690inline bool operator>= (
const ConstString& s1,
const char8* s2) {
return (s1.compare (s2) >= 0) ? true :
false;}
691inline bool operator== (
const ConstString& s1,
const char8* s2) {
return (s1.compare (s2) == 0) ? true :
false;}
692inline bool operator!= (
const ConstString& s1,
const char8* s2) {
return (s1.compare (s2) != 0) ? true :
false;}
693inline bool operator< (
const char8* s1,
const ConstString& s2) {
return (s2.compare (s1) > 0) ? true :
false;}
694inline bool operator<= (
const char8* s1,
const ConstString& s2) {
return (s2.compare (s1) >= 0) ? true :
false;}
695inline bool operator> (
const char8* s1,
const ConstString& s2) {
return (s2.compare (s1) < 0) ? true :
false;}
696inline bool operator>= (
const char8* s1,
const ConstString& s2) {
return (s2.compare (s1) <= 0) ? true :
false;}
697inline bool operator== (
const char8* s1,
const ConstString& s2) {
return (s2.compare (s1) == 0) ? true :
false;}
698inline bool operator!= (
const char8* s1,
const ConstString& s2) {
return (s2.compare (s1) != 0) ? true :
false;}
700inline bool operator< (
const ConstString& s1,
const char16* s2) {
return (s1.compare (s2) < 0) ? true :
false;}
701inline bool operator<= (
const ConstString& s1,
const char16* s2) {
return (s1.compare (s2) <= 0) ? true :
false;}
702inline bool operator> (
const ConstString& s1,
const char16* s2) {
return (s1.compare (s2) > 0) ? true :
false;}
703inline bool operator>= (
const ConstString& s1,
const char16* s2) {
return (s1.compare (s2) >= 0) ? true :
false;}
704inline bool operator== (
const ConstString& s1,
const char16* s2) {
return (s1.compare (s2) == 0) ? true :
false;}
705inline bool operator!= (
const ConstString& s1,
const char16* s2) {
return (s1.compare (s2) != 0) ? true :
false;}
706inline bool operator< (
const char16* s1,
const ConstString& s2) {
return (s2.compare (s1) > 0) ? true :
false;}
707inline bool operator<= (
const char16* s1,
const ConstString& s2) {
return (s2.compare (s1) >= 0) ? true :
false;}
708inline bool operator> (
const char16* s1,
const ConstString& s2) {
return (s2.compare (s1) < 0) ? true :
false;}
709inline bool operator>= (
const char16* s1,
const ConstString& s2) {
return (s2.compare (s1) <= 0) ? true :
false;}
710inline bool operator== (
const char16* s1,
const ConstString& s2) {
return (s2.compare (s1) == 0) ? true :
false;}
711inline bool operator!= (
const char16* s1,
const ConstString& s2) {
return (s2.compare (s1) != 0) ? true :
false;}
715extern int32 strnatcmp8 (
const char8* s1,
const char8* s2,
bool caseSensitive =
true);
716extern int32 strnatcmp16 (
const char16* s1,
const char16* s2,
bool caseSensitive =
true);
717inline int32 strnatcmp (
const tchar* s1,
const tchar* s2,
bool caseSensitive =
true)
720 return strnatcmp16 (s1, s2, caseSensitive);
722 return strnatcmp8 (s1, s2, caseSensitive);
739 StringObject (
const char16* str, int32 n = -1,
bool isTerminated =
true) :
String (str, n, isTerminated) {}
740 StringObject (
const char8* str, int32 n = -1,
bool isTerminated =
true) :
String (str, n, isTerminated) {}
745 using String::operator=;
748 void PLUGIN_API setText (
const char8*
text) SMTG_OVERRIDE;
752 void PLUGIN_API
setText8 (
const char8*
text) SMTG_OVERRIDE;
753 void PLUGIN_API
setText16 (
const char16*
text) SMTG_OVERRIDE;
755 const char8* PLUGIN_API
getText8 () SMTG_OVERRIDE;
756 const char16* PLUGIN_API
getText16 () SMTG_OVERRIDE;
758 void PLUGIN_API
take (
void* s,
bool _isWide) SMTG_OVERRIDE;
virtual const char8 * text8() const
Returns pointer to string of type char8.
int32 getFirstDifferent(const ConstString &str, CompareMode=kCaseSensitive) const
Returns position of first different character.
int64 getTrailingNumber(int64 fallback=0) const
Returns result of scanInt64 or the fallback.
bool isAsciiString() const
Checks if all characters in string are in ascii range.
virtual const tchar * text() const
Returns pointer to string of type tchar.
virtual char8 getChar8(uint32 index) const
Returns character of type char16 at 'index'.
static bool scanUInt32_16(const char16 *text, uint32 &value, bool scanToEnd=true)
Converts string of type char16 to int32 value.
static bool scanInt32_8(const char8 *text, int32 &value, bool scanToEnd=true)
Converts string of type char8 to int32 value.
static bool isCharSpace(char8 character)
Returns true if character is a space.
static bool scanUInt64_16(const char16 *text, uint64 &value, bool scanToEnd=true)
Converts string of type char16 to uint64 value.
static int32 wideStringToMultiByte(char8 *dest, const char16 *source, int32 char8Count, uint32 destCodePage=kCP_Default)
If dest is zero, this returns the maximum number of bytes needed to convert source.
@ kCaseSensitive
Comparison is done with regard to character's case.
@ kCaseInsensitive
Comparison is done without regard to character's case.
int32 findLast(const ConstString &str, int32 n=-1, CompareMode m=kCaseSensitive) const
Find last occurrence of n characters of str in this (n=-1: all)
tchar getCharAt(uint32 index) const
Returns character of type tchar at 'index', no conversion!
bool endsWith(const ConstString &str, CompareMode m=kCaseSensitive) const
Check if this ends with str.
bool isDigit(uint32 index) const
Returns true if character at position is a digit.
static bool scanHex_16(const char16 *text, uint8 &value, bool scanToEnd=true)
Converts string of type char16 to hex/unit8 value.
tchar operator[](short idx) const
Returns character at 'idx'.
bool testChar8(uint32 index, char8 c) const
Returns true if character is equal at position 'index'.
bool scanInt32(int32 &value, uint32 offset=0, bool scanToEnd=true) const
Converts string to int32 value starting at offset.
static bool scanHex_8(const char8 *text, uint8 &value, bool scanToEnd=true)
Converts string of type char8 to hex/unit8 value.
bool scanHex(uint8 &value, uint32 offset=0, bool scanToEnd=true) const
Converts string to hex/uint8 value starting at offset.
bool scanUInt32(uint32 &value, uint32 offset=0, bool scanToEnd=true) const
Converts string to uint32 value starting at offset.
bool extract(String &result, uint32 idx, int32 n=-1) const
Get n characters long substring starting at index (n=-1: until end)
static char8 toLower(char8 c)
Converts to lower case.
static bool isCharAlphaNum(char8 character)
Returns true if character is an alphanumeric character.
int32 countOccurences(char8 c, uint32 startIndex, CompareMode=kCaseSensitive) const
Counts occurences of c within this starting at index.
bool isWideString() const
Returns true if string is wide.
bool startsWith(const ConstString &str, CompareMode m=kCaseSensitive) const
Check if this starts with str.
int32 getTrailingNumberIndex(uint32 width=0) const
Returns start index of trailing number.
bool scanUInt64(uint64 &value, uint32 offset=0, bool scanToEnd=true) const
Converts string to uint64 value starting at offset.
bool isEmpty() const
Return true if string is empty.
tchar getChar(uint32 index) const
Returns character of type tchar at 'index'.
int64 getNumber() const
Returns result of scanInt64.
static int32 multiByteToWideString(char16 *dest, const char8 *source, int32 wcharCount, uint32 sourceCodePage=kCP_Default)
If dest is zero, this returns the maximum number of bytes needed to convert source.
bool contains(const ConstString &str, CompareMode m=kCaseSensitive) const
Check if this contains str
virtual ~ConstString()
Destructor.
static bool scanInt64_8(const char8 *text, int64 &value, bool scanToEnd=true)
Converts string of type char8 to int64 value.
static bool isCharAscii(char8 character)
Returns true if character is in ASCII range.
static bool scanInt64_16(const char16 *text, int64 &value, bool scanToEnd=true)
Converts string of type char16 to int64 value.
static bool isCharDigit(char8 character)
Returns true if character is a number.
static bool isCharAlpha(char8 character)
Returns true if character is an alphabetic character.
bool isNormalized(UnicodeNormalization=kUnicodeNormC)
On PC only kUnicodeNormC is working.
bool scanFloat(double &value, uint32 offset=0, bool scanToEnd=true) const
Converts string to double value starting at offset.
bool scanInt64(int64 &value, uint32 offset=0, bool scanToEnd=true) const
Converts string to int64 value starting at offset.
virtual char16 getChar16(uint32 index) const
Returns character of type char8 at 'index'.
static bool scanUInt64_8(const char8 *text, uint64 &value, bool scanToEnd=true)
Converts string of type char8 to uint64 value.
int32 compareAt(uint32 index, const ConstString &str, int32 n=-1, CompareMode m=kCaseSensitive) const
Compare n characters of str with n characters of this starting at index (return: see above)
int32 compare(const ConstString &str, int32 n, CompareMode m=kCaseSensitive) const
Compare n characters of str with n characters of this (return: see above)
static bool scanUInt32_8(const char8 *text, uint32 &value, bool scanToEnd=true)
Converts string of type char8 to int32 value.
virtual const void * ptr() const
Returns pointer to string of type void.
virtual const char16 * text16() const
Returns pointer to string of type char16.
virtual int32 length() const
Return length of string.
static char8 toUpper(char8 c)
Converts to upper case.
static bool scanInt32_16(const char16 *text, int32 &value, bool scanToEnd=true)
Converts string of type char16 to int32 value.
Implements FUnknown and IDependent.
A Value of variable type.
Interface to return an ascii string of variable size.
Interface to a string of variable size and encoding.
StringObject implements IStringResult and IString methods.
const char8 *PLUGIN_API getText8() SMTG_OVERRIDE
Return ASCII string.
void PLUGIN_API take(void *s, bool _isWide) SMTG_OVERRIDE
!Do not use this method! Early implementations take the given pointer as internal string and this wil...
void PLUGIN_API setText8(const char8 *text) SMTG_OVERRIDE
Assign ASCII string.
const char16 *PLUGIN_API getText16() SMTG_OVERRIDE
Return unicode string.
void PLUGIN_API setText16(const char16 *text) SMTG_OVERRIDE
Assign unicode string.
bool PLUGIN_API isWideString() const SMTG_OVERRIDE
Returns true if the string is in unicode format, returns false if the string is ASCII.
String & printf(const char8 *format,...)
Print formatted data into string.
char8 getChar8(uint32 index) const SMTG_OVERRIDE
Returns character of type char16 at 'index'.
String & assign(const ConstString &str, int32 n=-1)
Assign n characters of str (-1: all)
bool replaceChars8(const char8 *toReplace, char8 toReplaceBy)
Returns true when any replacement was done.
const char8 * text8() const SMTG_OVERRIDE
Returns pointer to string of type char8.
void swapContent(String &s)
Swaps ownership of the strings pointed to.
void toUpper()
Upper case the string.
bool normalize(UnicodeNormalization=kUnicodeNormC)
On PC only kUnicodeNormC is working.
bool fromAttributes(IAttributes *a, IAttrID attrID)
Assigns string from FAttributes.
bool fromVariant(const FVariant &var)
Assigns string from FVariant.
bool removeChars8(const char8 *which)
Remove all occurrences of each char in 'which'.
String & insertAt(uint32 idx, const ConstString &str, int32 n=-1)
Insert n characters of str at position idx (n=-1: all)
bool removeChars16(const char16 *which)
Remove all occurrences of each char in 'which'.
const String & fromPascalString(const unsigned char *buf)
Pascal string conversion.
bool toWideString(uint32 sourceCodePage=kCP_Default)
Converts to wide string according to sourceCodePage.
void take(String &str)
Take ownership of the string of 'str'.
char16 getChar16(uint32 index) const SMTG_OVERRIDE
Returns character of type char8 at 'index'.
unsigned char * toPascalString(unsigned char *buf)
Pascal string conversion.
String & append(const ConstString &str, int32 n=-1)
Append n characters of str to this (n=-1: all)
String & operator=(const char8 *str)
Assign from a string of type char8.
const char16 * text16() const SMTG_OVERRIDE
Returns pointer to string of type char16.
bool incrementTrailingNumber(uint32 width=2, tchar separator=STR(' '), uint32 minNumber=1, bool applyOnlyFormat=false)
Increment the trailing number if present else start with minNumber, width specifies the string width ...
String & remove(uint32 index=0, int32 n=-1)
Remove n characters from string starting at index (n=-1: until end)
void fromUTF8(const char8 *utf8String)
Assigns from UTF8 string.
void passToVariant(FVariant &var)
Pass ownership of buffer to Variant - sets Variant ownership.
bool trim(CharGroup mode=kSpace)
Trim lead/trail.
String & printFloat(double value, uint32 maxPrecision=6)
print a float into a string, trailing zeros will be trimmed
void updateLength()
Call this when the string is truncated outside (not recommended though)
void toLower()
Lower case the string.
String & replace(uint32 idx, int32 n1, const ConstString &str, int32 n2=-1)
Replace n1 characters of this (starting at idx) with n2 characters of str (n1,n2=-1: until end)
void removeChars(CharGroup mode=kSpace)
Removes all of group.
Basic Object implementing FUnknown.
@ kCP_MAC_ROMAN
Default Mac codepage.
@ kCP_ShiftJIS
Shifted Japan Industrial Standard Encoding.
@ kCP_US_ASCII
US-ASCII (7-bit).
@ kCP_Default
Default ANSI codepage.
@ kCP_MAC_CEE
Mac Central European Encoding.
@ kCP_ANSI_WEL
West European Latin Encoding.
@ kCP_ANSI
Default ANSI codepage.
@ kUnicodeNormKD
Unicode normalization form KD, compatibility decomposition.
@ kUnicodeNormKC
Unicode normalization form KC, compatibility composition.
@ kUnicodeNormD
Unicode normalization Form D, canonical decomposition.
@ kUnicodeNormC
Unicode normalization Form C, canonical composition.
bool isTerminated()
Returns true when singleton instances were already released.