xml_converter.hh

Go to the documentation of this file.
00001 // xml_converter.hh: this file is part of the Vaucanson project.
00002 //
00003 // Vaucanson, a generic library for finite state machines.
00004 //
00005 // Copyright (C) 2005, 2006 The Vaucanson Group.
00006 //
00007 // This program is free software; you can redistribute it and/or
00008 // modify it under the terms of the GNU General Public License
00009 // as published by the Free Software Foundation; either version 2
00010 // of the License, or (at your option) any later version.
00011 //
00012 // The complete GNU General Public Licence Notice can be found as the
00013 // `COPYING' file in the root directory.
00014 //
00015 // The Vaucanson Group consists of people listed in the `AUTHORS' file.
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 
00047 namespace vcsn
00048 {
00049   namespace xml
00050   {
00057     template <class Auto>
00058     struct xml_converter
00059     {
00060       xml_converter(bool use_label_node = false) :
00061         impl_(0), doc_(0), root_(0), use_label_node_(use_label_node) {};
00062 
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 
00091       void create_document(const Auto& aut, const std::string& name = "");
00092 
00093       xercesc::DOMElement* root_get() { return root_; }
00094 
00095     private:
00096       std::string create_state(hstate_t, const Auto&, xercesc::DOMElement*);
00097       void create_transition(htransition_t, const Auto&,
00098                              xercesc::DOMElement*, map_t&);
00099       void create_initial(hstate_t, const Auto&,
00100                           xercesc::DOMElement*, map_t&);
00101       void create_final(hstate_t, const Auto&,
00102                         xercesc::DOMElement*, map_t&);
00103 
00104       template <class Map, class Key>
00105       void add_xml_geometry(Map&, Key&, xercesc::DOMElement* node);
00106       template <class Map, class Key>
00107       void add_xml_drawing(Map&, Key&, xercesc::DOMElement* node);
00108 
00109       xercesc::DOMImplementation*  impl_;
00110       xercesc::DOMDocument*        doc_;
00111       xercesc::DOMElement*         root_;
00112       xml_chooser_t                chooser_;
00113       bool                         use_label_node_;
00114     };
00115 
00116   } // !xml
00117 
00118 } // !vcsn
00119 
00120 
00121 # ifndef VCSN_USE_INTERFACE_ONLY
00122 #  include <vaucanson/xml/xml_converter.hxx>
00123 # endif // VCSN_USE_INTERFACE_ONLY
00124 
00125 #endif // ! VCSN_XML_XML_CONVERTER_HH

Generated on Sat Jul 29 17:13:13 2006 for Vaucanson by  doxygen 1.4.6