00001 // See ../../license.txt for license information. 00002 // 00003 // writeobj.hpp 00004 // 00005 // NOTES 00006 // XML Writer for the persistence framework. 00007 // 00008 // 21-Jul-2003 phamilton Created 00009 // 00010 00011 #ifndef incPERSIST_XML_WRITEOBJ 00012 #define incPERSIST_XML_WRITEOBJ 00013 00014 // forwards 00015 #include <iostream> 00016 #include <string> 00017 #include <map> 00018 #include "../../common/persistable_object.hpp" 00019 #include "../config.hpp" 00020 00021 namespace ph { 00022 namespace persist { 00023 namespace xml { 00024 00025 class PERSIST_DECL writeobj : public ph::common::object_writer 00026 /* 00027 Class for writing objects to XML files. 00028 */ 00029 { 00030 public: 00031 writeobj(std::ostream *stream, std::ostream *console) : 00032 _stream(stream), _console(console), 00033 _tabs(0), _tagname(""), _data(""), _start(true) 00034 {}; 00035 00036 // ph::object_writer overrides 00037 virtual bool start(const std::string &tagname); 00038 virtual bool attr(const std::string &name, const std::string &value); 00039 virtual bool data(const std::string &d); 00040 virtual bool end(const std::string &tagname); 00041 00042 private: 00043 std::ostream *_stream; 00044 std::ostream *_console; 00045 int _tabs; 00046 std::string _tagname; 00047 std::map<std::string, std::string> _attrs; 00048 std::string _data; 00049 bool _start; 00050 00051 void object_start(); 00052 void object_end(const std::string &tagname); 00053 void data_object(); 00054 void tabs(); 00055 void cr(); 00056 }; 00057 00058 }; // xml 00059 }; // persist 00060 }; // ph 00061 00062 #endif // incPERSIST_XML_WRITEOBJ