00001
00002
00003
00004
00005
00006
00007
00008 #ifndef SERIALIZE_XML
00009 #define SERIALIZE_XML
00010
00011 #include <iosfwd>
00012
00013 class FlagXML;
00014
00015
00016
00022 class SerializeXML {
00023 public:
00024 SerializeXML();
00025 ~SerializeXML();
00026
00040 bool write( std::ostream &roOut, const FlagXML &roFLAGXML) const;
00041
00064 template<class T> T *read( std::istream &roIn);
00065
00073 inline FlagXML *getFlag() { return poFlagXML_; }
00074
00075 private:
00086 void readFlag( FlagXML *poFlagXML, std::istream &roIn);
00087
00088 FlagXML *poFlagXML_;
00089 };
00090
00091 template<class T> T *SerializeXML::read( std::istream &roIn) {
00092 if( poFlagXML_) {
00093 delete poFlagXML_;
00094 poFlagXML_ = 0;
00095 }
00096
00097
00098 T *poT = new T();
00099
00100
00101 if( FlagXML *poFlagXML = dynamic_cast<FlagXML *>( poT)) {
00102
00103
00104 try {
00105 readFlag( poFlagXML, roIn);
00106
00107 poFlagXML_ = poFlagXML;
00108 } catch( ...) {
00109
00110 delete poT;
00111 poT = 0;
00112 }
00113 } else {
00114
00115 delete poT;
00116 poT = 0;
00117 }
00118
00119 return poT;
00120 }
00121
00122 #endif // SERIALIZE_XML