OpenTREP Logo  0.6.0
C++ Open Travel Request Parsing Library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
OPENTREP_Abstract.hpp
Go to the documentation of this file.
1 #ifndef __OPENTREP_OPENTREP_ABSTRACT_HPP
2 #define __OPENTREP_OPENTREP_ABSTRACT_HPP
3 
4 // //////////////////////////////////////////////////////////////////////
5 // Import section
6 // //////////////////////////////////////////////////////////////////////
7 // STL
8 #include <iosfwd>
9 #include <string>
10 
11 namespace OPENTREP {
12 
17  public:
18  // /////////// Display support methods /////////
24  virtual void toStream (std::ostream& ioOut) const = 0;
25 
31  virtual void fromStream (std::istream& ioIn) = 0;
32 
36  virtual std::string toString() const = 0;
37 
38 
39  protected:
45 
49  virtual ~OPENTREP_Abstract() {}
50  };
51 }
52 
58 template <class charT, class traits>
59 inline
60 std::basic_ostream<charT, traits>&
61 operator<< (std::basic_ostream<charT, traits>& ioOut,
62  const OPENTREP::OPENTREP_Abstract& iStructure) {
68  std::basic_ostringstream<charT,traits> ostr;
69  ostr.copyfmt (ioOut);
70  ostr.width (0);
71 
72  // Fill string stream
73  iStructure.toStream (ostr);
74 
75  // Print string stream
76  ioOut << ostr.str();
77 
78  return ioOut;
79 }
80 
86 template <class charT, class traits>
87 inline
88 std::basic_istream<charT, traits>&
89 operator>> (std::basic_istream<charT, traits>& ioIn,
90  OPENTREP::OPENTREP_Abstract& ioStucture) {
91  // Fill Bom object with input stream
92  ioStucture.fromStream (ioIn);
93  return ioIn;
94 }
95 
96 #endif // __OPENTREP_OPENTREP_ABSTRACT_HPP
virtual void fromStream(std::istream &ioIn)=0
virtual std::string toString() const =0
virtual void toStream(std::ostream &ioOut) const =0
OPENTREP_Abstract(const OPENTREP_Abstract &)
std::basic_istream< charT, traits > & operator>>(std::basic_istream< charT, traits > &ioIn, OPENTREP::OPENTREP_Abstract &ioStucture)