Eq2deg
Utilities.hpp
Go to the documentation of this file.
1 #ifndef __UTILITIES_HPP
2 #define __UTILITIES_HPP
3 
17 // //////////////////////////////////////////////////////////////////////
18 // Import section
19 // //////////////////////////////////////////////////////////////////////
20 // STL
21 #include <iosfwd>
22 #include <sstream>
23 #include <string>
24 
25 class Utilities{
26  public:
32  void toStream (std::ostream& ioOut) const {
33  ioOut << describe();
34  }
35  private:
41  virtual std::string describe() const = 0;
42 };
43 
49 template <class charT, class traits>
50 inline
51 std::basic_ostream<charT, traits>&
52 operator<< (std::basic_ostream<charT, traits>& ioOut,
53  const Utilities& iUtils) {
59  std::basic_ostringstream<charT,traits> ostr;
60  ostr.copyfmt (ioOut);
61  ostr.width (0);
62 
63  // Fill string stream
64  iUtils.toStream (ostr);
65 
66  // Print string stream
67  ioOut << ostr.str();
68 
69  return ioOut;
70 }
71 
72 #endif //__UTILITIES_HPP
void toStream(std::ostream &ioOut) const
Definition: Utilities.hpp:32
Definition: Utilities.hpp:25