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
74 virtual void* create(
bool =
true,
bool empty =
false)
const;
154 String(
const string&
string);
159 #ifdef BALL_STD_STRING_HAS_RVALUE_REFERENCES
170 String& operator=(
string&& s);
174 explicit String(
const QString&
string);
177 explicit String(
const QByteArray&
string);
207 String(
Size buffer_size,
const char* format, ... );
214 #ifdef BALL_HAS_SSTREAM
215 String(std::stringstream& s);
217 String(std::strstream& s);
225 String(
const unsigned char uc);
231 String(
unsigned short us);
245 #ifdef BALL_ALLOW_LONG64_TYPE_OVERLOADS
266 virtual void clear();
274 void set(
const String& s);
287 void set(
const char* char_ptr,
Index from = 0,
Size len = EndPos);
293 void set(
Size buffer_size,
const char *format, ...);
298 #ifdef BALL_HAS_SSTREAM
299 void set(std::stringstream& s);
301 void set(std::strstream& s);
305 void set(
char c,
Size len = 1);
308 void set(
unsigned char uc);
314 void set(
unsigned short us);
320 void set(
unsigned int ui);
326 void set(
unsigned long ul);
328 #ifdef BALL_ALLOW_LONG64_TYPE_OVERLOADS
351 void get(
char* char_ptr,
Index from = 0,
Size len = EndPos)
const;
359 const String& operator = (
const char* pc);
364 #ifdef BALL_HAS_SSTREAM
365 const String& operator = (std::stringstream& s);
367 const String& operator = (std::strstream& s);
371 const String& operator = (
char c);
374 const String& operator = (
unsigned char uc);
377 const String& operator = (
short s);
380 const String& operator = (
unsigned short us);
383 const String& operator = (
int i);
386 const String& operator = (
unsigned int ui);
389 const String& operator = (
long l);
392 const String& operator = (
unsigned long ul);
394 #ifdef BALL_ALLOW_LONG64_TYPE_OVERLOADS
403 const String& operator = (
float f);
406 const String& operator = (
double d);
415 static void setCompareMode(
CompareMode compare_mode);
436 unsigned char toUnsignedChar()
const;
441 short toShort()
const;
446 unsigned short toUnsignedShort()
const;
456 unsigned int toUnsignedInt()
const;
466 unsigned long toUnsignedLong()
const;
471 float toFloat()
const;
476 double toDouble()
const;
488 void toLower(
Index from = 0,
Size len = EndPos);
494 void toUpper(
Index from = 0,
Size len = EndPos);
537 Size countFields(
const char* delimiters = CHARACTER_CLASS__WHITESPACE)
const;
542 Size countFieldsQuoted(
const char* delimiters = CHARACTER_CLASS__WHITESPACE,
543 const char* quotes = CHARACTER_CLASS__QUOTES)
const;
549 String getField(
Index index,
const char* delimiters = CHARACTER_CLASS__WHITESPACE,
Index* from = 0)
const;
555 String getFieldQuoted(
Index index,
const char* delimiters = CHARACTER_CLASS__WHITESPACE,
556 const char* quotes = CHARACTER_CLASS__QUOTES,
Index* from = 0)
const;
562 Size split(
String string_array[],
Size array_size,
const char* delimiters = CHARACTER_CLASS__WHITESPACE,
Index from = 0)
const;
569 Size split(std::vector<String>& strings,
const char* delimiters = CHARACTER_CLASS__WHITESPACE,
Index from = 0)
const;
578 Size splitQuoted(std::vector<String>& strings,
const char* delimiters = CHARACTER_CLASS__WHITESPACE,
579 const char* quotes = CHARACTER_CLASS__QUOTES,
Index from = 0)
const;
592 String& trimLeft(
const char* trimmed = CHARACTER_CLASS__WHITESPACE);
600 String& trimRight(
const char* trimmed = CHARACTER_CLASS__WHITESPACE);
605 String& trim(
const char* trimmed = CHARACTER_CLASS__WHITESPACE);
611 String trim(
const char* trimmed = CHARACTER_CLASS__WHITESPACE)
const;
669 #ifdef BALL_STD_STRING_HAS_RVALUE_REFERENCES
732 void substituteAll(
const String& to_replace,
const String& replacing);
741 bool has(
char c)
const;
744 bool hasSubstring(
const String& s,
Index from = 0)
const;
747 bool hasPrefix(
const String& s)
const;
750 bool hasSuffix(
const String& s)
const;
753 bool isEmpty()
const;
758 bool isAlpha()
const;
763 bool isAlnum()
const;
768 bool isDigit()
const;
774 bool isFloat()
const;
779 bool isSpace()
const;
785 bool isWhitespace()
const;
788 static bool isAlpha(
char c);
791 static bool isAlnum(
char c);
794 static bool isDigit(
char c);
797 static bool isSpace(
char c);
802 static bool isWhitespace(
char c);
840 int compare(
const char* char_ptr,
Index from = 0)
const;
856 bool operator == (
const String&
string)
const;
859 bool operator != (
const String&
string)
const;
862 bool operator < (
const String&
string)
const;
865 bool operator <= (
const String&
string)
const;
868 bool operator >= (
const String&
string)
const;
871 bool operator > (
const String&
string)
const;
877 friend bool operator == (
const char* char_ptr,
const String&
string);
883 friend bool operator != (
const char* char_ptr,
const String&
string);
889 friend bool operator < (
const char* char_ptr,
const String&
string);
895 friend bool operator <= (
const char* char_ptr,
const String&
string);
901 friend bool operator > (
const char* char_ptr,
const String&
string);
907 friend bool operator >= (
const char* char_ptr,
const String&
string);
912 bool operator == (
const char* char_ptr)
const;
917 bool operator != (
const char* char_ptr)
const;
922 bool operator < (
const char* char_ptr)
const;
927 bool operator <= (
const char* char_ptr)
const;
932 bool operator > (
const char* char_ptr)
const;
937 bool operator >= (
const char* char_ptr)
const;
941 friend bool operator == (
char c,
const String&
string);
945 friend bool operator != (
char c,
const String&
string);
949 friend bool operator < (
char c,
const String&
string);
953 friend bool operator <= (
char c,
const String&
string);
957 friend bool operator > (
char c,
const String&
string);
960 friend bool operator >= (
char c,
const String&
string);
963 bool operator == (
char c)
const;
966 bool operator != (
char c)
const;
969 bool operator < (
char c)
const;
972 bool operator <= (
char c)
const;
975 bool operator > (
char c)
const;
978 bool operator >= (
char c)
const;
986 bool isValid()
const;
989 void dump(std::ostream& s = std::cout,
Size depth = 0)
const;
997 std::istream& getline(std::istream& s = std::cin,
char delimiter =
'\n');
1001 friend std::istream& getline(std::istream& s,
String&
string,
char delimiter =
'\n');
1016 void validateIndex_(
Index& index)
const;
1018 void validateRange_(
Index& from,
Size& len)
const;
1020 static void validateCharPtrRange_(
Index& from,
Size& len,
const char* char_ptr);
1022 static void valudateCharPtrIndex_(
Index& index);
1026 static int compareAscendingly_(
const char* a,
const char* b);
1028 static int compareDescendingly_(
const char* a,
const char* b);
1032 static char B64Chars_[64];
1034 static int Index_64_[128];
1062 : public Exception::GeneralException
1121 virtual void clear();
1166 String* getBoundString();
1169 const String* getBoundString()
const
1180 void set(
const String&
string);
1208 const Substring& operator = (
const char* char_ptr);
1223 const char* c_str()
const;
1229 Index getFirstIndex()
const;
1235 Index getLastIndex()
const;
1245 char& operator [] (
Index index);
1252 char operator [] (
Index index)
const;
1270 bool isBound()
const;
1273 bool isEmpty()
const;
1283 bool operator == (
const Substring& substring)
const;
1288 bool operator != (
const Substring& substring)
const;
1293 bool operator == (
const String&
string)
const;
1298 bool operator != (
const String&
string)
const;
1304 friend bool operator == (
const String&
string,
const Substring& substring);
1310 friend bool operator != (
const String&
string,
const Substring& substring);
1316 bool operator == (
const char* char_ptr)
const;
1322 bool operator != (
const char* char_ptr)
const;
1327 bool operator == (
char c)
const;
1332 bool operator != (
char c)
const;
1352 bool isValid()
const;
1357 void dump(std::ostream& s = std::cout,
Size depth = 0)
const;
1364 void validateRange_(
Index& from,
Size& len)
const;
1385 # ifndef BALL_NO_INLINE_FUNCTIONS
1386 # include <BALL/DATATYPE/string.iC>
1390 #endif // BALL_DATATYPE_STRING_H
static const char * CHARACTER_CLASS__ASCII_UPPER
Character class containing all upper case letters.
static const char * CHARACTER_CLASS__ASCII_FLOAT
Character class containing the digits from 0 to 9 and a dot.
BALL_EXPORT std::ostream & operator<<(std::ostream &os, const Exception::GeneralException &e)
BALL_EXTERN_VARIABLE const double c
static const char * CHARACTER_CLASS__ASCII_ALPHA
Character class containing all letters (lower and upper case)
static const String EMPTY
Constant empty string.
#define BALL_CREATE_DEEP(name)
BALL_ULONG64_TYPE LongSize
BALL_LONG64_TYPE LongIndex
static const char * CHARACTER_CLASS__WHITESPACE
static const char * CHARACTER_CLASS__QUOTES
static const char * CHARACTER_CLASS__ASCII_ALPHANUMERIC
Character class containing all letters and digits.
ConstRandomAccessIterator< Container, DataType, Position, Traits > operator+(Distance distance, const ConstRandomAccessIterator< Container, DataType, Position, Traits > &iterator)
static const char * CHARACTER_CLASS__ASCII_LOWER
Character class containing all lower case letters.
static const char * CHARACTER_CLASS__ASCII_NUMERIC
Character class containing the digits from 0 to 9.
Index compare(const T1 &a, const T2 &b)