Vaucanson  1.4.1
printers.hh
Go to the documentation of this file.
1 // printers.hh: this file is part of the Vaucanson project.
2 //
3 // Vaucanson, a generic library for finite state machines.
4 //
5 // Copyright (C) 2007 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_PRINTERS_HH
19 # define VCSN_XML_PRINTERS_HH
20 
31 # include <vector>
32 # include <map>
33 # include <iostream>
34 
35 # include <xercesc/dom/DOM.hpp>
36 # include <xercesc/util/XMLString.hpp>
37 # include <xercesc/util/PlatformUtils.hpp>
38 
39 namespace vcsn
40 {
41  namespace xml
42  {
43  /*
44  * Printer class dedicated to parse an FSMXML document.
45  */
46  class Printer
47  {
48  public:
49  Printer ();
50  virtual ~Printer () = 0;
51  };
52 
53  /*
54  * Printer class dedicated to the parse an automaton.
55  */
56  template <typename Auto>
57  class AutPrinter : public Printer
58  {
59  public:
60  AutPrinter (const Auto& aut, const std::string& name = "");
61  virtual ~AutPrinter ();
62 
63  void
64  print (std::ostream& out);
65 
66  protected:
67  typedef typename Auto::hstate_t hstate_t;
68  typedef typename Auto::htransition_t htransition_t;
69  typedef std::map<hstate_t, std::string> map_t;
70  typedef typename Auto::set_t auto_set_t;
71  typedef typename Auto::value_t auto_impl_t;
72  typedef typename Auto::series_set_elt_t series_set_elt_t;
73 
74  std::string
75  create_state(hstate_t s,
76  xercesc::DOMElement* root);
77  void
78  create_transition(htransition_t e,
79  xercesc::DOMElement* root);
80  void
81  create_initial(hstate_t s,
82  xercesc::DOMElement* root);
83  void
84  create_final(hstate_t s,
85  xercesc::DOMElement* root);
86 
87  void
88  create_geometry(hstate_t&,
89  xercesc::DOMElement* root);
90 
91  const Auto& aut_;
92  const std::string& name_;
93 
94  map_t state2str_;
95 
96  xercesc::DOMImplementation* impl_;
97  xercesc::DOMDocument* doc_;
98  xercesc::DOMElement* root_;
99  };
100 
101  /*
102  * Printer class dedicated to the parse a rational expression.
103  */
104  template <typename RE>
105  class RegExpPrinter : public Printer
106  {
107  public:
108  RegExpPrinter (const RE& regexp, const std::string& name = "");
109  virtual ~RegExpPrinter ();
110 
111  void
112  print (std::ostream& out);
113 
114  protected:
115  const RE& regexp_;
116  const std::string& name_;
117 
118  xercesc::DOMImplementation* impl_;
119  xercesc::DOMDocument* doc_;
120  xercesc::DOMElement* root_;
121  };
122  } // !xml
123 } // !vcsn
124 
125 # if !defined VCSN_USE_INTERFACE_ONLY || defined VCSN_USE_LIB
126 # include <vaucanson/xml/printers.hxx>
127 # endif // VCSN_USE_INTERFACE_ONLY
128 
129 #endif // !VCSN_XML_PRINTERS_HH