- Main Page
- Modules
- Namespaces
- Classes
- Files
- Related Pages

# 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, 2007 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 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 std::map<hstate_t, std::string>           map_t;
    00062       typedef typename Auto::set_t                      auto_set_t;
    00063       typedef typename Auto::value_t                    auto_impl_t;
    00064       typedef xml_chooser<auto_set_t, auto_impl_t>      xml_chooser_t;
    00065
    00075       template <class OStream>
    00076       void save(const Auto& a, OStream& out, const std::string& name = "");
    00077
    00086       template <class IStream>
    00087       void load(Auto& a, IStream& in);
    00088
    00090       void create_document(const Auto& aut, const std::string& name = "");
    00091
    00093       xercesc::DOMElement* root_get();
    00094
    00095     private:
    00096       std::string create_state(hstate_t s, const Auto& aut,
    00097                                xercesc::DOMElement* root);
    00098       void create_transition(htransition_t e, const Auto& aut,
    00099                              xercesc::DOMElement* root, map_t& state2str);
    00100       void create_initial(hstate_t s, const Auto& aut,
    00101                           xercesc::DOMElement* root, map_t& state2str);
    00102       void create_final(hstate_t s, const Auto& aut,
    00103                         xercesc::DOMElement* root, map_t& state2str);
    00104
    00105       template <class Map, class Key>
    00106       void add_xml_geometry(Map& map, Key& key, xercesc::DOMElement* node);
    00107
    00108       template <class Map, class Key>
    00109       void add_xml_drawing(Map& map, Key& key, xercesc::DOMElement* node);
    00110
    00111       xercesc::DOMImplementation*  impl_;
    00112       xercesc::DOMDocument*        doc_;
    00113       xercesc::DOMElement*         root_;
    00114       xml_chooser_t                chooser_;
    00115       bool                         use_label_node_;
    00116     };
    00117
    00118   } // !xml
    00119
    00120 } // !vcsn
    00121
    00122
    00123 # if !defined VCSN_USE_INTERFACE_ONLY || defined VCSN_USE_LIB
    00124 #  include <vaucanson/xml/xml_converter.hxx>
    00125 # endif // VCSN_USE_INTERFACE_ONLY
    00126
    00127 #endif // ! VCSN_XML_XML_CONVERTER_HH