1 #ifndef SUPLIB_PP_STR_H 2 #define SUPLIB_PP_STR_H 32 #include <Exception/Exception.h> 36 std::string&
trim( std::string& str );
38 std::string&
prune( std::string& str );
40 bool iscomment(
const std::string& str,
const std::string& ignore=
" \t",
const std::string& comment=
"#" );
42 float str2f(
const char* txt );
44 double str2d(
const char* txt );
46 int str2i(
const char* txt,
int base=10 );
48 long str2l(
const char* txt,
int base=10 );
50 unsigned long str2ul(
const char* txt,
int base=10 );
52 template <
typename Container>
53 void tok (Container &container, std::string
const &in,
54 const char *
const delimiters =
" \t\n",
58 const std::string::size_type len = in.length();
59 std::string::size_type i = 0;
60 std::string::size_type j = 0;
68 i = in.find_first_not_of( delimiters, i );
70 j = in.find_first_of( delimiters, i );
72 if ( std::string::npos == i ) {
76 }
else if ( std::string::npos == j ) {
78 container.push_back( in.substr( i, j ) );
83 container.push_back( in.substr( i, j - i ) );
91 container.push_back( std::string() );
122 #endif // ! SUPLIB_PP_STR_H bool iscomment(const std::string &str, const std::string &ignore=" \t", const std::string &comment="#")
determine if the string is a comment.
The suplib namespace encompasses all of the functions in the suplib++ library.
float str2f(const char *txt)
convert string to floating-point number
long str2l(const char *txt, int base=10)
convert string to long number
std::string & prune(std::string &str)
remove leading and trailing white space from a string
double str2d(const char *txt)
convert string to double-precision number
std::string & trim(std::string &str)
remove leading white space from a string
int str2i(const char *txt, int base=10)
convert string to integer number
unsigned long str2ul(const char *txt, int base=10)
convert string to long number