1 #ifndef UTILITIES_GENERAL_IOUTILS_H
2 #define UTILITIES_GENERAL_IOUTILS_H
34 inline int operator () (
const std::string &
c)
const {
return atoi(c.c_str());}
38 struct ato<unsigned int> {
39 inline unsigned int operator () (
const char *
c)
const {
return strtoul(c,0,0);}
40 inline unsigned int operator () (
const std::string &
c)
const {
return strtoul(c.c_str(),0,0);}
46 inline float operator () (
const std::string &
c)
const {
return atof(c.c_str());}
51 inline double operator () (
const char *
c)
const {
return strtod(c,0);}
52 inline double operator () (
const std::string &
c)
const {
return strtod(c.c_str(),0);}
58 inline const char *
operator () (
const std::string &
c)
const {
return c.c_str();}
62 struct ato<std::string> {
63 inline const std::string &
operator () (
const char *
c)
const {
static std::string cs; cs=
c;
return cs;}
64 inline const std::string &
operator () (
const std::string &
c)
const {
return c;}
68 struct ato<std::vector<T> > {
72 std::istringstream
in(c);
73 std::istream_iterator<T> sbegin(in), send;
74 std::copy(sbegin,send,std::inserter(v,v.end()));
78 inline std::vector<T>
operator () (
const std::string &cs)
const {
80 if (cs.empty())
return v;
81 std::istringstream
in(cs.c_str());
82 std::istream_iterator<T> sbegin(
in), send;
83 std::copy(sbegin,send,std::inserter(v,v.end()));
113 const char *
operator () (
const std::string&
c)
const {
return c.c_str();}
116 std::ostream_iterator<T > oi(
oss(),
" ");
123 mutable std::ostringstream
oss_;
124 std::ostringstream &
oss()
const {
return oss_;}
126 static std::string &
localS();
133 #endif // UTILITIES_GENERAL_IOUTILS_H
const char * operator()(const unsigned long &c) const
const char * operator()(const long &c) const
const T & operator()(const T &c) const
const char * operator()(const unsigned short int &c) const
const char * operator()(const short int &c) const
static std::string & localS()
void operator=(const toa &)
const char * operator()(const unsigned int &c) const
const char * operator()(const float &c) const
std::ostringstream & oss() const