StdAir Logo  0.44.0
C++ Standard Airline IT Object Library
DbaAbstract.hpp
Go to the documentation of this file.
00001 #ifndef __STDAIR_DBA_DBAABSTRACT_HPP
00002 #define __STDAIR_DBA_DBAABSTRACT_HPP
00003 
00004 // //////////////////////////////////////////////////////////////////////
00005 // Import section
00006 // //////////////////////////////////////////////////////////////////////
00007 // STL
00008 #include <iosfwd>
00009 
00010 namespace stdair {
00011 
00013   class DbaAbstract {
00014   public:
00015 
00017     virtual ~DbaAbstract() {}
00018     
00021     virtual void toStream (std::ostream& ioOut) const {}
00022     
00025     virtual void fromStream (std::istream& ioIn) {}
00026     
00027   protected:
00029     DbaAbstract() {}
00030   };
00031 }
00032 
00038 template <class charT, class traits>
00039 inline
00040 std::basic_ostream<charT, traits>&
00041 operator<< (std::basic_ostream<charT, traits>& ioOut,
00042             const stdair::DbaAbstract& iDba) {
00048   std::basic_ostringstream<charT,traits> ostr;
00049   ostr.copyfmt (ioOut);
00050   ostr.width (0);
00051 
00052   // Fill string stream
00053   iDba.toStream (ostr);
00054 
00055   // Print string stream
00056   ioOut << ostr.str();
00057 
00058   return ioOut;
00059 }
00060 
00066 template <class charT, class traits>
00067 inline
00068 std::basic_istream<charT, traits>&
00069 operator>> (std::basic_istream<charT, traits>& ioIn,
00070             stdair::DbaAbstract& ioDba) {
00071   // Fill Dba object with input stream
00072   ioDba.fromStream (ioIn);
00073   return ioIn;
00074 }
00075 
00076 #endif // __STDAIR_DBA_DBAABSTRACT_HPP