7 #ifndef BALL_DATATYPE_STRING_H
8 #define BALL_DATATYPE_STRING_H
10 #ifndef BALL_CONFIG_CONFIG_H
11 # include <BALL/CONFIG/config.h>
13 #ifndef BALL_COMMON_GLOBAL_H
16 #ifndef BALL_COMMON_CREATE_H
19 #ifndef BALL_COMMON_MACROS_H
22 #ifndef BALL_COMMON_EXCEPTION_H
25 #ifndef BALL_COMMON_DEBUG_H
37 #ifdef BALL_HAS_SSTREAM
76 virtual void* create(
bool =
true,
bool empty =
false)
const;
156 String(
const string&
string);
161 #ifdef BALL_STD_STRING_HAS_RVALUE_REFERENCES
172 String& operator=(
string&& s);
176 explicit String(
const QString&
string);
179 explicit String(
const QByteArray&
string);
209 String(
Size buffer_size,
const char* format, ... );
216 #ifdef BALL_HAS_SSTREAM
217 String(std::stringstream& s);
219 String(std::strstream& s);
227 String(
const unsigned char uc);
233 String(
unsigned short us);
247 #ifdef BALL_ALLOW_LONG64_TYPE_OVERLOADS
268 virtual void clear();
276 void set(
const String& s);
289 void set(
const char* char_ptr,
Index from = 0,
Size len = EndPos);
295 void set(
Size buffer_size,
const char *format, ...);
300 #ifdef BALL_HAS_SSTREAM
301 void set(std::stringstream& s);
303 void set(std::strstream& s);
307 void set(
char c,
Size len = 1);
310 void set(
unsigned char uc);
316 void set(
unsigned short us);
322 void set(
unsigned int ui);
328 void set(
unsigned long ul);
330 #ifdef BALL_ALLOW_LONG64_TYPE_OVERLOADS
353 void get(
char* char_ptr,
Index from = 0,
Size len = EndPos)
const;
361 const String& operator = (
const char* pc);
366 #ifdef BALL_HAS_SSTREAM
367 const String& operator = (std::stringstream& s);
369 const String& operator = (std::strstream& s);
373 const String& operator = (
char c);
376 const String& operator = (
unsigned char uc);
379 const String& operator = (
short s);
382 const String& operator = (
unsigned short us);
385 const String& operator = (
int i);
388 const String& operator = (
unsigned int ui);
391 const String& operator = (
long l);
394 const String& operator = (
unsigned long ul);
396 #ifdef BALL_ALLOW_LONG64_TYPE_OVERLOADS
405 const String& operator = (
float f);
408 const String& operator = (
double d);
418 static void setCompareMode(
CompareMode compare_mode);
438 unsigned char toUnsignedChar()
const;
443 short toShort()
const;
448 unsigned short toUnsignedShort()
const;
458 unsigned int toUnsignedInt()
const;
468 unsigned long toUnsignedLong()
const;
473 float toFloat()
const;
478 double toDouble()
const;
490 void toLower(
Index from = 0,
Size len = EndPos);
496 void toUpper(
Index from = 0,
Size len = EndPos);
539 Size countFields(
const char* delimiters = CHARACTER_CLASS__WHITESPACE)
const;
544 Size countFieldsQuoted(
const char* delimiters = CHARACTER_CLASS__WHITESPACE,
545 const char* quotes = CHARACTER_CLASS__QUOTES)
const;
551 String getField(
Index index,
const char* delimiters = CHARACTER_CLASS__WHITESPACE,
Index* from = 0)
const;
557 String getFieldQuoted(
Index index,
const char* delimiters = CHARACTER_CLASS__WHITESPACE,
558 const char* quotes = CHARACTER_CLASS__QUOTES,
Index* from = 0)
const;
564 Size split(
String string_array[],
Size array_size,
const char* delimiters = CHARACTER_CLASS__WHITESPACE,
Index from = 0)
const;
571 Size split(std::vector<String>& strings,
const char* delimiters = CHARACTER_CLASS__WHITESPACE,
Index from = 0)
const;
580 Size splitQuoted(std::vector<String>& strings,
const char* delimiters = CHARACTER_CLASS__WHITESPACE,
581 const char* quotes = CHARACTER_CLASS__QUOTES,
Index from = 0)
const;
594 String& trimLeft(
const char* trimmed = CHARACTER_CLASS__WHITESPACE);
602 String& trimRight(
const char* trimmed = CHARACTER_CLASS__WHITESPACE);
607 String& trim(
const char* trimmed = CHARACTER_CLASS__WHITESPACE);
613 String trim(
const char* trimmed = CHARACTER_CLASS__WHITESPACE)
const;
671 #ifdef BALL_STD_STRING_HAS_RVALUE_REFERENCES
740 bool has(
char c)
const;
743 bool hasSubstring(
const String& s,
Index from = 0)
const;
746 bool hasPrefix(
const String& s)
const;
749 bool hasSuffix(
const String& s)
const;
752 bool isEmpty()
const;
757 bool isAlpha()
const;
762 bool isAlnum()
const;
767 bool isDigit()
const;
773 bool isFloat()
const;
778 bool isSpace()
const;
784 bool isWhitespace()
const;
787 static bool isAlpha(
char c);
790 static bool isAlnum(
char c);
793 static bool isDigit(
char c);
796 static bool isSpace(
char c);
801 static bool isWhitespace(
char c);
839 int compare(
const char* char_ptr,
Index from = 0)
const;
855 bool operator == (
const String&
string)
const;
858 bool operator != (
const String&
string)
const;
861 bool operator < (
const String&
string)
const;
864 bool operator <= (
const String&
string)
const;
867 bool operator >= (
const String&
string)
const;
870 bool operator > (
const String&
string)
const;
876 friend bool operator == (
const char* char_ptr,
const String&
string);
882 friend bool operator != (
const char* char_ptr,
const String&
string);
888 friend bool operator < (
const char* char_ptr,
const String&
string);
894 friend bool operator <= (
const char* char_ptr,
const String&
string);
900 friend bool operator > (
const char* char_ptr,
const String&
string);
906 friend bool operator >= (
const char* char_ptr,
const String&
string);
911 bool operator == (
const char* char_ptr)
const;
916 bool operator != (
const char* char_ptr)
const;
921 bool operator < (
const char* char_ptr)
const;
926 bool operator <= (
const char* char_ptr)
const;
931 bool operator > (
const char* char_ptr)
const;
936 bool operator >= (
const char* char_ptr)
const;
940 friend bool operator == (
char c,
const String&
string);
944 friend bool operator != (
char c,
const String&
string);
948 friend bool operator < (
char c,
const String&
string);
952 friend bool operator <= (
char c,
const String&
string);
956 friend bool operator > (
char c,
const String&
string);
959 friend bool operator >= (
char c,
const String&
string);
962 bool operator == (
char c)
const;
965 bool operator != (
char c)
const;
968 bool operator < (
char c)
const;
971 bool operator <= (
char c)
const;
974 bool operator > (
char c)
const;
977 bool operator >= (
char c)
const;
985 bool isValid()
const;
988 void dump(std::ostream& s = std::cout,
Size depth = 0)
const;
996 std::istream& getline(std::istream& s = std::cin,
char delimiter =
'\n');
1000 friend std::istream& getline(std::istream& s,
String&
string,
char delimiter =
'\n');
1015 void validateIndex_(
Index& index)
const;
1017 void validateRange_(
Index& from,
Size& len)
const;
1019 static void validateCharPtrRange_(
Index& from,
Size& len,
const char* char_ptr);
1021 static void valudateCharPtrIndex_(
Index& index);
1025 static int compareAscendingly_(
const char* a,
const char* b);
1027 static int compareDescendingly_(
const char* a,
const char* b);
1031 static char B64Chars_[64];
1033 static int Index_64_[128];
1061 : public Exception::GeneralException
1120 virtual void clear();
1165 String* getBoundString();
1168 const String* getBoundString()
const
1179 void set(
const String& string);
1207 const Substring& operator = (
const char* char_ptr);
1222 const char* c_str()
const;
1228 Index getFirstIndex()
const;
1234 Index getLastIndex()
const;
1244 char& operator [] (
Index index);
1251 char operator [] (
Index index)
const;
1269 bool isBound()
const;
1272 bool isEmpty()
const;
1282 bool operator == (
const Substring& substring)
const;
1287 bool operator != (
const Substring& substring)
const;
1292 bool operator == (
const String&
string)
const;
1297 bool operator != (
const String&
string)
const;
1303 friend bool operator == (
const String&
string,
const Substring& substring);
1309 friend bool operator != (
const String&
string,
const Substring& substring);
1315 bool operator == (
const char* char_ptr)
const;
1321 bool operator != (
const char* char_ptr)
const;
1326 bool operator == (
char c)
const;
1331 bool operator != (
char c)
const;
1351 bool isValid()
const;
1356 void dump(std::ostream& s = std::cout,
Size depth = 0)
const;
1363 void validateRange_(
Index& from,
Size& len)
const;
1384 # ifndef BALL_NO_INLINE_FUNCTIONS
1385 # include <BALL/DATATYPE/string.iC>
1389 #endif // BALL_DATATYPE_STRING_H