5 #ifndef BALL_DATATYPE_STRING_H
6 #define BALL_DATATYPE_STRING_H
8 #ifndef BALL_CONFIG_CONFIG_H
9 # include <BALL/CONFIG/config.h>
11 #ifndef BALL_COMMON_GLOBAL_H
14 #ifndef BALL_COMMON_CREATE_H
17 #ifndef BALL_COMMON_MACROS_H
20 #ifndef BALL_COMMON_EXCEPTION_H
23 #ifndef BALL_COMMON_DEBUG_H
68 virtual void* create(
bool =
true,
bool empty =
false)
const;
98 static const size_t npos = -1;
152 String(
const string&
string);
167 String& operator=(
string&& s);
170 explicit String(
const QString&
string);
173 explicit String(
const QByteArray&
string);
203 String(
Size buffer_size,
const char* format, ... );
210 String(std::stringstream& s);
217 String(
const unsigned char uc);
223 String(
unsigned short us);
237 #ifdef BALL_ALLOW_LONG64_TYPE_OVERLOADS
255 operator string const&()
const;
270 void set(
const String& s);
283 void set(
const char* char_ptr,
Index from = 0,
Size len = EndPos);
289 void set(
Size buffer_size,
const char *format, ...);
294 void set(std::stringstream& s);
297 void set(
char c,
Size len = 1);
300 void set(
unsigned char uc);
306 void set(
unsigned short us);
312 void set(
unsigned int ui);
318 void set(
unsigned long ul);
320 #ifdef BALL_ALLOW_LONG64_TYPE_OVERLOADS
343 void get(
char* char_ptr,
Index from = 0,
Size len = EndPos)
const;
351 const String& operator = (
const char* pc);
356 const String& operator = (std::stringstream& s);
359 const String& operator = (
char c);
362 const String& operator = (
unsigned char uc);
365 const String& operator = (
short s);
368 const String& operator = (
unsigned short us);
371 const String& operator = (
int i);
374 const String& operator = (
unsigned int ui);
377 const String& operator = (
long l);
380 const String& operator = (
unsigned long ul);
382 #ifdef BALL_ALLOW_LONG64_TYPE_OVERLOADS
391 const String& operator = (
float f);
394 const String& operator = (
double d);
403 static void setCompareMode(
CompareMode compare_mode);
424 unsigned char toUnsignedChar()
const;
429 short toShort()
const;
434 unsigned short toUnsignedShort()
const;
444 unsigned int toUnsignedInt()
const;
454 unsigned long toUnsignedLong()
const;
459 float toFloat()
const;
464 double toDouble()
const;
476 void toLower(
Index from = 0,
Size len = EndPos);
482 void toUpper(
Index from = 0,
Size len = EndPos);
525 Size countFields(
const char* delimiters = CHARACTER_CLASS__WHITESPACE)
const;
530 Size countFieldsQuoted(
const char* delimiters = CHARACTER_CLASS__WHITESPACE,
531 const char* quotes = CHARACTER_CLASS__QUOTES)
const;
537 String getField(
Index index,
const char* delimiters = CHARACTER_CLASS__WHITESPACE,
Index* from = 0)
const;
543 String getFieldQuoted(
Index index,
const char* delimiters = CHARACTER_CLASS__WHITESPACE,
544 const char* quotes = CHARACTER_CLASS__QUOTES,
Index* from = 0)
const;
550 Size split(
String string_array[],
Size array_size,
const char* delimiters = CHARACTER_CLASS__WHITESPACE,
Index from = 0)
const;
557 Size split(std::vector<String>& strings,
const char* delimiters = CHARACTER_CLASS__WHITESPACE,
Index from = 0)
const;
566 Size splitQuoted(std::vector<String>& strings,
const char* delimiters = CHARACTER_CLASS__WHITESPACE,
567 const char* quotes = CHARACTER_CLASS__QUOTES,
Index from = 0)
const;
580 String& trimLeft(
const char* trimmed = CHARACTER_CLASS__WHITESPACE);
588 String& trimRight(
const char* trimmed = CHARACTER_CLASS__WHITESPACE);
593 String& trim(
const char* trimmed = CHARACTER_CLASS__WHITESPACE);
599 String trim(
const char* trimmed = CHARACTER_CLASS__WHITESPACE)
const;
718 void substituteAll(
const String& to_replace,
const String& replacing);
727 bool has(
char c)
const;
730 bool hasSubstring(
const String& s,
Index from = 0)
const;
733 bool hasPrefix(
const String& s)
const;
736 bool hasSuffix(
const String& s)
const;
739 bool isEmpty()
const;
744 bool isAlpha()
const;
749 bool isAlnum()
const;
754 bool isDigit()
const;
760 bool isFloat()
const;
765 bool isSpace()
const;
771 bool isWhitespace()
const;
774 static bool isAlpha(
char c);
777 static bool isAlnum(
char c);
780 static bool isDigit(
char c);
783 static bool isSpace(
char c);
788 static bool isWhitespace(
char c);
826 int compare(
const char* char_ptr,
Index from = 0)
const;
984 bool isValid()
const;
987 void dump(std::ostream& s = std::cout,
Size depth = 0)
const;
995 std::istream&
getline(std::istream& s = std::cin,
char delimiter =
'\n');
1065 size_t size() const BALL_NOEXCEPT;
1067 size_t length() const BALL_NOEXCEPT;
1069 size_t max_size() const BALL_NOEXCEPT;
1071 void resize(
size_t n);
1073 void resize(
size_t n,
char c);
1075 size_t capacity() const BALL_NOEXCEPT;
1077 void reserve(
size_t n = 0);
1079 void clear() BALL_NOEXCEPT;
1081 bool empty() const BALL_NOEXCEPT;
1084 void shrink_to_fit();
1092 char& operator[] (
size_t pos);
1094 const
char& operator[] (
size_t pos) const;
1096 char& at(
size_t pos);
1098 const
char& at(
size_t pos) const;
1103 const
char& front() const;
1107 const
char& back() const;
1116 String& operator += (const
string& str);
1118 String& operator += (const
char* s);
1123 String& operator += (std::initializer_list<
char> il);
1128 String& append(const
string& str);
1130 String& append(const
string& str,
size_t subpos,
size_t sublen);
1132 String& append(const
char* s);
1134 String& append(const
char* s,
size_t n);
1136 String& append(
size_t n,
char c);
1138 template <class InputIterator>
1139 String& append(InputIterator first, InputIterator last);
1142 String& append(std::initializer_list<
char> li);
1145 void push_back(
char c);
1149 String& assign(const
string& str);
1151 String& assign(const
string& str,
size_t subpos,
size_t sublen);
1153 String& assign(const
char* s);
1155 String& assign(const
char* s,
size_t n);
1157 String& assign(
size_t n,
char c);
1159 template <class InputIterator>
1160 String& assign(InputIterator first, InputIterator last);
1163 String& assign(std::initializer_list<
char> li);
1166 String& assign(
string&& str) BALL_NOEXCEPT;
1169 String& insert(
size_t pos, const
string& str);
1171 String& insert(
size_t pos, const
string& str,
size_t subpos,
size_t sublen);
1173 String& insert(
size_t pos, const
char* s);
1175 String& insert(
size_t pos, const
char* s,
size_t n);
1177 String& insert(
size_t pos,
size_t n,
char c);
1178 #ifdef BALL_HAS_STD_STRING_CONST_ITERATOR_FUNCTIONS
1184 void insert(
iterator p,
size_t n,
char c);
1189 template <
class InputIterator>
1192 #ifdef BALL_HAS_STD_STRING_CONST_ITERATOR_INITLIST_INSERT
1198 String& erase(
size_t pos = 0,
size_t len = npos);
1199 #ifdef BALL_HAS_STD_STRING_CONST_ITERATOR_FUNCTIONS
1212 String& replace(
size_t pos,
size_t len,
const string& str);
1214 String& replace(
size_t pos,
size_t len,
const string& str,
size_t subpos,
size_t sublen);
1216 String& replace(
size_t pos,
size_t len,
const char* s);
1218 String& replace(
size_t pos,
size_t len,
const char* s,
size_t n);
1220 String& replace(
size_t pos,
size_t len,
size_t n,
char c);
1221 #ifdef BALL_HAS_STD_STRING_CONST_ITERATOR_FUNCTIONS
1231 template <
class InputIterator>
1243 template <
class InputIterator>
1246 #ifdef BALL_HAS_STD_STRING_CONST_ITERATOR_FUNCTIONS
1252 void swap(
string& str);
1263 const char* c_str() const BALL_NOEXCEPT;
1265 const
char* data() const BALL_NOEXCEPT;
1269 size_t copy(
char* s,
size_t len,
size_t pos = 0) const;
1272 size_t find(const
string& str,
size_t pos = 0) const BALL_NOEXCEPT;
1274 size_t find(const
char* s,
size_t pos = 0) const;
1276 size_t find(const
char* s,
size_t pos,
size_t n) const;
1278 size_t find(
char c,
size_t pos = 0) const BALL_NOEXCEPT;
1281 size_t rfind(const
string& str,
size_t pos = npos) const BALL_NOEXCEPT;
1283 size_t rfind(const
char* s,
size_t pos = npos) const;
1285 size_t rfind(const
char* s,
size_t pos,
size_t n) const;
1287 size_t rfind(
char c,
size_t pos = npos) const BALL_NOEXCEPT;
1290 size_t find_first_of(const
string& str,
size_t pos = 0) const BALL_NOEXCEPT;
1292 size_t find_first_of(const
char* s,
size_t pos = 0) const;
1294 size_t find_first_of(const
char* s,
size_t pos,
size_t n) const;
1296 size_t find_first_of(
char c,
size_t pos = 0) const BALL_NOEXCEPT;
1299 size_t find_last_of(const
string& str,
size_t pos = npos) const BALL_NOEXCEPT;
1301 size_t find_last_of(const
char* s,
size_t pos = npos) const;
1303 size_t find_last_of(const
char* s,
size_t pos,
size_t n) const;
1305 size_t find_last_of(
char c,
size_t pos = npos) const BALL_NOEXCEPT;
1308 size_t find_first_not_of(const
string& str,
size_t pos = 0) const BALL_NOEXCEPT;
1310 size_t find_first_not_of(const
char* s,
size_t pos = 0) const;
1312 size_t find_first_not_of(const
char* s,
size_t pos,
size_t n) const;
1314 size_t find_first_not_of(
char c,
size_t pos = 0) const BALL_NOEXCEPT;
1317 size_t find_last_not_of(const
string& str,
size_t pos = npos) const BALL_NOEXCEPT;
1319 size_t find_last_not_of(const
char* s,
size_t pos = npos) const;
1321 size_t find_last_not_of(const
char* s,
size_t pos,
size_t n) const;
1323 size_t find_last_not_of(
char c,
size_t pos = npos) const BALL_NOEXCEPT;
1326 string substr(
size_t pos = 0,
size_t len = npos) const;
1329 int compare(const
string& str) const BALL_NOEXCEPT;
1331 int compare(
size_t pos,
size_t len, const
string& str) const;
1333 int compare(
size_t pos,
size_t len, const
string& str,
size_t subpos,
size_t sublen) const;
1337 int compare(
size_t pos,
size_t len, const
char* s) const;
1339 int compare(
size_t pos,
size_t len, const
char* s,
size_t n) const;
1353 void validateIndex_(
Index& index) const;
1355 void validateRange_(
Index& from,
Size& len) const;
1357 static
void validateCharPtrRange_(
Index& from,
Size& len, const
char* char_ptr);
1359 static
void valudateCharPtrIndex_(
Index& index);
1366 static
int compareAscendingly_(const
char* a, const
char* b);
1368 static
int compareDescendingly_(const
char* a, const
char* b);
1372 static
char B64Chars_[64];
1374 static
int Index_64_[128];
1402 : public Exception::GeneralException
1461 virtual void clear();
1512 String* getBoundString();
1515 const String* getBoundString()
const
1526 void set(
const String&
string);
1554 const Substring& operator = (
const char* char_ptr);
1569 const char* c_str()
const;
1575 Index getFirstIndex()
const;
1581 Index getLastIndex()
const;
1591 char& operator [] (
Index index);
1598 char operator [] (
Index index)
const;
1616 bool isBound()
const;
1619 bool isEmpty()
const;
1698 bool isValid()
const;
1703 void dump(std::ostream& s = std::cout,
Size depth = 0)
const;
1710 void validateRange_(
Index& from,
Size& len)
const;
1845 istream& getline(istream& is,
BALL::String& str,
char delim);
1851 istream& getline(istream& is,
BALL::String&& str,
char delim);
1858 # ifndef BALL_NO_INLINE_FUNCTIONS
1859 # include <BALL/DATATYPE/string.iC>
1862 #endif // BALL_DATATYPE_STRING_H