Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

xml_converter.hh

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 #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   } // !xml
00123 
00124 } // !vcsn
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()

Generated on Mon Jul 24 16:56:39 2006 for Vaucanson by  doxygen 1.4.4