00001 #ifndef XSTRING_H
00002 #define XSTRING_H
00003
00004 #include <sstream>
00005 #include <string>
00006
00007 template<class T> class XString{
00008
00009 public:
00010
00011 static T convertFromString(const std::string& s)
00012 {
00013 std::istringstream in(s);
00014 T x;
00015 if (in >> x)
00016 return x;
00017
00018 return 0;
00019
00020
00021
00022 }
00023
00024 static std::string convertToString(const T & t)
00025 {
00026 std::ostringstream out ;
00027
00028 if (out << std::fixed << t )
00029 return out.str();
00030
00031 return 0;
00032
00033
00034
00035 }
00036
00037 };
00038 #endif