00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef __UTILS_H
00019 #define __UTILS_H
00020
00021 #include <string>
00022 #include <sstream>
00023
00024 template <class T>
00025 bool from_string(T& t, const std::string& s) {
00026 std::istringstream iss(s, std::istringstream::in);
00027 return !(iss >> t).fail();
00028 }
00029
00030 template <class T>
00031 std::string to_string(const T& t) {
00032 std::ostringstream oss;
00033 oss << t;
00034 return oss.str();
00035 }
00036
00037
00038 namespace utils {
00039
00040 void replace(std::string& where, const std::string& what, const std::string& by);
00041
00042 bool start_with(const std::string& str, const std::string& what);
00043 bool end_with(const std::string& str, const std::string& what);
00044
00045 }
00046
00047
00048 #endif