Vaucanson  1.4.1
regexp.hh
1 // regexp.hh: this file is part of the Vaucanson project.
2 //
3 // Vaucanson, a generic library for finite state machines.
4 //
5 // Copyright (C) 2007, 2008, 2011 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_REGEXP_HH
19 # define VCSN_XML_REGEXP_HH
20 
31 # include <map>
32 # include <string>
33 
34 # include <xercesc/sax2/SAX2XMLReader.hpp>
35 # include <xercesc/sax2/XMLReaderFactory.hpp>
36 # include <xercesc/sax2/DefaultHandler.hpp>
37 # include <xercesc/sax2/Attributes.hpp>
38 
39 # include <xercesc/sax/SAXException.hpp>
40 # include <xercesc/util/XMLString.hpp>
41 
42 # include <vaucanson/xml/xmleq.hh>
43 # include <vaucanson/xml/strings.hh>
44 # include <vaucanson/xml/handlers_base.hh>
45 # include <vaucanson/xml/builders.hh>
46 
47 namespace vcsn
48 {
49  namespace xml
50  {
54  template <typename T>
55  class RegexpHandler : public Handler
56  {
57  public:
58  RegexpHandler (xercesc::SAX2XMLReader* parser,
59  Handler& root,
60  T param);
61  RegexpHandler (xercesc::SAX2XMLReader* parser,
62  Handler& root,
63  T param,
64  XMLCh* end);
65  virtual ~RegexpHandler ();
66 
67  void
68  start (const XMLCh* const uri,
69  const XMLCh* const localname,
70  const XMLCh* const qname,
71  const xercesc::Attributes& attrs);
72  void
73  end (const XMLCh* const uri,
74  const XMLCh* const localname,
75  const XMLCh* const qname);
76 
77  T& series();
78 
79  T& series(T& param);
80  // Create the Handler accordingly to localname
81  // Return 0 if localname is incorrect.
83  create (const XMLCh* const localname);
84 
85  protected:
87  create_weight (const xercesc::Attributes& attrs);
88 
89  XMLCh* end_;
90 
91  T param_;
92 
93  RegexpHandler<T>* lefth_;
94  };
98  template <typename T>
99  class WeightHandler : public RegexpHandler<T>
100  {
101  // Access to base class protected members.
103  using RegexpHandler<T>::eq_;
106 
107  public:
108  WeightHandler (xercesc::SAX2XMLReader* parser,
109  Handler& root,
110  T param);
111 
112  void
113  start (const XMLCh* const uri,
114  const XMLCh* const localname,
115  const XMLCh* const qname,
116  const xercesc::Attributes& attrs);
117  void
118  end (const XMLCh* const uri,
119  const XMLCh* const localname,
120  const XMLCh* const qname);
121  };
125  template <typename T>
126  class ExtMulHandler : public RegexpHandler<T>
127  {
128  // Access to base class protected members.
130  using RegexpHandler<T>::eq_;
137 
138  public:
139  ExtMulHandler (xercesc::SAX2XMLReader* parser,
140  Handler& root,
141  T param,
142  bool left);
143  virtual ~ExtMulHandler();
144 
145  void
146  start (const XMLCh* const uri,
147  const XMLCh* const localname,
148  const XMLCh* const qname,
149  const xercesc::Attributes& attrs);
150  void
151  end (const XMLCh* const uri,
152  const XMLCh* const localname,
153  const XMLCh* const qname);
154  private:
155  bool left_;
156  RegexpHandler<T>* righth_;
157  };
161  template <typename T>
162  class StarHandler : public RegexpHandler<T>
163  {
164  // Access to base class protected members.
166  using RegexpHandler<T>::eq_;
172 
173  public:
174  StarHandler (xercesc::SAX2XMLReader* parser,
175  Handler& root,
176  T param);
177 
178  void
179  start (const XMLCh* const uri,
180  const XMLCh* const localname,
181  const XMLCh* const qname,
182  const xercesc::Attributes& attrs);
183  void
184  end (const XMLCh* const uri,
185  const XMLCh* const localname,
186  const XMLCh* const qname);
187  private:
188  int in_;
189  };
193  template <typename T>
194  class ProductHandler : public RegexpHandler<T>
195  {
196  // Access to base class protected members.
198  using RegexpHandler<T>::eq_;
204 
205  public:
206  ProductHandler (xercesc::SAX2XMLReader* parser,
207  Handler& root,
208  T param);
209  virtual ~ProductHandler ();
210 
211  void
212  start (const XMLCh* const uri,
213  const XMLCh* const localname,
214  const XMLCh* const qname,
215  const xercesc::Attributes& attrs);
216  void
217  end (const XMLCh* const uri,
218  const XMLCh* const localname,
219  const XMLCh* const qname);
220  private:
221  int in_;
222  RegexpHandler<T>* righth_;
223  };
227  template <typename T>
228  class SumHandler : public RegexpHandler<T>
229  {
230  // Access to base class protected members.
232  using RegexpHandler<T>::eq_;
238 
239  public:
240  SumHandler (xercesc::SAX2XMLReader* parser,
241  Handler& root,
242  T param);
243  virtual ~SumHandler ();
244 
245  void
246  start (const XMLCh* const uri,
247  const XMLCh* const localname,
248  const XMLCh* const qname,
249  const xercesc::Attributes& attrs);
250  void
251  end (const XMLCh* const uri,
252  const XMLCh* const localname,
253  const XMLCh* const qname);
254  private:
255  int in_;
256  RegexpHandler<T>* righth_;
257  };
261  template <typename T>
262  class MonElmtHandler : public RegexpHandler<T>
263  {
264  // Access to base class protected members.
266  using RegexpHandler<T>::eq_;
270 
271  public:
272  MonElmtHandler (xercesc::SAX2XMLReader* parser,
273  Handler& root,
274  T param);
275 
276  void
277  start (const XMLCh* const uri,
278  const XMLCh* const localname,
279  const XMLCh* const qname,
280  const xercesc::Attributes& attrs);
281  void
282  end (const XMLCh* const uri,
283  const XMLCh* const localname,
284  const XMLCh* const qname);
285  private:
286  Handler* mongenh_;
287  };
291  template <typename T>
292  class AtomHandler : public RegexpHandler<T>
293  {
294  // Access to base class protected members.
298 
299  public:
300  AtomHandler (xercesc::SAX2XMLReader* parser,
301  Handler& root,
302  T param,
303  XMLCh* end);
304  void
305  start (const XMLCh* const uri,
306  const XMLCh* const localname,
307  const XMLCh* const qname,
308  const xercesc::Attributes& attrs);
309  void
310  end (const XMLCh* const uri,
311  const XMLCh* const localname,
312  const XMLCh* const qname);
313  };
314  } // !xml
315 } // !vcsn
316 
317 # if ! defined VCSN_USE_INTERFACE_ONLY || defined VCSN_USE_LIB
318 # include <vaucanson/xml/regexp.hxx>
319 # endif // !VCSN_USE_INTERFACE_ONLY || VCSN_USE_LIB
320 
321 #endif // !VCSN_XML_REGEXP_HH