00001
00020 #ifndef StringUtil_h
00021 #define StringUtil_h
00022
00023 #include <string>
00024 #include <vector>
00025 #include <sstream>
00026
00053 int getlinePortable(std::istream& istr, std::string& line);
00054
00078 bool isEscaped(const std::string& str, std::string::size_type pos);
00079
00112 std::string escape(const std::string str);
00113
00114
00151 std::string unescape(const std::string str);
00152
00172 void eraseHeadBlank(std::string& str);
00173
00193 void eraseTailBlank(std::string& str);
00194
00216 void replaceString(std::string& str, const std::string from,
00217 const std::string to);
00218
00242 std::vector<std::string> split(const std::string& input,
00243 const std::string& delimiter);
00244
00273 bool toBool(std::string str, std::string yes, std::string no,
00274 bool default_value = true);
00275
00305 bool isAbsolutePath(const std::string& str);
00306
00332 bool isURL(const std::string& str);
00333
00355 template <class Printable>
00356 std::string otos(Printable n)
00357 {
00358 std::stringstream str_stream;
00359 str_stream << n;
00360 return str_stream.str();
00361 };
00362
00386 template <typename To>
00387 bool stringTo(To& val, const char* str)
00388 {
00389 std::stringstream s;
00390 try {
00391 return (s << str && s >> val);
00392 }
00393 catch (...)
00394 {
00395 return false;
00396 }
00397 }
00398
00421 std::vector<std::string> unique_sv(std::vector<std::string> sv);
00422
00447 std::string flatten(std::vector<std::string> sv);
00448
00471 char** toArgv(const std::vector<std::string>& args);
00472
00473 #endif // StringUtil_h