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
35 #ifdef BALL_HAS_SSTREAM
73 virtual void* create(
bool =
true,
bool empty =
false)
const;
103 static const size_t npos = -1;
157 String(
const string&
string);
162 #ifdef BALL_STD_STRING_HAS_RVALUE_REFERENCES
173 String& operator=(
string&& s);
177 explicit String(
const QString&
string);
180 explicit String(
const QByteArray&
string);
210 String(
Size buffer_size,
const char* format, ... );
217 #ifdef BALL_HAS_SSTREAM
218 String(std::stringstream& s);
220 String(std::strstream& s);
228 String(
const unsigned char uc);
234 String(
unsigned short us);
248 #ifdef BALL_ALLOW_LONG64_TYPE_OVERLOADS
266 operator string const&()
const;
281 void set(
const String& s);
294 void set(
const char* char_ptr,
Index from = 0,
Size len = EndPos);
300 void set(
Size buffer_size,
const char *format, ...);
305 #ifdef BALL_HAS_SSTREAM
306 void set(std::stringstream& s);
308 void set(std::strstream& s);
312 void set(
char c,
Size len = 1);
315 void set(
unsigned char uc);
321 void set(
unsigned short us);
327 void set(
unsigned int ui);
333 void set(
unsigned long ul);
335 #ifdef BALL_ALLOW_LONG64_TYPE_OVERLOADS
358 void get(
char* char_ptr,
Index from = 0,
Size len = EndPos)
const;
366 const String& operator = (
const char* pc);
371 #ifdef BALL_HAS_SSTREAM
372 const String& operator = (std::stringstream& s);
374 const String& operator = (std::strstream& s);
378 const String& operator = (
char c);
381 const String& operator = (
unsigned char uc);
384 const String& operator = (
short s);
387 const String& operator = (
unsigned short us);
390 const String& operator = (
int i);
393 const String& operator = (
unsigned int ui);
396 const String& operator = (
long l);
399 const String& operator = (
unsigned long ul);
401 #ifdef BALL_ALLOW_LONG64_TYPE_OVERLOADS
410 const String& operator = (
float f);
413 const String& operator = (
double d);
422 static void setCompareMode(
CompareMode compare_mode);
443 unsigned char toUnsignedChar()
const;
448 short toShort()
const;
453 unsigned short toUnsignedShort()
const;
463 unsigned int toUnsignedInt()
const;
473 unsigned long toUnsignedLong()
const;
478 float toFloat()
const;
483 double toDouble()
const;
495 void toLower(
Index from = 0,
Size len = EndPos);
501 void toUpper(
Index from = 0,
Size len = EndPos);
544 Size countFields(
const char* delimiters = CHARACTER_CLASS__WHITESPACE)
const;
549 Size countFieldsQuoted(
const char* delimiters = CHARACTER_CLASS__WHITESPACE,
550 const char* quotes = CHARACTER_CLASS__QUOTES)
const;
556 String getField(
Index index,
const char* delimiters = CHARACTER_CLASS__WHITESPACE,
Index* from = 0)
const;
562 String getFieldQuoted(
Index index,
const char* delimiters = CHARACTER_CLASS__WHITESPACE,
563 const char* quotes = CHARACTER_CLASS__QUOTES,
Index* from = 0)
const;
569 Size split(
String string_array[],
Size array_size,
const char* delimiters = CHARACTER_CLASS__WHITESPACE,
Index from = 0)
const;
576 Size split(std::vector<String>& strings,
const char* delimiters = CHARACTER_CLASS__WHITESPACE,
Index from = 0)
const;
585 Size splitQuoted(std::vector<String>& strings,
const char* delimiters = CHARACTER_CLASS__WHITESPACE,
586 const char* quotes = CHARACTER_CLASS__QUOTES,
Index from = 0)
const;
599 String& trimLeft(
const char* trimmed = CHARACTER_CLASS__WHITESPACE);
607 String& trimRight(
const char* trimmed = CHARACTER_CLASS__WHITESPACE);
612 String& trim(
const char* trimmed = CHARACTER_CLASS__WHITESPACE);
618 String trim(
const char* trimmed = CHARACTER_CLASS__WHITESPACE)
const;
676 #ifdef BALL_STD_STRING_HAS_RVALUE_REFERENCES
739 void substituteAll(
const String& to_replace,
const String& replacing);
748 bool has(
char c)
const;
751 bool hasSubstring(
const String& s,
Index from = 0)
const;
754 bool hasPrefix(
const String& s)
const;
757 bool hasSuffix(
const String& s)
const;
760 bool isEmpty()
const;
765 bool isAlpha()
const;
770 bool isAlnum()
const;
775 bool isDigit()
const;
781 bool isFloat()
const;
786 bool isSpace()
const;
792 bool isWhitespace()
const;
795 static bool isAlpha(
char c);
798 static bool isAlnum(
char c);
801 static bool isDigit(
char c);
804 static bool isSpace(
char c);
809 static bool isWhitespace(
char c);
847 int compare(
const char* char_ptr,
Index from = 0)
const;
1005 bool isValid()
const;
1008 void dump(std::ostream& s = std::cout,
Size depth = 0)
const;
1016 std::istream& getline(std::istream& s = std::cin,
char delimiter =
'\n');
1070 #ifdef BALL_HAS_STD_STRING_CONST_ITERATORS
1088 size_t size() const BALL_NOEXCEPT;
1090 size_t length() const BALL_NOEXCEPT;
1092 size_t max_size() const BALL_NOEXCEPT;
1094 void resize(
size_t n);
1096 void resize(
size_t n,
char c);
1098 size_t capacity() const BALL_NOEXCEPT;
1100 void reserve(
size_t n = 0);
1102 void clear() BALL_NOEXCEPT;
1104 bool empty() const BALL_NOEXCEPT;
1106 #ifdef BALL_HAS_STD_STRING_SHRINK_TO_FIT
1107 void shrink_to_fit();
1117 char& operator[] (
size_t pos);
1119 const char& operator[] (
size_t pos)
const;
1121 char& at(
size_t pos);
1123 const char& at(
size_t pos)
const;
1125 #ifdef BALL_HAS_STD_STRING_FRONT_BACK
1129 const char& front()
const;
1133 const char& back()
const;
1144 String& operator += (
const string& str);
1146 String& operator += (
const char* s);
1148 String& operator += (
char c);
1149 #ifdef BALL_HAS_INITIALIZER_LISTS
1150 String& operator += (std::initializer_list<char> il);
1156 String& append(
const string& str);
1158 String& append(
const string& str,
size_t subpos,
size_t sublen);
1160 String& append(
const char* s);
1162 String& append(
const char* s,
size_t n);
1164 String& append(
size_t n,
char c);
1166 template <
class InputIterator>
1167 String& append(InputIterator first, InputIterator last);
1168 #ifdef BALL_HAS_INITIALIZER_LISTS
1169 String& append(std::initializer_list<char> li);
1172 void push_back(
char c);
1177 String& assign(
const string& str);
1179 String& assign(
const string& str,
size_t subpos,
size_t sublen);
1181 String& assign(
const char* s);
1183 String& assign(
const char* s,
size_t n);
1185 String& assign(
size_t n,
char c);
1187 template <
class InputIterator>
1188 String& assign(InputIterator first, InputIterator last);
1189 #ifdef BALL_HAS_INITIALIZER_LISTS
1190 String& assign(std::initializer_list<char> li);
1193 #ifdef BALL_STD_STRING_HAS_RVALUE_REFERENCES
1194 String& assign(
string&& str) BALL_NOEXCEPT;
1199 String& insert(
size_t pos,
const string& str);
1201 String& insert(
size_t pos,
const string& str,
size_t subpos,
size_t sublen);
1203 String& insert(
size_t pos,
const char* s);
1205 String& insert(
size_t pos,
const char* s,
size_t n);
1207 String& insert(
size_t pos,
size_t n,
char c);
1208 #ifdef BALL_HAS_STD_STRING_CONST_ITERATOR_FUNCTIONS
1214 void insert(
iterator p,
size_t n,
char c);
1219 template <
class InputIterator>
1222 #if defined(BALL_HAS_INITIALIZER_LISTS) && defined(BALL_HAS_STD_STRING_CONST_ITERATOR_FUNCTIONS)
1228 String& erase(
size_t pos = 0,
size_t len = npos);
1229 #ifdef BALL_HAS_STD_STRING_CONST_ITERATOR_FUNCTIONS
1242 String& replace(
size_t pos,
size_t len,
const string& str);
1244 String& replace(
size_t pos,
size_t len,
const string& str,
size_t subpos,
size_t sublen);
1246 String& replace(
size_t pos,
size_t len,
const char* s);
1248 String& replace(
size_t pos,
size_t len,
const char* s,
size_t n);
1250 String& replace(
size_t pos,
size_t len,
size_t n,
char c);
1251 #ifdef BALL_HAS_STD_STRING_CONST_ITERATOR_FUNCTIONS
1261 template <
class InputIterator>
1273 template <
class InputIterator>
1276 #if defined(BALL_HAS_INITIALIZER_LISTS) && defined(BALL_HAS_STD_STRING_CONST_ITERATOR_FUNCTIONS)
1282 void swap(
string& str);
1284 #ifdef BALL_HAS_STD_STRING_POP_BACK
1295 const char* c_str() const BALL_NOEXCEPT;
1297 const
char* data() const BALL_NOEXCEPT;
1301 size_t copy(
char* s,
size_t len,
size_t pos = 0) const;
1304 size_t find(const
string& str,
size_t pos = 0) const BALL_NOEXCEPT;
1306 size_t find(const
char* s,
size_t pos = 0) const;
1308 size_t find(const
char* s,
size_t pos,
size_t n) const;
1310 size_t find(
char c,
size_t pos = 0) const BALL_NOEXCEPT;
1313 size_t rfind(const
string& str,
size_t pos = npos) const BALL_NOEXCEPT;
1315 size_t rfind(const
char* s,
size_t pos = npos) const;
1317 size_t rfind(const
char* s,
size_t pos,
size_t n) const;
1319 size_t rfind(
char c,
size_t pos = npos) const BALL_NOEXCEPT;
1322 size_t find_first_of(const
string& str,
size_t pos = 0) const BALL_NOEXCEPT;
1324 size_t find_first_of(const
char* s,
size_t pos = 0) const;
1326 size_t find_first_of(const
char* s,
size_t pos,
size_t n) const;
1328 size_t find_first_of(
char c,
size_t pos = 0) const BALL_NOEXCEPT;
1331 size_t find_last_of(const
string& str,
size_t pos = npos) const BALL_NOEXCEPT;
1333 size_t find_last_of(const
char* s,
size_t pos = npos) const;
1335 size_t find_last_of(const
char* s,
size_t pos,
size_t n) const;
1337 size_t find_last_of(
char c,
size_t pos = npos) const BALL_NOEXCEPT;
1340 size_t find_first_not_of(const
string& str,
size_t pos = 0) const BALL_NOEXCEPT;
1342 size_t find_first_not_of(const
char* s,
size_t pos = 0) const;
1344 size_t find_first_not_of(const
char* s,
size_t pos,
size_t n) const;
1346 size_t find_first_not_of(
char c,
size_t pos = 0) const BALL_NOEXCEPT;
1349 size_t find_last_not_of(const
string& str,
size_t pos = npos) const BALL_NOEXCEPT;
1351 size_t find_last_not_of(const
char* s,
size_t pos = npos) const;
1353 size_t find_last_not_of(const
char* s,
size_t pos,
size_t n) const;
1355 size_t find_last_not_of(
char c,
size_t pos = npos) const BALL_NOEXCEPT;
1358 string substr(
size_t pos = 0,
size_t len = npos) const;
1361 int compare(const
string& str) const BALL_NOEXCEPT;
1363 int compare(
size_t pos,
size_t len, const
string& str) const;
1365 int compare(
size_t pos,
size_t len, const
string& str,
size_t subpos,
size_t sublen) const;
1369 int compare(
size_t pos,
size_t len, const
char* s) const;
1371 int compare(
size_t pos,
size_t len, const
char* s,
size_t n) const;
1385 void validateIndex_(
Index& index) const;
1387 void validateRange_(
Index& from,
Size& len) const;
1389 static
void validateCharPtrRange_(
Index& from,
Size& len, const
char* char_ptr);
1391 static
void valudateCharPtrIndex_(
Index& index);
1398 static
int compareAscendingly_(const
char* a, const
char* b);
1400 static
int compareDescendingly_(const
char* a, const
char* b);
1404 static
char B64Chars_[64];
1406 static
int Index_64_[128];
1434 : public Exception::GeneralException
1467 Substring(
const Substring& substring,
bool deep =
true);
1481 virtual ~Substring();
1493 virtual void clear();
1544 String* getBoundString();
1547 const String* getBoundString()
const
1558 void set(
const String&
string);
1563 void set(
const Substring& s);
1575 const Substring& operator = (
const String&
string);
1580 const Substring& operator = (
const Substring& substring);
1586 const Substring& operator = (
const char* char_ptr);
1601 const char* c_str()
const;
1607 Index getFirstIndex()
const;
1613 Index getLastIndex()
const;
1623 char& operator [] (
Index index);
1630 char operator [] (
Index index)
const;
1635 Substring& toLower();
1640 Substring& toUpper();
1648 bool isBound()
const;
1651 bool isEmpty()
const;
1661 bool operator == (
const Substring& substring)
const;
1666 bool operator != (
const Substring& substring)
const;
1719 friend std::ostream&
operator << (std::ostream& s,
const Substring& substring);
1730 bool isValid()
const;
1735 void dump(std::ostream& s = std::cout,
Size depth = 0)
const;
1742 void validateRange_(
Index& from,
Size& len)
const;
1821 #ifdef BALL_STD_STRING_HAS_RVALUE_REFERENCES
1879 istream& getline(istream& is,
BALL::String& str,
char delim);
1884 #ifdef BALL_STD_STRING_HAS_RVALUE_REFERENCES
1885 istream& getline(istream& is,
BALL::String&& str,
char delim);
1894 # ifndef BALL_NO_INLINE_FUNCTIONS
1895 # include <BALL/DATATYPE/string.iC>
1898 #endif // BALL_DATATYPE_STRING_H
static const char * CHARACTER_CLASS__ASCII_LOWER
Character class containing all lower case letters.
static const char * CHARACTER_CLASS__ASCII_ALPHA
Character class containing all letters (lower and upper case)
string::const_reverse_iterator const_reverse_iterator
static const char * CHARACTER_CLASS__QUOTES
static const String EMPTY
Constant empty string.
static const char * CHARACTER_CLASS__ASCII_FLOAT
Character class containing the digits from 0 to 9 and a dot.
string::difference_type difference_type
std::istream & operator>>(std::istream &is, TRegularData1D< ValueType > &grid)
Input operator.
static const char * CHARACTER_CLASS__ASCII_ALPHANUMERIC
Character class containing all letters and digits.
BALL_EXPORT std::ostream & operator<<(std::ostream &os, const Exception::GeneralException &e)
BALL_EXPORT bool operator>(const String &s1, const String &s2)
string::iterator iterator
BALL_EXTERN_VARIABLE const double c
string::const_iterator const_iterator
static const char * CHARACTER_CLASS__ASCII_UPPER
Character class containing all upper case letters.
BALL_EXPORT bool operator!=(const String &s1, const String &s2)
string::const_pointer const_pointer
#define BALL_CREATE_DEEP(name)
BALL_ULONG64_TYPE LongSize
string::allocator_type allocator_type
BALL_LONG64_TYPE LongIndex
static const char * CHARACTER_CLASS__WHITESPACE
BALL_EXPORT bool operator>=(const String &s1, const String &s2)
string::traits_type traits_type
BALL_EXPORT bool operator==(const String &s1, const String &s2)
static const char * CHARACTER_CLASS__ASCII_NUMERIC
Character class containing the digits from 0 to 9.
string::const_reference const_reference
BALL_EXPORT bool operator<=(const String &s1, const String &s2)
string::value_type valuetype
ConstRandomAccessIterator< Container, DataType, Position, Traits > operator+(Distance distance, const ConstRandomAccessIterator< Container, DataType, Position, Traits > &iterator)
string::reverse_iterator reverse_iterator
string::size_type size_type
string::reference reference
Index compare(const T1 &a, const T2 &b)
BALL_EXPORT bool operator<(const String &s1, const String &s2)