StdAir Logo  1.00.3
C++ Standard Airline IT Object Library
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 
11 namespace stdair {
12 
16  struct StructAbstract {
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 
58 template <class charT, class traits>
59 inline
60 std::basic_ostream<charT, traits>&
61 operator<< (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 
86 template <class charT, class traits>
87 inline
88 std::basic_istream<charT, traits>&
89 operator>> (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
virtual const std::string describe() const =0
Handle on the StdAir library context.
void toStream(std::ostream &ioOut) const
Base class for the light structures.
std::basic_istream< charT, traits > & operator>>(std::basic_istream< charT, traits > &ioIn, stdair::StructAbstract &ioStruct)
virtual void fromStream(std::istream &ioIn)