00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00033 #ifndef S3_CONVERSION_H
00034 #define S3_CONVERSION_H
00035
00036 #include <s3fc/s3_exception.h>
00037 #include <string>
00038 #include <vector>
00039 #include <sstream>
00040
00044 class s3_conversion
00045 {
00046 public:
00047
00052 template<typename T>
00053 static std::string to_string(const T &t)
00054 {
00055 std::ostringstream os;
00056 os << t;
00057 return os.str();
00058 }
00059
00064 template<class T>
00065 static T from_string(const std::string& s)
00066 {
00067 std::istringstream is( s );
00068 T t;
00069 is >> t;
00070 return t;
00071 }
00072
00079 static std::vector<std::string> string_to_vec_string(const std::string& str);
00085 static std::vector<int> string_to_vec_int(const std::string& str);
00091 static std::vector<float> string_to_vec_float(const std::string& str);
00102 static std::vector<std::string> split_string(const std::string& str,
00103 const char* delim = 0);
00107 class exception : public s3_generic_exception
00108 {
00109 public:
00115 exception(const std::string& where,
00116 const std::string& what);
00117 };
00118 };
00119
00120 template<>
00121 std::string s3_conversion::from_string<std::string>(const std::string& s);
00122
00123
00124 #endif //S3_CONVERSION_H