9 #ifndef _LIMBO_STRING_STRING
10 #define _LIMBO_STRING_STRING
30 if (s.empty())
return false;
31 for (string::const_iterator it = s.begin(); it != s.end(); ++it)
33 if (!isdigit(*it))
return false;
43 if (s.empty())
return false;
46 for (string::const_iterator it = s.begin(); it != s.end(); ++it)
50 if (*it ==
'.' && dp_cnt < 1)
64 if (s.empty())
return false;
67 for (string::const_iterator it = s.begin(); it != s.end(); ++it)
71 if (*it ==
'.' && dp_cnt < 1)
86 s_up.reserve(s.size());
87 for (string::const_iterator it = s.begin(); it != s.end(); ++it)
98 s_low.reserve(s.size());
99 for (string::const_iterator it = s.begin(); it != s.end(); ++it)
100 s_low.push_back(::
tolower(*it));
108 inline bool iequals(
string const& s1,
string const& s2)
112 return s1_up == s2_up;
120 size_t found = s.rfind(
'/');
121 if (found != string::npos)
return s.substr(0, found);
129 size_t found = s.rfind(
'/');
130 if (found != string::npos)
return s.substr(found+1);
138 size_t found = s.rfind(
'.');
139 if (found != string::npos)
return s.substr(found+1);
140 else return string(
"");
147 size_t found = s.rfind(
'.');
148 if (found != string::npos)
return s.substr(0, found);
156 size_t pos1 = std::string::npos;
157 size_t pos2 = std::string::npos;
158 for (
size_t i = 0; i < str.size(); i++)
160 if (pos1 == std::string::npos && str[i] !=
' ' && str[i] !=
'\t')
162 else if (pos1 != std::string::npos && (str[i] ==
' ' || str[i] ==
'\t'))
168 return str.substr(pos1, pos2 - pos1);
string trim_file_suffix(string const &s)
trim the suffix of a file
string get_file_path(const string &s)
get relative path of a file
string toupper(string const &s)
convert string to upper case
bool is_integer(string const &s)
check whether string represents an integer
string get_file_suffix(const string &s)
get suffix of a file
bool is_number(string const &s)
check whether string represents a number, either integer or floating point number ...
string get_file_name(const string &s)
get pure name of a file (no path)
convert metadata type to string
bool iequals(string const &s1, string const &s2)
check two strings equal, case-insensitive
bool is_float(string const &s)
check whether string represents an float
string tolower(string const &s)
convert string to lower case
string get_first_word(string const &str)
fetch the first word of a string, assume delimiter is space or tab