TECA
The Toolkit for Extreme Climate Analysis
teca_string_util Namespace Reference

Codes for dealing with string processing. More...

Classes

struct  scanf_tt
 A traits class for scanf conversion codes. More...
 
struct  scanf_tt< char >
 
struct  scanf_tt< double >
 
struct  scanf_tt< float >
 
struct  scanf_tt< int >
 
struct  scanf_tt< long >
 
struct  scanf_tt< long long >
 
struct  scanf_tt< short >
 
struct  scanf_tt< std::string >
 
struct  scanf_tt< unsigned char >
 
struct  scanf_tt< unsigned int >
 
struct  scanf_tt< unsigned long >
 
struct  scanf_tt< unsigned long long >
 
struct  scanf_tt< unsigned short >
 
struct  string_tt
 A traits class for conversion from text to numbers. More...
 
struct  string_tt< bool >
 A traits class for conversion from text to numbers, specialized for bool. More...
 
struct  string_tt< char * >
 
struct  string_tt< char >
 
struct  string_tt< double >
 
struct  string_tt< float >
 
struct  string_tt< int >
 
struct  string_tt< long >
 
struct  string_tt< long long >
 
struct  string_tt< short >
 
struct  string_tt< std::string >
 A traits class for conversion from text to numbers, specialized for std::string. More...
 

Functions

TECA_EXPORT int extract_string (const char *istr, std::string &field)
 
TECA_EXPORT int tokenize (char *istr, char delim, int n_cols, char **ostr)
 
template<typename container_t = std::vector<char*>>
TECA_EXPORT int tokenize (char *istr, char delim, container_t &ostr)
 
int skip_pad (char *&buf)
 
int is_comment (char *buf)
 return 0 if the first non-pad character is # More...
 
template<typename val_t >
TECA_EXPORT int extract_value (char *l, val_t &val)
 
TECA_EXPORT void remove_postfix (std::set< std::string > &names, std::string postfix)
 
TECA_EXPORT std::string emptystr (const std::string &in)
 When passed the string "" return empty string otherwise return the passed string. More...
 

Detailed Description

Codes for dealing with string processing.

Function Documentation

◆ emptystr()

TECA_EXPORT std::string teca_string_util::emptystr ( const std::string &  in)
inline

When passed the string "" return empty string otherwise return the passed string.

◆ extract_string()

TECA_EXPORT int teca_string_util::extract_string ( const char *  istr,
std::string &  field 
)

Convert the characters between the first and second double quote to a std::string. Escaped characters are skipped. Return 0 if successful.

◆ extract_value()

template<typename val_t >
TECA_EXPORT int teca_string_util::extract_value ( char *  l,
val_t &  val 
)

Extract the value in a "name = value" pair. an error occurs if splitting the input on '=' doesn't produce 2 tokens or if the conversion to val_t fails. returns 0 if successful.

◆ is_comment()

int teca_string_util::is_comment ( char *  buf)
inline

return 0 if the first non-pad character is #

◆ remove_postfix()

TECA_EXPORT void teca_string_util::remove_postfix ( std::set< std::string > &  names,
std::string  postfix 
)

Given a collection of strings, where some of the strings end with a common substring, the post-fix, this function visits each string in the collection and removes the post-fix from each string that it is found in.

◆ skip_pad()

int teca_string_util::skip_pad ( char *&  buf)
inline

Skip space, tabs, and new lines. return non-zero if the end of the string is reached before a non-pad character is encountered

◆ tokenize() [1/2]

template<typename container_t = std::vector<char*>>
TECA_EXPORT int teca_string_util::tokenize ( char *  istr,
char  delim,
container_t &  ostr 
)

Scan the input string (istr) for the given a delimiter (delim). push a point to the first non-delimiter character and the first character after each instance of the delimiter. return zero if successful. when successful there will be at least one value.

◆ tokenize() [2/2]

TECA_EXPORT int teca_string_util::tokenize ( char *  istr,
char  delim,
int  n_cols,
char **  ostr 
)

Scan the input string (istr) for the given a delimiter (delim). push a pointer to the first non-delimiter character and the first character after each instance of the delimiter. return zero if successful. when successful there will be at least one value.