00001 #ifndef __STDAIR_BAS_STRUCTABSTRACT_HPP
00002 #define __STDAIR_BAS_STRUCTABSTRACT_HPP
00003
00004
00005
00006
00007
00008 #include <iosfwd>
00009 #include <string>
00010
00011 namespace stdair {
00012
00016 struct StructAbstract {
00017 public:
00018
00022 virtual ~StructAbstract() {}
00023
00029 void toStream (std::ostream& ioOut) const {
00030 ioOut << describe();
00031 }
00032
00038 virtual void fromStream (std::istream& ioIn) {}
00039
00043 virtual const std::string describe() const = 0;
00044
00045 protected:
00049 StructAbstract() {}
00050 };
00051 }
00052
00058 template <class charT, class traits>
00059 inline
00060 std::basic_ostream<charT, traits>&
00061 operator<< (std::basic_ostream<charT, traits>& ioOut,
00062 const stdair::StructAbstract& iStruct) {
00068 std::basic_ostringstream<charT,traits> ostr;
00069 ostr.copyfmt (ioOut);
00070 ostr.width (0);
00071
00072
00073 iStruct.toStream (ostr);
00074
00075
00076 ioOut << ostr.str();
00077
00078 return ioOut;
00079 }
00080
00086 template <class charT, class traits>
00087 inline
00088 std::basic_istream<charT, traits>&
00089 operator>> (std::basic_istream<charT, traits>& ioIn,
00090 stdair::StructAbstract& ioStruct) {
00091
00092 ioStruct.fromStream (ioIn);
00093 return ioIn;
00094
00095 }
00096 #endif // __STDAIR_BAS_STRUCTABSTRACT_HPP