12 #ifndef __KOME_CORE_STRING_FUNCTIONS_H__
13 #define __KOME_CORE_STRING_FUNCTIONS_H__
17 #include <boost/function.hpp>
30 std::string
strfmt(
const char* fmt, ... );
38 std::string
wstr2str( std::wstring& ws );
46 std::wstring
str2wstr( std::string& s );
90 std::vector<std::string>& tokens
107 const char* separator,
108 std::vector<std::string>& tokens
120 bool isint(
const char* s,
const int radix = 10,
int* val =
NULL );
130 int toint(
const char* s,
const int radix = 10,
const int dfval = 0 );
141 bool isint64(
const char* s,
const int radix = 10,
long long* val =
NULL );
151 long long toint64(
const char* s,
const int radix = 10,
const long long dfval = 0 );
170 double todouble(
const char* s,
const double dfval = 0.0 );
182 bool tobool(
const char* s,
bool dfVal =
false );
199 bool startswith(
const char* s,
const char* prefix );
208 bool endswith(
const char* s,
const char* suffix );
218 std::string
replacestring(
const char* s,
const char* oldStr,
const char* newStr );
228 std::string
shortenstring(
const char* s,
const unsigned int len,
const bool cutTail =
true );
237 std::string
regexsearch(
const char* s,
const char* regex );
240 #endif // __KOME_CORE_STRING_FUNCTIONS_H__
std::string strfmt(const char *fmt,...)
get formated string
bool endswith(const char *s, const char *suffix)
judge whether there is a sub-string at the end of string
std::string wstr2str(std::wstring &ws)
convert wstring to string
std::string shortenstring(const char *s, const unsigned int len, const bool cutTail=true)
shorten the specified string
std::string replacestring(const char *s, const char *oldStr, const char *newStr)
replaces specified substring with another one
int compareignorecase(const char *s1, const char *s2)
compare two strings ignoring case considerations
bool isint(const char *s, const int radix=10, int *val=NULL)
judge whether sutisfied character string shows integer number.
long long toint64(const char *s, const int radix=10, const long long dfval=0)
convert string into 64 bit integer
std::wstring str2wstr(std::string &s)
convert string to wstring
int toint(const char *s, const int radix=10, const int dfval=0)
convert string into integer
unsigned int stringtoken(const char *s, const char *delim, std::vector< std::string > &tokens)
get tokens from string
bool isint64(const char *s, const int radix=10, long long *val=NULL)
judge whether sutisfied character string shows 64 bit integer number.
bool startswith(const char *s, const char *prefix)
judges whether there is a sub-string at the start of string
bool tobool(const char *s, bool dfVal=false)
get true or false from character string.
double todouble(const char *s, const double dfval=0.0)
convert string into double
unsigned int stringseparate(const char *s, const char *separator, std::vector< std::string > &tokens)
separates string
std::string regexsearch(const char *s, const char *regex)
search string using regular expression.
std::string trimstring(const char *s)
remove white spaces from both ends of specified string
bool isdouble(const char *s, double *val=NULL)
judge whether sutisfied character string shows real number.
std::string touppercase(const char *s)
convert all of the characters int the string given to upper case
std::string tolowercase(const char *s)
convert all of the characters in the string given to lower case