Go to the documentation of this file.00001 #ifndef __RMOL_BOM_STRUCTABSTRACT_HPP
00002 #define __RMOL_BOM_STRUCTABSTRACT_HPP
00003
00004
00005
00006
00007
00008 #include <iostream>
00009 #include <sstream>
00010
00011 namespace RMOL {
00012
00015 struct StructAbstract {
00016 public:
00017
00019 virtual ~StructAbstract() {}
00020
00023 void toStream (std::ostream& ioOut) const {
00024 ioOut << describe();
00025 }
00026
00029 virtual void fromStream (std::istream& ioIn) {}
00030
00032 virtual const std::string describe() const = 0;
00033
00034 protected:
00036 StructAbstract() {}
00037 };
00038 }
00039
00045 template <class charT, class traits>
00046 inline
00047 std::basic_ostream<charT, traits>&
00048 operator<< (std::basic_ostream<charT, traits>& ioOut,
00049 const RMOL::StructAbstract& iStruct) {
00055 std::basic_ostringstream<charT,traits> ostr;
00056 ostr.copyfmt (ioOut);
00057 ostr.width (0);
00058
00059
00060 iStruct.toStream (ostr);
00061
00062
00063 ioOut << ostr.str();
00064
00065 return ioOut;
00066 }
00067
00073 template <class charT, class traits>
00074 inline
00075 std::basic_istream<charT, traits>&
00076 operator>> (std::basic_istream<charT, traits>& ioIn,
00077 RMOL::StructAbstract& ioStruct) {
00078
00079 ioStruct.fromStream (ioIn);
00080 return ioIn;
00081
00082 }
00083
00084 #endif // __RMOL_BOM_STRUCTABSTRACT_HPP