00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef VCSN_XML_XML_CONVERTER_HH
00019 # define VCSN_XML_XML_CONVERTER_HH
00020
00032 # include <xercesc/dom/DOM.hpp>
00033 # include <xercesc/util/XMLString.hpp>
00034 # include <xercesc/util/PlatformUtils.hpp>
00035
00036 # include <string>
00037 # include <sstream>
00038
00039 # include <vaucanson/design_pattern/element.hh>
00040 # include <vaucanson/design_pattern/factory.hh>
00041 # include <vaucanson/misc/usual_macros.hh>
00042 # include <vaucanson/xml/xerces_parser.hh>
00043 # include <vaucanson/xml/node.hh>
00044 # include <vaucanson/xml/xml_chooser.hh>
00045
00046 namespace vcsn
00047 {
00048 namespace xml
00049 {
00056 template <class Auto>
00057 struct xml_converter
00058 {
00059 xml_converter(bool use_label_node = false);
00060
00061 typedef typename Auto::hstate_t hstate_t;
00062 typedef typename Auto::htransition_t htransition_t;
00063 typedef std::map<hstate_t, std::string> map_t;
00064 typedef typename Auto::set_t auto_set_t;
00065 typedef typename Auto::value_t auto_impl_t;
00066 typedef xml_chooser<auto_set_t, auto_impl_t> xml_chooser_t;
00067
00077 template <class OStream>
00078 void save(const Auto& a, OStream& out, const std::string& name = "");
00079
00088 template <class IStream>
00089 void load(Auto& a, IStream& in);
00090
00092 void create_document(const Auto& aut, const std::string& name = "");
00093
00095 xercesc::DOMElement* root_get();
00096
00097 private:
00098 std::string create_state(hstate_t s, const Auto& aut,
00099 xercesc::DOMElement* root);
00100 void create_transition(htransition_t e, const Auto& aut,
00101 xercesc::DOMElement* root, map_t& state2str);
00102 void create_initial(hstate_t s, const Auto& aut,
00103 xercesc::DOMElement* root, map_t& state2str);
00104 void create_final(hstate_t s, const Auto& aut,
00105 xercesc::DOMElement* root, map_t& state2str);
00106
00107 template <class Map, class Key>
00108 void add_xml_geometry(Map& map, Key& key, xercesc::DOMElement* node);
00109
00110 template <class Map, class Key>
00111 void add_xml_drawing(Map& map, Key& key, xercesc::DOMElement* node);
00112
00113 xercesc::DOMImplementation* impl_;
00114 xercesc::DOMDocument* doc_;
00115 xercesc::DOMElement* root_;
00116 xml_chooser_t chooser_;
00117 bool use_label_node_;
00118 };
00119
00120 }
00121
00122 }
00123
00124
00125 # if !defined VCSN_USE_INTERFACE_ONLY || defined VCSN_USE_LIB
00126 # include <vaucanson/xml/xml_converter.hxx>
00127 # endif // VCSN_USE_INTERFACE_ONLY
00128
00129 #endif // ! VCSN_XML_XML_CONVERTER_HH