Tools/WeatherCorrections/LineStringTo.h
Go to the documentation of this file.
1 #ifndef _anal_LineStringTo_h_
2 #define _anal_LineStringTo_h_
3 
4 #include <boost/lexical_cast.hpp>
5 #include <boost/algorithm/string/trim.hpp>
6 #include <string>
7 #include <iostream>
8 
9 
10 namespace anal {
11 
12  template<class T>
13  struct LineStringTo : public T {
14  LineStringTo& operator=(const T& t)
15  { T::operator=(t); return *this; }
16 
17  friend
18  std::istream&
19  operator>>(std::istream& is, LineStringTo& obj)
20  {
21  std::string line;
22  if (std::getline(is, line)) {
23  boost::algorithm::trim(line);
24  try {
25  obj = boost::lexical_cast<T>(line);
26  } catch (const boost::bad_lexical_cast& /*e*/) {
27  obj = T();
28  }
29  }
30  return is;
31  }
32  };
33 
34 }
35 
36 
37 #endif
bool is(const double a, const double b)
Definition: testlib.cc:113
friend std::istream & operator>>(std::istream &is, LineStringTo &obj)
LineStringTo & operator=(const T &t)

, generated on Tue Sep 26 2023.