Image Component Library (ICL)
Classes | Functions
String Manipuation Functions

Classes

struct  icl::utils::MatchResult
 Utility structure for matching results. More...
 

Functions

template<class T >
std::ostream & icl::utils::icl_to_stream (std::ostream &s, T t)
 compatibility function that writes a datatype instance into a stream More...
 
template<class T >
std::istream & icl::utils::icl_from_stream (std::istream &s, T &t)
 compability function that reads a datatype instance from a stream More...
 
ICLUtils_API std::string & icl::utils::toLowerI (std::string &s)
 inplace lower case conversion More...
 
ICLUtils_API std::string & icl::utils::toUpperI (std::string &s)
 inplace upper case conversion More...
 
ICLUtils_API std::string icl::utils::toLower (const std::string &s)
 lower case conversion More...
 
ICLUtils_API std::string icl::utils::toUpper (const std::string &s)
 upper case conversion More...
 
ICLUtils_API std::vector< std::string > icl::utils::tok (const std::string &s, const std::string &delims=" ", bool singleCharDelims=true, char escapeChar='\0')
 tokenizes a string with given delimiters (internally using a temporary StrTok instance) More...
 
ICLUtils_API std::vector< std::string > & icl::utils::tok (const std::string &s, const std::string &delim, std::vector< std::string > &dst, bool singleCharDelims=true, char escapeChar='\0')
 tokenize a string with given delimiters into a result vector (optimized) More...
 
ICLUtils_API std::string icl::utils::cat (const std::vector< std::string > &v)
 concatinates at string-vector to a single string More...
 
ICLUtils_API std::string icl::utils::toStr (int i, const char *format, char *buf=0)
 creates a string from a given integer More...
 
ICLUtils_API std::string icl::utils::toStr (double d, const char *format, char *buf=0)
 creates a string from a given double/float More...
 
ICLUtils_API std::string icl::utils::toStr (int i, char *buf=0)
 create a string from given integer using format string "%d" More...
 
ICLUtils_API std::string icl::utils::toStr (double d, char *buf=0)
 create a string from given float using format string "%f" More...
 
template<class T >
std::string icl::utils::str (const T &t)
 convert a data type into a string using an std::ostringstream instance More...
 
template<class T >
std::string icl::utils::cat (const std::vector< T > &v, const std::string &delim=",")
 creates a delim-separated string of str'ed values of given vector More...
 
template<class T >
icl::utils::parse (const std::string &s)
 parses a string into template parameter (defined for iclXX and std::string) More...
 
ICLUtils_API icl8u icl::utils::to8u (const std::string &s)
 cast a string to an icl8u (parse) More...
 
ICLUtils_API icl16s icl::utils::to16s (const std::string &s)
 cast a string to an icl16s (parse) More...
 
ICLUtils_API icl32s icl::utils::to32s (const std::string &s)
 cast a string to an icl32ss (parse) More...
 
ICLUtils_API icl32f icl::utils::to32f (const std::string &s)
 cast a string to an icl32f (parse) More...
 
ICLUtils_API icl64f icl::utils::to64f (const std::string &s)
 cast a string to an icl64f (parse) More...
 
template<class T >
std::vector< T > icl::utils::parseVec (const std::vector< std::string > &v)
 parse a vector of strings into a vector of T's More...
 
template<class T >
std::vector< T > icl::utils::parseVecStr (const std::string &vecStr, const std::string &delims=",")
 parse a delims seperated string into a vector of T's More...
 
template<class T >
std::vector< std::string > icl::utils::strVec (const std::vector< T > &v)
 convert a vector of T's into a vector of strings More...
 
ICLUtils_API MatchResult icl::utils::match (const std::string &text, const std::string &regex, int numSubMatches=0) throw (InvalidRegularExpressionException)
 Applies a regular expression match on given text and regex pattern (internally using regex.h) More...
 

Detailed Description

Function Documentation

ICLUtils_API std::string icl::utils::cat ( const std::vector< std::string > &  v)

concatinates at string-vector to a single string

template<class T >
std::string icl::utils::cat ( const std::vector< T > &  v,
const std::string &  delim = "," 
)

creates a delim-separated string of str'ed values of given vector

e.g. if v is {1,2,3} and delim is '-' the resulting string will be "1-2-3"

