StdAir Logo  1.00.13
C++ Standard Airline IT Object Library
Loading...
Searching...
No Matches
StructAbstract.hpp
Go to the documentation of this file.
1#ifndef __STDAIR_BAS_STRUCTABSTRACT_HPP
2#define __STDAIR_BAS_STRUCTABSTRACT_HPP
3
4// //////////////////////////////////////////////////////////////////////
5// Import section
6// //////////////////////////////////////////////////////////////////////
7// STL
8#include <iosfwd>
9#include <string>
10
11namespace stdair {
12
17 public:
18
22 virtual ~StructAbstract() {}
23
29 void toStream (std::ostream& ioOut) const {
30 ioOut << describe();
31 }
32
38 virtual void fromStream (std::istream& ioIn) {}
39
43 virtual const std::string describe() const = 0;
44
45 protected:
50 };
51}
52
58template <class charT, class traits>
59inline
60std::basic_ostream<charT, traits>&
61operator<< (std::basic_ostream<charT, traits>& ioOut,
62 const stdair::StructAbstract& iStruct) {
68 std::basic_ostringstream<charT,traits> ostr;
69 ostr.copyfmt (ioOut);
70 ostr.width (0);
71
72 // Fill string stream
73 iStruct.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 stdair::StructAbstract& ioStruct) {
91 // Fill the Structure object with the input stream.
92 ioStruct.fromStream (ioIn);
93 return ioIn;
94
95}
96#endif // __STDAIR_BAS_STRUCTABSTRACT_HPP
std::basic_ostream< charT, traits > & operator<<(std::basic_ostream< charT, traits > &ioOut, const stdair::StructAbstract &iStruct)
std::basic_istream< charT, traits > & operator>>(std::basic_istream< charT, traits > &ioIn, stdair::StructAbstract &ioStruct)
Handle on the StdAir library context.
Base class for the light structures.
virtual const std::string describe() const =0
virtual void fromStream(std::istream &ioIn)
void toStream(std::ostream &ioOut) const