56 #ifndef _RNR_STRING_THEORY_H 57 #define _RNR_STRING_THEORY_H 98 inline std::string
okstr(
bool b)
100 return b?
"ok":
"not-ok";
110 inline std::string
space(
unsigned n)
112 return std::string(n,
' ');
124 size_t split(
const std::string &str,
const char delim, StringVec &elems);
134 StringVec
split(
const std::string &str,
const char delim);
143 inline std::string &
ltrim(std::string &str)
145 str.erase( str.begin(), std::find_if(str.begin(), str.end(),
146 std::not1(std::ptr_fun<int, int>(std::isspace))) );
157 inline std::string
ltrim(
const char *s)
170 inline std::string &
rtrim(std::string &str)
172 str.erase( std::find_if(str.rbegin(), str.rend(),
173 std::not1(std::ptr_fun<int, int>(std::isspace))).base(), str.end() );
184 inline std::string
rtrim(
const char *s)
197 inline std::string &
trim(std::string &str)
209 inline std::string
trim(
const char *s)
226 extern std::string &
replace(
const std::string &what,
227 const std::string &with,
241 inline std::string
replace(
const std::string &what,
242 const std::string &with,
246 return replace(what, with, str);
256 std::string
lowercase(
const std::string &str);
278 std::string
uppercase(
const std::string &str);
310 size_t gcss(
const std::string &str1,
311 const std::string &str2,
312 const size_t pos = 0);
325 int tobool(
const std::string &str,
bool &val);
335 int tolong(
const std::string &str,
long &val);
345 int todouble(
const std::string &str,
double &val);
358 extern std::string
prettify(
const std::string &str);
374 extern std::string
c14n(
const std::string &str);
392 #endif // _RNR_STRING_THEORY_H std::string & ltrim(std::string &str)
Trim string in-place of leading whitespace.
int tolong(const std::string &str, long &val)
Convert string to a long integer.
std::vector< std::string > StringVec
Useful types.
int tobool(const std::string &str, bool &val)
Convert string to boolean.
std::string lowercase(const std::string &str)
Convert in-place string to lower case.
std::string & rtrim(std::string &str)
Trim string in-place of trailing whitespace.
const char * TruthHood[]
strings that equate to true
size_t split(const std::string &str, const char delim, StringVec &elems)
Split string.
int todouble(const std::string &str, double &val)
Convert string to a double-precision floating-point number.
std::string & trim(std::string &str)
Trim string in-place of leading and trailing whitespace.
std::string prettify(const std::string &str)
Prettify string.
std::string uppercase(const std::string &str)
Convert string to upper case.
std::string okstr(bool b)
Convert boolean to "ok" or "not-ok".
std::string space(unsigned n)
Create space string.
std::string & replace(const std::string &what, const std::string &with, std::string &str)
In-place replace all whats in string with with.
std::string c14n(const std::string &str)
Simple canonicalization of a string.
size_t gcss(const std::string &str1, const std::string &str2, const size_t pos=0)
Find the length of the Greatest Common SubString.
const char * FalseHood[]
Falsehood and truthhood strings. Each list termintate with a NULL.