00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include <vaucanson/config/system.hh>
00019
00020 #if not defined (VCSN_XML_XML_CONVERTER_HH) and VCSN_INCLUDE_XML()
00021 # define VCSN_XML_XML_CONVERTER_HH
00022
00023 # ifndef VCSN_USE_XML
00024 # error Vaucanson XML support is disabled.
00025 # endif
00026
00038 # include <xercesc/dom/DOM.hpp>
00039 # include <xercesc/util/XMLString.hpp>
00040 # include <xercesc/util/PlatformUtils.hpp>
00041
00042 # include <string>
00043 # include <sstream>
00044
00045 # include <vaucanson/design_pattern/element.hh>
00046 # include <vaucanson/design_pattern/factory.hh>
00047 # include <vaucanson/misc/usual_macros.hh>
00048 # include <vaucanson/xml/xerces_parser.hh>
00049 # include <vaucanson/xml/node.hh>
00050 # include <vaucanson/xml/xml_chooser.hh>
00051
00052
00053 namespace vcsn
00054 {
00055 namespace xml
00056 {
00063 template <class Auto>
00064 struct xml_converter
00065 {
00066 xml_converter(bool use_label_node = false) :
00067 impl_(0), doc_(0), root_(0), use_label_node_(use_label_node) {};
00068
00069 typedef std::map<hstate_t, std::string> map_t;
00070 typedef typename Auto::set_t auto_set_t;
00071 typedef typename Auto::value_t auto_impl_t;
00072 typedef xml_chooser<auto_set_t, auto_impl_t> xml_chooser_t;
00073
00083 template <class OStream>
00084 void save(const Auto& a, OStream& out, const std::string& name = "");
00085
00094 template <class IStream>
00095 void load(Auto& a, IStream& in);
00096
00097 void create_document(const Auto& aut, const std::string& name = "");
00098
00099 xercesc::DOMElement* root_get() { return root_; }
00100
00101 private:
00102 std::string create_state(hstate_t, const Auto&, xercesc::DOMElement*);
00103 void create_transition(htransition_t, const Auto&,
00104 xercesc::DOMElement*, map_t&);
00105 void create_initial(hstate_t, const Auto&,
00106 xercesc::DOMElement*, map_t&);
00107 void create_final(hstate_t, const Auto&,
00108 xercesc::DOMElement*, map_t&);
00109
00110 template <class Map, class Key>
00111 void add_xml_geometry(Map&, Key&, xercesc::DOMElement* node);
00112 template <class Map, class Key>
00113 void add_xml_drawing(Map&, Key&, xercesc::DOMElement* node);
00114
00115 xercesc::DOMImplementation* impl_;
00116 xercesc::DOMDocument* doc_;
00117 xercesc::DOMElement* root_;
00118 xml_chooser_t chooser_;
00119 bool use_label_node_;
00120 };
00121
00122 }
00123
00124 }
00125
00126
00127 # ifndef VCSN_USE_INTERFACE_ONLY
00128 # include <vaucanson/xml/xml_converter.hxx>
00129 # endif // VCSN_USE_INTERFACE_ONLY
00130
00131 #endif // ! VCSN_XML_XML_CONVERTER_HH && VCSN_INCLUDE_XML()