Mass++ Common Libraries v2.7.5
 All Classes Namespaces Files Functions Variables Enumerations Macros
StringFunctions.h
Go to the documentation of this file.
1 
12 #ifndef __KOME_CORE_STRING_FUNCTIONS_H__
13 #define __KOME_CORE_STRING_FUNCTIONS_H__
14 
15 
16 #include <string>
17 #include <boost/function.hpp>
18 #include <vector>
19 
20 
21 #define FMT strfmt
22 
23 
30 std::string strfmt( const char* fmt, ... );
31 
38 std::string wstr2str( std::wstring& ws );
39 
46 std::wstring str2wstr( std::string& s );
47 
54 std::string tolowercase( const char* s );
55 
62 std::string touppercase( const char* s );
63 
73 int compareignorecase( const char* s1, const char* s2 );
74 
87 unsigned int stringtoken(
88  const char* s,
89  const char* delim,
90  std::vector<std::string>& tokens
91 );
92 
105 unsigned int stringseparate(
106  const char* s,
107  const char* separator,
108  std::vector<std::string>& tokens
109 );
110 
120 bool isint( const char* s, const int radix = 10, int* val = NULL );
121 
130 int toint( const char* s, const int radix = 10, const int dfval = 0 );
131 
141 bool isint64( const char* s, const int radix = 10, long long* val = NULL );
142 
151 long long toint64( const char* s, const int radix = 10, const long long dfval = 0 );
152 
161 bool isdouble( const char* s, double* val = NULL );
162 
170 double todouble( const char* s, const double dfval = 0.0 );
171 
182 bool tobool( const char* s, bool dfVal = false );
183 
190 std::string trimstring( const char* s );
191 
199 bool startswith( const char* s, const char* prefix );
200 
208 bool endswith( const char* s, const char* suffix );
209 
218 std::string replacestring( const char* s, const char* oldStr, const char* newStr );
219 
228 std::string shortenstring( const char* s, const unsigned int len, const bool cutTail = true );
229 
237 std::string regexsearch( const char* s, const char* regex );
238 
239 
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
#define NULL
Definition: CoreMacros.h:18
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