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
52 std::istream&
getline(std::istream& s, String&
string,
char delimiter =
'\n');
77 virtual void* create(
bool =
true,
bool empty =
false)
const;
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
269 virtual void clear();
277 void set(
const String& s);
290 void set(
const char* char_ptr,
Index from = 0,
Size len = EndPos);
296 void set(
Size buffer_size,
const char *format, ...);
301 #ifdef BALL_HAS_SSTREAM
302 void set(std::stringstream& s);
304 void set(std::strstream& s);
308 void set(
char c,
Size len = 1);
311 void set(
unsigned char uc);
317 void set(
unsigned short us);
323 void set(
unsigned int ui);
329 void set(
unsigned long ul);
331 #ifdef BALL_ALLOW_LONG64_TYPE_OVERLOADS
354 void get(
char* char_ptr,
Index from = 0,
Size len = EndPos)
const;
362 const String& operator = (
const char* pc);
367 #ifdef BALL_HAS_SSTREAM
368 const String& operator = (std::stringstream& s);
370 const String& operator = (std::strstream& s);
374 const String& operator = (
char c);
377 const String& operator = (
unsigned char uc);
380 const String& operator = (
short s);
383 const String& operator = (
unsigned short us);
386 const String& operator = (
int i);
389 const String& operator = (
unsigned int ui);
392 const String& operator = (
long l);
395 const String& operator = (
unsigned long ul);
397 #ifdef BALL_ALLOW_LONG64_TYPE_OVERLOADS
406 const String& operator = (
float f);
409 const String& operator = (
double d);
418 static void setCompareMode(
CompareMode compare_mode);
439 unsigned char toUnsignedChar()
const;
444 short toShort()
const;
449 unsigned short toUnsignedShort()
const;
459 unsigned int toUnsignedInt()
const;
469 unsigned long toUnsignedLong()
const;
474 float toFloat()
const;
479 double toDouble()
const;
491 void toLower(
Index from = 0,
Size len = EndPos);
497 void toUpper(
Index from = 0,
Size len = EndPos);
540 Size countFields(
const char* delimiters = CHARACTER_CLASS__WHITESPACE)
const;
545 Size countFieldsQuoted(
const char* delimiters = CHARACTER_CLASS__WHITESPACE,
546 const char* quotes = CHARACTER_CLASS__QUOTES)
const;
552 String getField(
Index index,
const char* delimiters = CHARACTER_CLASS__WHITESPACE,
Index* from = 0)
const;
558 String getFieldQuoted(
Index index,
const char* delimiters = CHARACTER_CLASS__WHITESPACE,
559 const char* quotes = CHARACTER_CLASS__QUOTES,
Index* from = 0)
const;
565 Size split(
String string_array[],
Size array_size,
const char* delimiters = CHARACTER_CLASS__WHITESPACE,
Index from = 0)
const;
572 Size split(std::vector<String>& strings,
const char* delimiters = CHARACTER_CLASS__WHITESPACE,
Index from = 0)
const;
581 Size splitQuoted(std::vector<String>& strings,
const char* delimiters = CHARACTER_CLASS__WHITESPACE,
582 const char* quotes = CHARACTER_CLASS__QUOTES,
Index from = 0)
const;
595 String& trimLeft(
const char* trimmed = CHARACTER_CLASS__WHITESPACE);
603 String& trimRight(
const char* trimmed = CHARACTER_CLASS__WHITESPACE);
608 String& trim(
const char* trimmed = CHARACTER_CLASS__WHITESPACE);
614 String trim(
const char* trimmed = CHARACTER_CLASS__WHITESPACE)
const;
672 #ifdef BALL_STD_STRING_HAS_RVALUE_REFERENCES
735 void substituteAll(
const String& to_replace,
const String& replacing);
744 bool has(
char c)
const;
747 bool hasSubstring(
const String& s,
Index from = 0)
const;
750 bool hasPrefix(
const String& s)
const;
753 bool hasSuffix(
const String& s)
const;
756 bool isEmpty()
const;
761 bool isAlpha()
const;
766 bool isAlnum()
const;
771 bool isDigit()
const;
777 bool isFloat()
const;
782 bool isSpace()
const;
788 bool isWhitespace()
const;
791 static bool isAlpha(
char c);
794 static bool isAlnum(
char c);
797 static bool isDigit(
char c);
800 static bool isSpace(
char c);
805 static bool isWhitespace(
char c);
843 int compare(
const char* char_ptr,
Index from = 0)
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;
874 bool operator > (
const String&
string)
const;
880 friend bool operator == (
const char* char_ptr,
const String&
string);
886 friend bool operator != (
const char* char_ptr,
const String&
string);
892 friend bool operator < (
const char* char_ptr,
const String&
string);
898 friend bool operator <= (
const char* char_ptr,
const String&
string);
904 friend bool operator > (
const char* char_ptr,
const String&
string);
910 friend bool operator >= (
const char* char_ptr,
const String&
string);
915 bool operator == (
const char* char_ptr)
const;
920 bool operator != (
const char* char_ptr)
const;
925 bool operator < (
const char* char_ptr)
const;
930 bool operator <= (
const char* char_ptr)
const;
935 bool operator > (
const char* char_ptr)
const;
940 bool operator >= (
const char* char_ptr)
const;
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);
960 friend bool operator > (
char c,
const String&
string);
963 friend bool operator >= (
char c,
const String&
string);
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;
981 bool operator >= (
char c)
const;
989 bool isValid()
const;
992 void dump(std::ostream& s = std::cout,
Size depth = 0)
const;
1000 std::istream&
getline(std::istream& s = std::cin,
char delimiter =
'\n');
1004 friend std::istream&
getline(std::istream& s,
String&
string,
char delimiter);
1019 void validateIndex_(
Index& index)
const;
1021 void validateRange_(
Index& from,
Size& len)
const;
1023 static void validateCharPtrRange_(
Index& from,
Size& len,
const char* char_ptr);
1025 static void valudateCharPtrIndex_(
Index& index);
1029 static int compareAscendingly_(
const char* a,
const char* b);
1031 static int compareDescendingly_(
const char* a,
const char* b);
1035 static char B64Chars_[64];
1037 static int Index_64_[128];
1065 : public Exception::GeneralException
1124 virtual void clear();
1169 String* getBoundString();
1172 const String* getBoundString()
const
1183 void set(
const String&
string);
1211 const Substring& operator = (
const char* char_ptr);
1226 const char* c_str()
const;
1232 Index getFirstIndex()
const;
1238 Index getLastIndex()
const;
1248 char& operator [] (
Index index);
1255 char operator [] (
Index index)
const;
1273 bool isBound()
const;
1276 bool isEmpty()
const;
1286 bool operator == (
const Substring& substring)
const;
1291 bool operator != (
const Substring& substring)
const;
1296 bool operator == (
const String&
string)
const;
1301 bool operator != (
const String&
string)
const;
1307 friend bool operator == (
const String&
string,
const Substring& substring);
1313 friend bool operator != (
const String&
string,
const Substring& substring);
1319 bool operator == (
const char* char_ptr)
const;
1325 bool operator != (
const char* char_ptr)
const;
1330 bool operator == (
char c)
const;
1335 bool operator != (
char c)
const;
1355 bool isValid()
const;
1360 void dump(std::ostream& s = std::cout,
Size depth = 0)
const;
1367 void validateRange_(
Index& from,
Size& len)
const;
1388 # ifndef BALL_NO_INLINE_FUNCTIONS
1389 # include <BALL/DATATYPE/string.iC>
1393 #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
-*- Mode: C++; tab-width: 2; -*-
BALL_EXPORT std::istream & getline(std::istream &s, String &string, char delimiter= '\n')
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)