00001
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057 #ifndef StringUtil_h
00058 #define StringUtil_h
00059
00060 #include <string>
00061 #include <vector>
00062 #include <sstream>
00063
00086 bool isEscaped(const std::string& str, std::string::size_type pos);
00087
00088
00113 std::string escape(const std::string str);
00114
00115
00142 std::string unescape(const std::string str);
00143
00144
00152 void eraseHeadBlank(std::string& str);
00153
00154
00162 void eraseTailBlank(std::string& str);
00163
00164
00172 void replaceString(std::string& str, const std::string from,
00173 const std::string to);
00174
00175
00183 std::vector<std::string> split(const std::string& input,
00184 const std::string& delimiter);
00185
00186
00194 bool toBool(std::string str, std::string yes, std::string no,
00195 bool default_value = true);
00196
00197
00205 bool isAbsolutePath(const std::string& str);
00206
00207
00215 bool isURL(const std::string& str);
00216
00217
00225 template <class Printable>
00226 std::string otos(Printable n)
00227 {
00228 std::stringstream str_stream;
00229 str_stream << n;
00230 return str_stream.str();
00231 };
00232
00233 template <typename To>
00234 bool stringTo(To& val, const char* str)
00235 {
00236 std::stringstream s;
00237 return (s << str && s >> val);
00238 }
00239
00240
00241 std::vector<std::string> unique_sv(std::vector<std::string> sv);
00242
00243 std::string flatten(std::vector<std::string> sv);
00244
00245
00246 char** toArgv(const std::vector<std::string>& args);
00247
00248
00249 #endif // StringUtil_h