Vaucanson  1.4.1
xml_exp_visitor.hh
Go to the documentation of this file.
1 // xml_exp_visitor.hh: this file is part of the Vaucanson project.
2 //
3 // Vaucanson, a generic library for finite state machines.
4 //
5 // Copyright (C) 2006, 2008 The Vaucanson Group.
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License
9 // as published by the Free Software Foundation; either version 2
10 // of the License, or (at your option) any later version.
11 //
12 // The complete GNU General Public Licence Notice can be found as the
13 // `COPYING' file in the root directory.
14 //
15 // The Vaucanson Group consists of people listed in the `AUTHORS' file.
16 //
17 
18 #ifndef VCSN_XML_XML_EXP_VISITOR_HH
19 # define VCSN_XML_XML_EXP_VISITOR_HH
20 
29 # include <xercesc/dom/DOM.hpp>
30 # include <xercesc/util/XMLString.hpp>
31 # include <xercesc/util/PlatformUtils.hpp>
32 # include <vaucanson/misc/usual_macros.hh>
33 # include <string>
34 # include <cstddef>
35 
36 # include <vaucanson/algebra/implementation/series/rat/nodes.hh>
37 # include <vaucanson/algebra/implementation/series/rat/exp.hh>
38 
39 
40 namespace vcsn {
41 
42  namespace rat {
43 
44  template<typename M_, typename W_>
45  class XmlExpVisitor : public ConstNodeVisitor<M_, W_>
46  {
47  public:
48  XmlExpVisitor(xercesc::DOMDocument* doc, const char* node_name);
49 
50  virtual void
51  product(const Node<M_, W_>* left_, const Node<M_, W_>* right_);
52 
53  virtual void
54  sum(const Node<M_, W_>* left_, const Node<M_, W_>* right_);
55 
56  virtual void
57  star(const Node<M_, W_>* node);
58 
59  virtual void
60  left_weight(const W_&, const Node<M_, W_>* node);
61 
62  virtual void
63  right_weight(const W_&, const Node<M_, W_>* node);
64 
65  virtual void
66  constant(const M_& m);
67 
68  virtual void zero();
69 
70  virtual void one();
71 
72  xercesc::DOMElement* get() const;
73 
74  xercesc::DOMDocument* set(xercesc::DOMDocument* v);
75 
76  protected:
77  void sum_or_product(const Node<M_, W_>* left_, const Node<M_, W_>* right_);
78  void weight_or_star(const Node<M_, W_>* node);
79  template <typename T>
80  void set_weight(const T& w, xercesc::DOMElement* node);
81  template <typename S, typename T>
82  void set_weight(const rat::exp<S, T>& w, xercesc::DOMElement* node);
83 
84  protected:
85  xercesc::DOMDocument* doc_;
86  xercesc::DOMElement* label_;
87  xercesc::DOMElement* current_;
88  };
89 
90  } // rat
91 
92 } // vcsn
93 
94 # if !defined VCSN_USE_INTERFACE_ONLY || defined VCSN_USE_LIB
95 # include <vaucanson/xml/xml_exp_visitor.hxx>
96 # endif // VCSN_USE_INTERFACE_ONLY
97 
98 #endif // ! VCSN_XML_XML_EXP_VISITOR_HH