49 static bool replace( std::string & s ,
50 const std::string & from ,
const std::string & to ,
51 size_type * pos_p = NULL ) ;
56 static unsigned int replaceAll( std::string & s ,
const std::string & from ,
const std::string & to ) ;
62 static unsigned int replaceAll( std::string & s ,
const char * from ,
const char * to ) ;
65 static void removeAll( std::string & ,
char ) ;
68 static void trimLeft( std::string & s ,
const std::string &
ws , size_type limit = 0U ) ;
71 static void trimRight( std::string & s ,
const std::string &
ws , size_type limit = 0U ) ;
74 static void trim( std::string & s ,
const std::string &
ws ) ;
77 static std::string
trimmed(
const std::string & s ,
const std::string &
ws ) ;
80 static bool isNumeric(
const std::string & s ,
bool allow_minus_sign =
false ) ;
88 static bool isUShort(
const std::string & s ) ;
92 static bool isUInt(
const std::string & s ) ;
96 static bool isULong(
const std::string & s ) ;
100 static std::string
fromBool(
bool b ) ;
106 static std::string
fromInt(
int i ) ;
109 static std::string
fromLong(
long l ) ;
112 static std::string
fromShort(
short s ) ;
115 static std::string
fromUInt(
unsigned int ui ) ;
118 static std::string
fromULong(
unsigned long ul ) ;
121 static std::string
fromUShort(
unsigned short us ) ;
124 static bool toBool(
const std::string & s ) ;
129 static double toDouble(
const std::string & s ) ;
135 static int toInt(
const std::string & s ) ;
141 static long toLong(
const std::string & s ) ;
147 static short toShort(
const std::string & s ) ;
153 static unsigned int toUInt(
const std::string & s ,
bool limited =
false ) ;
163 static unsigned long toULong(
const std::string & s ,
bool limited =
false ) ;
173 static unsigned short toUShort(
const std::string & s ,
bool limited =
false ) ;
183 static void toUpper( std::string & s ) ;
187 static void toLower( std::string & s ) ;
191 static std::string
upper(
const std::string & s ) ;
195 static std::string
lower(
const std::string & s ) ;
208 static std::string
printable(
const std::string & in ,
char escape =
'\\' ) ;
212 static void escape( std::string & ,
const std::string & specials ,
char escape =
'\\' ) ;
216 static std::string
escaped(
const std::string & ,
const std::string & specials ,
char escape =
'\\' ) ;
220 static std::string
readLineFrom( std::istream & stream ,
const std::string & eol = std::string() ) ;
245 static void readLineFrom( std::istream & stream ,
const std::string & eol , std::string & result ,
246 bool pre_erase_result =
true ) ;
249 static std::string
wrap( std::string text ,
250 const std::string & prefix_first_line ,
const std::string & prefix_subsequent_lines ,
251 size_type width = 70U ) ;
265 const std::string & seperators ,
char escape =
'\0' ,
266 bool discard_bogus_escapes =
true ) ;
280 const std::string & seperators ,
char escape =
'\0' ,
bool discard_bogus_escapes =
true ) ;
283 static std::string
join(
const Strings & strings ,
const std::string & sep ) ;
286 static std::string
join(
const StringArray & strings ,
const std::string & sep ) ;
293 const std::string & default_ = std::string() ) ;
299 const std::string & default_ = std::string() ) ;
304 static bool tailMatch(
const std::string & in ,
const std::string & ending ) ;
307 static std::string
ws() ;
311 static void readLineFromImp( std::istream & ,
const std::string & , std::string & ) ;
static std::string fromBool(bool b)
Converts boolean 'b' to a string.
std::string::size_type size_type
static std::string printable(const std::string &in, char escape= '\\')
Returns a printable represention of the given input string.
static bool toBool(const std::string &s)
Converts string 's' to a bool.
static unsigned int toUInt(const std::string &s, bool limited=false)
Converts string 's' to an unsigned int.
static int toInt(const std::string &s)
Converts string 's' to an int.
std::list< std::string > Strings
A std::list of std::strings.
static std::string wrap(std::string text, const std::string &prefix_first_line, const std::string &prefix_subsequent_lines, size_type width=70U)
Does word-wrapping.
static bool tailMatch(const std::string &in, const std::string &ending)
Returns true if the given string has the given ending.
static void splitIntoFields(const std::string &in, Strings &out, const std::string &seperators, char escape= '\0', bool discard_bogus_escapes=true)
Splits the string into fields.
static void escape(std::string &, const std::string &specials, char escape= '\\')
Prefixes each occurrence of one of the special characters with the escape character.
static std::string fromDouble(double d)
Converts double 'd' to a string.
std::vector< std::string > StringArray
A std::vector of std::strings.
std::string::size_type size_type
A std::size_t type.
static void splitIntoTokens(const std::string &in, Strings &out, const std::string &ws)
Splits the string into 'ws'-delimited tokens.
static short toShort(const std::string &s)
Converts string 's' to a short.
static bool isNumeric(const std::string &s, bool allow_minus_sign=false)
Returns true if every character is a decimal digit.
static std::string fromInt(int i)
Converts int 'i' to a string.
static std::string tail(const std::string &in, std::string::size_type pos, const std::string &default_=std::string())
Returns the last part of the string after the given position.
static void trim(std::string &s, const std::string &ws)
Trims both ends of s, taking off any of the 'ws' characters.
static void trimLeft(std::string &s, const std::string &ws, size_type limit=0U)
Trims the lhs of s, taking off up to 'limit' of the 'ws' characters.
static std::string fromLong(long l)
Converts long 'l' to a string.
static std::string lower(const std::string &s)
Returns a copy of 's' in which all uppercase characters have been replaced by lowercase characters...
static void toLower(std::string &s)
Replaces all uppercase characters in string 's' by lowercase characters.
static Strings keys(const StringMap &string_map)
Extracts the keys from a map of strings.
static std::string fromUInt(unsigned int ui)
Converts unsigned int 'ui' to a string.
static bool replace(std::string &s, const std::string &from, const std::string &to, size_type *pos_p=NULL)
Replaces 'from' with 'to', starting at offset '*pos_p'.
static unsigned int replaceAll(std::string &s, const std::string &from, const std::string &to)
Does a global replace on string 's', replacing all occurences of sub-string 'from' with 'to'...
static std::string head(const std::string &in, std::string::size_type pos, const std::string &default_=std::string())
Returns the first part of the string up to just before the given position.
static void trimRight(std::string &s, const std::string &ws, size_type limit=0U)
Trims the rhs of s, taking off up to 'limit' of the 'ws' characters.
static double toDouble(const std::string &s)
Converts string 's' to a double.
static std::string fromShort(short s)
Converts short 's' to a string.
static bool isUShort(const std::string &s)
Returns true if the string can be converted into an unsigned short without throwing an exception...
static std::string upper(const std::string &s)
Returns a copy of 's' in which all lowercase characters have been replaced by uppercase characters...
static std::string fromUShort(unsigned short us)
Converts unsigned short 'us' to a string.
static std::string escaped(const std::string &, const std::string &specials, char escape= '\\')
Prefixes each occurrence of one of the special characters with the escape character.
static std::string trimmed(const std::string &s, const std::string &ws)
Returns a trim()med version of s.
static std::string readLineFrom(std::istream &stream, const std::string &eol=std::string())
Reads a line from the stream using the given line terminator.
static bool isPrintableAscii(const std::string &s)
Returns true if every character is a 7-bit, non-control character (ie.
std::map< std::string, std::string > StringMap
A std::map of std::strings.
A static class which provides string helper functions.
static long toLong(const std::string &s)
Converts string 's' to a long.
static unsigned short toUShort(const std::string &s, bool limited=false)
Converts string 's' to an unsigned short.
static unsigned long toULong(const std::string &s, bool limited=false)
Converts string 's' to an unsigned long.
static bool isUInt(const std::string &s)
Returns true if the string can be converted into an unsigned integer without throwing an exception...
static void removeAll(std::string &, char)
Removes all occurrences of the character from the string.
static bool isULong(const std::string &s)
Returns true if the string can be converted into an unsigned long without throwing an exception...
static std::string fromULong(unsigned long ul)
Converts unsigned long 'ul' to a string.
static std::string join(const Strings &strings, const std::string &sep)
Concatenates a set of strings.
static std::string ws()
A convenience function returning standard whitespace characters.
static std::string toPrintableAscii(char c, char escape= '\\')
Returns a 7-bit printable representation of the given input character.
#define G_EXCEPTION_CLASS(class_name, description)
static void toUpper(std::string &s)
Replaces all lowercase characters in string 's' by uppercase characters.