OpenTREP Logo  0.07.18
C++ Open Travel Request Parsing Library
Loading...
Searching...
No Matches
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
11namespace 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
58template <class charT, class traits>
59inline
60std::basic_ostream<charT, traits>&
61operator<< (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
86template <class charT, class traits>
87inline
88std::basic_istream<charT, traits>&
89operator>> (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
std::basic_ostream< charT, traits > & operator<<(std::basic_ostream< charT, traits > &ioOut, const OPENTREP::OPENTREP_Abstract &iStructure)
std::basic_istream< charT, traits > & operator>>(std::basic_istream< charT, traits > &ioIn, OPENTREP::OPENTREP_Abstract &ioStucture)
virtual std::string toString() const =0
virtual void toStream(std::ostream &ioOut) const =0
virtual void fromStream(std::istream &ioIn)=0
OPENTREP_Abstract(const OPENTREP_Abstract &)