template<class T >
std::istream& icl::utils::icl_from_stream ( std::istream &  s,
T &  t 
)
inline

compability function that reads a datatype instance from a stream

This must be used, to ensure, icl8u data is read as (int) rather as char

template<class T >
std::ostream& icl::utils::icl_to_stream ( std::ostream &  s,
t 
)
inline

compatibility function that writes a datatype instance into a stream

This must be used, to ensure, icl8u data is shown as (int) rather as char

ICLUtils_API MatchResult icl::utils::match ( const std::string &  text,
const std::string &  regex,
int  numSubMatches = 0 
)
throw (InvalidRegularExpressionException
)

Applies a regular expression match on given text and regex pattern (internally using regex.h)

Parameters
textsource string
regexregular expression to search in text
numSubMatchesIf 0 (which is default, result contains only an information whether the match was successful or not. Sub matches can be recorded optionally using a numSubMatches value > 0. Please note, that the whole pattern match is submatches[0] in the resulting MatchResult if numSubMatches is at least 1
template<class T >
T icl::utils::parse ( const std::string &  s)
inline

parses a string into template parameter (defined for iclXX and std::string)

See also
to8u to16s to32s to32f to64f (
template<class T >
std::vector<T> icl::utils::parseVec ( const std::vector< std::string > &  v)
inline

parse a vector of strings into a vector of T's

template<class T >
std::vector<T> icl::utils::parseVecStr ( const std::string &  vecStr,
const std::string &  delims = "," 
)
inline

parse a delims seperated string into a vector of T's

template<class T >
std::string icl::utils::str ( const T &  t)
inline

convert a data type into a string using an std::ostringstream instance

template<class T >
std::vector<std::string> icl::utils::strVec ( const std::vector< T > &  v)
inline

convert a vector of T's into a vector of strings

ICLUtils_API icl16s icl::utils::to16s ( const std::string &  s)

cast a string to an icl16s (parse)

ICLUtils_API icl32f icl::utils::to32f ( const std::string &  s)

cast a string to an icl32f (parse)

ICLUtils_API icl32s icl::utils::to32s ( const std::string &  s)

cast a string to an icl32ss (parse)

ICLUtils_API icl64f icl::utils::to64f ( const std::string &  s)

cast a string to an icl64f (parse)

ICLUtils_API icl8u icl::utils::to8u ( const std::string &  s)

cast a string to an icl8u (parse)

ICLUtils_API std::vector<std::string> icl::utils::tok ( const std::string &  s,
const std::string &  delims = " ",
bool  singleCharDelims = true,
char  escapeChar = '\0' 
)

tokenizes a string with given delimiters (internally using a temporary StrTok instance)

ICLUtils_API std::vector<std::string>& icl::utils::tok ( const std::string &  s,
const std::string &  delim,
std::vector< std::string > &  dst,
bool  singleCharDelims = true,
char  escapeChar = '\0' 
)

tokenize a string with given delimiters into a result vector (optimized)

ICLUtils_API std::string icl::utils::toLower ( const std::string &  s)

lower case conversion

ICLUtils_API std::string& icl::utils::toLowerI ( std::string &  s)

inplace lower case conversion

ICLUtils_API std::string icl::utils::toStr ( int  i,
const char *  format,
char *  buf = 0 
)

creates a string from a given integer

Parameters
ito be converted integer value
formatformat string as d or %8d
bufoptinal dest buffer (used if not NULL)
ICLUtils_API std::string icl::utils::toStr ( double  d,
const char *  format,
char *  buf = 0 
)

creates a string from a given double/float

Parameters
dto be converted double/float value
formatformat string as ff or %3.5f
bufoptinal dest buffer (used if not NULL)
ICLUtils_API std::string icl::utils::toStr ( int  i,
char *  buf = 0 
)

create a string from given integer using format string "%d"

See also
toStr(int,const char*,char*)
ICLUtils_API std::string icl::utils::toStr ( double  d,
char *  buf = 0 
)

create a string from given float using format string "%f"

See also
toStr(double,const char*,char*)
ICLUtils_API std::string icl::utils::toUpper ( const std::string &  s)

upper case conversion

ICLUtils_API std::string& icl::utils::toUpperI ( std::string &  s)

inplace upper case conversion