00001 # ifndef HepUtilities_string_conversion_h__included__
00002 # define HepUtilities_string_conversion_h__included__
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 # include <string>
00014 #ifdef OLDSTREAMS
00015 # include <strstream>
00016 # define ostringstream ostrstream
00017 # define istringstream istrstream
00018 #else
00019 # include <sstream>
00020 #endif
00021
00022 namespace Anaphe
00023 {
00024
00030 template<class T>
00031 std::string to_string(const T& val)
00032 {
00033 std::ostringstream buf;
00034
00035 buf << val;
00036 #ifndef BADENDS
00037 buf << std::ends;
00038 #endif
00039 std::string ret = buf.str();
00040 return ret;
00041 }
00042
00048 template<class T>
00049 bool to_value(std::string s, T& val)
00050 {
00051 std::istringstream buf(s.c_str());
00052 buf >> std::ws;
00053 return buf >> val;
00054 }
00055
00056 }
00057
00058
00059 # endif