suplibxx  1.3.9
String

Functions

bool suplib::iscomment (const string &str, const string &ignore=" \t", const string &comment="#")
 determine if the string is a comment. More...
 
string & suplib::prune (string &str)
 remove leading and trailing white space from a string More...
 
double suplib::str2d (const char *txt) throw ( Exception )
 convert string to double-precision number More...
 
float suplib::str2f (const char *txt) throw ( Exception )
 convert string to floating-point number More...
 
int suplib::str2i (const char *txt, int base=10) throw ( Exception )
 convert string to integer number More...
 
long suplib::str2l (const char *txt, int base=10) throw ( Exception )
 convert string to long number More...
 
unsigned long suplib::str2ul (const char *txt, int base=10) throw ( Exception )
 convert string to long number More...
 
template<typename Container >
void suplib::tok (Container &container, string const &in, const char *const delimiters=" \t\n", bool skip=true)
 split a string into tokens More...
 
string & suplib::trim (string &str)
 remove leading white space from a string More...
 

Detailed Description

Function Documentation

◆ iscomment()

bool suplib::iscomment ( const string &  str,
const string &  ignore = " \t",
const string &  comment = "#" 
)

determine if the string is a comment.

Parameters
strthe string upon which to operate

iscomment scans str to determine if the first character following all the ignore characters is a comment character. It compares the position of the first non-ignore character with the position of the first comment character. If they are the same and occur before the end of the string, it returns true. Otherwise it returns false.

Returns
It returns true if line is a comment.

Definition at line 48 of file iscomment.cc.

◆ prune()

string & suplib::prune ( string &  str)

remove leading and trailing white space from a string

Parameters
strthe string upon which to operate

prune deletes leading and trailing white space, where white space is defined as blanks, tabs, new lines, and carriage returns.

Returns
It returns the passed reference

Definition at line 48 of file prune.cc.

◆ str2d()

double suplib::str2d ( const char *  txt)
throw (Exception
)

convert string to double-precision number

Parameters
txtthe string upon which to operate

str2d() converts the initial portion of the string pointed to by txt to type double representation. It throws an exception, of type Exception, if txt is not a legitimate double precision number.

Returns
It returns the double precision number

Definition at line 44 of file str2d.cc.

◆ str2f()

float suplib::str2f ( const char *  txt)
throw (Exception
)

convert string to floating-point number

Parameters
txtthe string upon which to operate

str2f() converts the initial portion of the string pointed to by txt to type float representation. It throws an exception, of type Exception, if txt is not a legitimate floating point number.

Returns
It returns the floating point number

Definition at line 39 of file str2f.cc.

◆ str2i()

int suplib::str2i ( const char *  txt,
int  base = 10 
)
throw (Exception
)

convert string to integer number

Parameters
txtthe string upon which to operate

str2i() converts the initial portion of the string pointed to by txt to type integer representation. It throws an exception, of type Exception, if txt is not a legitimate integer.

Returns
It returns the integer.

Definition at line 40 of file str2i.cc.

◆ str2l()

long suplib::str2l ( const char *  txt,
int  base = 10 
)
throw (Exception
)

convert string to long number

Parameters
txtthe string upon which to operate

str2l() converts the initial portion of the string pointed to by txt to type long representation. It throws an exception, of type Exception, if txt is not a legitimate long.

Returns
It returns the long.

Definition at line 44 of file str2l.cc.

◆ str2ul()

unsigned long suplib::str2ul ( const char *  txt,
int  base = 10 
)
throw (Exception
)

convert string to long number

Parameters
txtthe string upon which to operate

str2ul() converts the initial portion of the string pointed to by txt to type unsigned long representation. It throws an exception, of type Exception, if txt is not a legitimate long.

Returns
It returns the long.

Definition at line 44 of file str2ul.cc.

◆ tok()

template<typename Container >
template< typename Container > void suplib::tok ( Container &  container,
string const &  in,
const char *const  delimiters = " \t\n",
bool  skip = true 
)

split a string into tokens

Parameters
containerthe reference to a C++ container object into which the parsed string goes.
inthe string to parse.
delimitersthe characters which delimit tokens.
skipconsecutive delimiters are skipped.

Splits the input string, in, on one or more of the characters in delimiters. The tokens are placed in container.

Returns
void

Definition at line 60 of file str.h.

◆ trim()

string & suplib::trim ( string &  str)

remove leading white space from a string

Parameters
strthe string upon which to operate

trim deletes leading white space, where white space is defined as blanks, tabs, new lines, and carriage returns.

Returns
It returns the passed reference

Definition at line 49 of file trim.cc.