23 #ifndef __ccxx_String_hxx 24 #define __ccxx_String_hxx 98 String(
const wchar_t* str);
124 bool endsWith(
const String& str,
bool ignoreCase =
false)
const;
135 bool endsWith(
const Char& c,
bool ignoreCase =
false)
const;
146 bool endsWithAnyOf(
const String& chars,
bool ignoreCase =
false)
const;
157 bool startsWith(
const String& str,
bool ignoreCase =
false)
const;
168 bool startsWith(
const Char& c,
bool ignoreCase =
false)
const;
180 bool startsWithAnyOf(
const String& chars,
bool ignoreCase =
false)
const;
195 {
return(getLength()); }
204 void setLength(
uint_t length);
213 void reserve(
uint_t capacity);
219 uint_t getCapacity()
const;
244 bool isEmpty()
const;
261 bool isInteger()
const;
269 bool isAlphaNumeric()
const;
281 int compareTo(
const String& other,
bool ignoreCase =
false)
const;
288 String& trim(
const String &chars = whitespaceChars,
bool begin =
true,
298 {
return(trim(chars,
true,
false)); }
307 {
return(trim(chars,
false,
true)); }
383 {
return(insert(
String(str), index, count)); }
395 {
return(insert(
String(str), index, count)); }
411 {
return(append(
Char(c))); }
419 {
return(append(
Char(c))); }
463 String& append(
const int64_t& val);
473 String& append(
const double& val,
uint_t precision = 6);
481 String& append(
const uint64_t& val);
489 {
return(insert(c, END)); }
499 {
return(insert(str, END, count)); }
509 {
return(insert(str, END, count)); }
519 {
return(insert(
String(str), END, count)); }
529 {
return(insert(str, END, count)); }
537 {
return(insert(
Char(c), 0)); }
545 {
return(insert(
Char(c), 0)); }
553 {
return(insert(c, 0)); }
563 {
return(insert(str, 0, count)); }
573 {
return(insert(str, 0, count)); }
583 {
return(insert(
String(str), 0, count)); }
593 {
return(insert(str, 0, count)); }
649 int indexOf(
const Char& c,
uint_t fromIndex = 0)
const;
660 {
return(indexOf(
String(str), fromIndex)); }
671 int indexOfAnyOf(
const String& chars,
uint_t fromIndex = 0)
const;
681 int indexOf(
const String& str,
uint_t fromIndex = 0)
const;
692 int lastIndexOf(
const Char& c,
uint_t fromIndex = END)
const;
704 int lastIndexOfAnyOf(
const String& chars,
uint_t fromIndex = END)
const;
715 int lastIndexOf(
const String& str,
uint_t fromIndex = END)
const;
725 {
return(indexOf(c) >= 0); }
735 {
return(indexOf(str) >= 0); }
746 {
return(indexOfAnyOf(chars) >= 0); }
806 bool toBool(
uint_t index = 0)
const;
833 int64_t toInt64(
uint_t index = 0,
uint_t base = 10)
const;
842 uint64_t toUInt64(
uint_t index = 0,
uint_t base = 10)
const;
850 float toFloat(
uint_t index = 0)
const;
858 double toDouble(
uint_t index = 0)
const;
861 operator const void*()
const;
876 String& operator=(
const char* other);
883 String& operator=(
const wchar_t* other);
894 {
return(
operator=(other.c_str())); }
904 CharRef operator[](
int index);
914 const Char operator[](
int index)
const;
921 const_iterator begin()
const;
928 const_iterator end()
const;
940 {
return(substring(fromIndex, toIndex)); }
949 {
return(isNull()); }
957 {
return(append(c)); }
965 {
return(append(c)); }
973 {
return(append(c)); }
981 {
return(append(str)); }
989 {
return(append(str)); }
998 {
return(append(val)); }
1007 {
return(append(val)); }
1016 {
return(append(val)); }
1025 {
return(append(val)); }
1034 {
return(append(val)); }
1043 {
return(append(val)); }
1047 {
return(append(str)); }
1051 {
return(append(str)); }
1055 {
return(append(str)); }
1059 {
return(append(val)); }
1063 {
return(append(c)); }
1067 {
return(append(c)); }
1071 {
return(append(c)); }
1075 {
return(append(val)); }
1079 {
return(append(val)); }
1083 {
return(append(val)); }
1087 {
return(append(val)); }
1091 {
return(append(val)); }
1095 {
return(prepend(c)); }
1099 {
return(prepend(c)); }
1103 {
return(prepend(c)); }
1107 {
return(prepend(str)); }
1111 {
return(prepend(str)); }
1115 {
return(prepend(str)); }
1122 void write(std::ostream& stream)
const;
1147 void _makeCopy(
uint_t size,
bool unshareable =
false);
1149 void _fromUTF8(
const char* str,
uint_t len,
uint_t offset);
1151 void _fromWChar(
const wchar_t* str);
1168 { push_back(s);
return(*
this); }
1229 {
return(
String(s1) + s2); }
1232 {
String t; t += c; t += s;
return(t); }
1235 { s.
write(stream);
return(stream); }
1239 #endif // __ccxx_String_hxx String & operator+=(uint_t val)
Append a string representation of an unsigned integer value onto the end of the string.
Definition: String.h++:1015
String & operator+=(const String &str)
Append a string onto the end of this string.
Definition: String.h++:988
StringVec & operator<<(String s)
Append operator.
Definition: String.h++:1167
String & operator<<(const double &val)
Append operator.
Definition: String.h++:1090
bool containsAnyOf(const char *chars) const
Determine if the string contains any character in a given set of characters.
Definition: String.h++:745
A String vector.
Definition: String.h++:1159
String & prepend(char16_t c)
Prepend a character to the beginning of the string.
Definition: String.h++:544
static const String empty
The empty string.
Definition: String.h++:1134
String & operator<<(uint_t val)
Append operator.
Definition: String.h++:1078
String & operator^=(char16_t c)
Prepend operator.
Definition: String.h++:1098
String & operator+=(const Char &c)
Append a character onto the end of the string.
Definition: String.h++:972
String & operator^=(const char *str)
Prepend operator.
Definition: String.h++:1106
String & append(const String &str, uint_t count=0)
Append a string to the end of the string.
Definition: String.h++:498
const TimeSpan operator+(const TimeSpan &s1, const TimeSpan &s2)
Definition: TimeSpan.c++:362
bool operator<=(const Blob &b1, const Blob &b2)
Definition: Blob.h++:356
String & operator<<(const Char &c)
Append operator.
Definition: String.h++:1070
String & operator+=(double val)
Append a string representation of double-precision floating point value onto the end of the string...
Definition: String.h++:1024
bool operator==(const Blob &b1, const Blob &b2)
Definition: Blob.h++:344
String & operator+=(uint64_t val)
Append a string representation of an unsigned long long (64-bit) integer onto the end of the string...
Definition: String.h++:1042
uint32_t char32_t
A UTF-32 character.
Definition: Common.h++:207
unsigned int uint_t
An alias for unsigned int.
Definition: Integers.h++:74
bool operator!() const
Unary NOT operator.
Definition: String.h++:948
String & operator+=(const char *str)
Append a C string onto the end of this string.
Definition: String.h++:980
String & append(char16_t c)
Append a UTF-16 character to the end of the string.
Definition: String.h++:418
String & operator+=(char16_t c)
Append a UTF-16 character onto the end of the string.
Definition: String.h++:964
String & insert(const wchar_t *str, uint_t index=0, uint_t count=0)
Insert a C wide string to this string.
Definition: String.h++:382
void write(std::ostream &stream) const
Write the string (in UTF-8 form) to a stream.
Definition: String.c++:1482
int compareTo(const String &other, bool ignoreCase=false) const
Compare the string to another.
Definition: String.c++:420
static const uint_t END
A pseudo-index indicating the end of the string.
Definition: String.h++:1125
bool contains(const String &str) const
Determine if the string contains a given substring.
Definition: String.h++:734
String & prepend(const char *str, uint_t count=0)
Prepend a string to the beginning of the string.
Definition: String.h++:582
static const String whitespaceChars
The set of whitespace delimiter characters.
Definition: String.h++:1137
String & prepend(char c)
Prepend a character to the beginning of the string.
Definition: String.h++:536
String & operator+=(int val)
Append a string representation of an integer value onto the end of the string.
Definition: String.h++:1006
String & operator=(const std::string &other)
Assignment operator.
Definition: String.h++:893
String & operator<<(const uint64_t &val)
Append operator.
Definition: String.h++:1086
String & append(const Char &c)
Append a character to the end of the string.
Definition: String.h++:488
String & prepend(const wchar_t *str, uint_t count=0)
Prepend a wide string to the beginning of the string.
Definition: String.h++:592
std::ostream & operator<<(std::ostream &stream, const BitSet &bs)
Definition: BitSet.h++:383
String operator()(uint_t fromIndex, uint_t toIndex=END) const
Substring operator.
Definition: String.h++:939
String & operator<<(const int64_t &val)
Append operator.
Definition: String.h++:1082
int indexOf(const char *str, uint_t fromIndex=0) const
Find the first occurrence of a given string in this string.
Definition: String.h++:659
char16_t value_type
Definition: String.h++:54
String & operator^=(const wchar_t *str)
Prepend operator.
Definition: String.h++:1110
String & operator<<(char c)
Append operator.
Definition: String.h++:1062
String & clear()
Clear the string.
Definition: String.h++:232
#define COMMONCPP_API
Definition: Common.h++:126
String & operator<<(int val)
Append operator.
Definition: String.h++:1074
String & trimEnd(const String &chars=whitespaceChars)
Trim characters from the end of the string.
Definition: String.h++:306
String & append(const wchar_t *str, uint_t count=0)
Append a wide string to the end of the string.
Definition: String.h++:528
String & operator+=(int64_t val)
Append a string representation of a long long (64-bit) integer onto the end of the string...
Definition: String.h++:1033
String & prepend(const char16_t *str, uint_t count=0)
Prepend a string to the beginning of the string.
Definition: String.h++:572
String & operator+=(char c)
Append a character onto the end of the string.
Definition: String.h++:956
bool operator!=(const Blob &b1, const Blob &b2)
Definition: Blob.h++:347
A class representing a UTF-16 character.
Definition: Char.h++:33
A flexible, reference counted, copy-on-write, thread-safe, nullable string.
Definition: String.h++:50
An implicitly shared, reference-counted container for an immutable, NUL-terminated C string...
Definition: CString.h++:39
String & operator<<(const String &str)
Append operator.
Definition: String.h++:1054
StringVec()
Definition: String.h++:1163
String & prepend(const String &str, uint_t count=0)
Prepend a string to the beginning of the string.
Definition: String.h++:562
uint_t length() const
Get the length of the string.
Definition: String.h++:194
bool operator<(const Blob &b1, const Blob &b2)
Definition: Blob.h++:350
String & prepend(const Char &c)
Prepend a character to the beginning of the string.
Definition: String.h++:552
uint16_t char16_t
A UTF-16 character.
Definition: Common.h++:201
String & append(char c)
Append a character to the end of the string.
Definition: String.h++:410
static const StringVec emptyVec
An empty StringVec.
Definition: String.h++:1171
String & insert(const char *str, uint_t index=0, uint_t count=0)
Insert a C string to this string.
Definition: String.h++:394
String & append(const char16_t *str, uint_t count=0)
Append a UTF-16 character array to the end of the string.
Definition: String.h++:508
String & operator+=(bool val)
Append a string representation of a boolean value onto the end of the string.
Definition: String.h++:997
bool operator>=(const Blob &b1, const Blob &b2)
Definition: Blob.h++:359
static const String null
The null string.
Definition: String.h++:1128
String & operator^=(const String &str)
Prepend operator.
Definition: String.h++:1114
String & operator^=(char c)
Prepend operator.
Definition: String.h++:1094
String & trimBegin(const String &chars=whitespaceChars)
Trim characters from the beginning of the string.
Definition: String.h++:297
String & append(const char *str, uint_t count=0)
Append a string to the end of the string.
Definition: String.h++:518
Definition: AllocationMap.c++:25
static const String nullRep
The string representation of the null value.
Definition: String.h++:1131
const char16_t * const_iterator
Definition: String.h++:55
bool operator>(const Blob &b1, const Blob &b2)
Definition: Blob.h++:353
String & operator<<(char16_t c)
Append operator.
Definition: String.h++:1066
String & operator<<(const wchar_t *str)
Append operator.
Definition: String.h++:1050
bool contains(const Char &c) const
Determine if the string contains a given character.
Definition: String.h++:724
String & operator<<(bool val)
Append operator.
Definition: String.h++:1058
String & operator^=(const Char &c)
Prepend operator.
Definition: String.h++:1102
String & operator<<(const char *str)
Append operator.
Definition: String.h++:1046