1 #ifndef SUPLIB_PP_STR_H 2 #define SUPLIB_PP_STR_H 37 #include <Exception/Exception.h> 43 string&
trim(
string& str );
45 string&
prune(
string& str );
47 bool iscomment(
const string& str,
const string& ignore=
" \t",
const string& comment=
"#" );
49 float str2f(
const char* txt )
throw( Exception );
51 double str2d(
const char* txt )
throw( Exception );
53 int str2i(
const char* txt,
int base=10 ) throw( Exception );
55 long str2l( const
char* txt,
int base=10 ) throw( Exception );
57 unsigned long str2ul( const
char* txt,
int base=10 ) throw( Exception );
59 template <typename Container>
60 void tok (Container &container,
string const &in,
61 const
char * const delimiters = " \t\n",
65 const string::size_type len = in.length();
66 string::size_type i = 0;
67 string::size_type j = 0;
75 i = in.find_first_not_of( delimiters, i );
77 j = in.find_first_of( delimiters, i );
79 if ( string::npos == i ) {
83 }
else if ( string::npos == j ) {
85 container.push_back( in.substr( i, j ) );
90 container.push_back( in.substr( i, j - i ) );
98 container.push_back(
string() );
129 #endif // ! SUPLIB_PP_STR_H The suplib namespace encompasses all of the functions in the suplib++ library.
string & trim(string &str)
remove leading white space from a string
float str2f(const char *txt)
convert string to floating-point number
long str2l(const char *txt, int base=10)
convert string to long number
double str2d(const char *txt)
convert string to double-precision number
int str2i(const char *txt, int base=10)
convert string to integer number
string & prune(string &str)
remove leading and trailing white space from a string
unsigned long str2ul(const char *txt, int base=10)
convert string to long number
void tok(Container &container, string const &in, const char *const delimiters=" \t\n", bool skip=true)
split a string into tokens
bool iscomment(const string &str, const string &ignore=" \t", const string &comment="#")
determine if the string is a comment.