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

- File List
- File Members

# builders.hh

Go to the documentation of this file.

    00001 // builders.hh: this file is part of the Vaucanson project.
    00002 //
    00003 // Vaucanson, a generic library for finite state machines.
    00004 //
    00005 // Copyright (C) 2007, 2008, 2009 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_BUILDERS_HH
    00019 # define VCSN_XML_BUILDERS_HH
    00020
    00031 # include <string>
    00032
    00033 // These includes are here to satisfy sanity checks, but we need a way
    00034 // to force the inclusion of the XML related headers after the automaton
    00035 // type is fully constructed (no undefined_type), and improve sanity
    00036 // checks.
    00037 # include <vaucanson/algebra/implementation/monoid/free_monoid.hh>
    00038 # include <vaucanson/algebra/implementation/series/series.hh>
    00039
    00040 # include <xercesc/sax2/Attributes.hpp>
    00041 # include <xercesc/util/XMLString.hpp>
    00042 # include <xercesc/dom/DOM.hpp>
    00043
    00044 # include <vaucanson/xml/handlers_base.hh>
    00045
    00046 namespace vcsn
    00047 {
    00048   namespace xml
    00049   {
    00053     template <typename T>
    00054     class monGenAction
    00055     {
    00056     public:
    00057       monGenAction(const T&);
    00058     };
    00059
    00060     // An action on a free monoid (insert monGen inside its alphabet)
    00061     template <typename T>
    00062     class monGenAction<vcsn::algebra::FreeMonoid<T> >
    00063     {
    00064     public:
    00065       typedef vcsn::algebra::FreeMonoid<T> monoid_t;
    00066       typedef typename monoid_t::alphabet_t alphabet_t;
    00067
    00068       monGenAction(monoid_t&);
    00069       void operator () (const std::string&);
    00070     private:
    00071       alphabet_t& alphabet_;
    00072     };
    00073
    00074     // An action on a series element (multiply it by monGen)
    00075     template <typename T, typename U, typename V>
    00076     class monGenAction<vcsn::Element<vcsn::algebra::Series<T, U>, V> >
    00077     {
    00078     public:
    00079       typedef vcsn::Element<vcsn::algebra::Series<T, U>, V>     series_t;
    00080       typedef typename series_t::set_t::monoid_t                monoid_t;
    00081       typedef typename monoid_t::alphabet_t                     alphabet_t;
    00082       typedef typename alphabet_t::letter_t                     letter_t;
    00083
    00084       monGenAction(series_t&);
    00085       void operator () (const std::string&);
    00086     private:
    00087       series_t& s_;
    00088     };
    00089
    00096     template <typename T, typename U>
    00097     class monGenHandler : public Handler
    00098     {
    00099       public:
    00100         monGenHandler (xercesc::SAX2XMLReader* parser,
    00101                      Handler& root,
    00102                      const monGenAction<U>& action,
    00103                      const XMLCh* value = 0);
    00104
    00105         void
    00106         start (const XMLCh* const uri,
    00107                       const XMLCh* const localname,
    00108                       const XMLCh* const qname,
    00109                       const xercesc::Attributes& attrs);
    00110         void
    00111         end (const XMLCh* const uri,
    00112                     const XMLCh* const localname,
    00113                     const XMLCh* const qname);
    00114       private:
    00115         const XMLCh*    value_;
    00116
    00117         // What to do with value_.
    00118         monGenAction<U> action_;
    00119     };
    00120
    00127     template <typename T, typename U>
    00128     class monGenTupleHandler : public Handler
    00129     {
    00130       public:
    00131         monGenTupleHandler (xercesc::SAX2XMLReader* parser,
    00132                      Handler& root,
    00133                      const monGenAction<U>& action);
    00134
    00135         void
    00136         start (const XMLCh* const uri,
    00137                       const XMLCh* const localname,
    00138                       const XMLCh* const qname,
    00139                       const xercesc::Attributes& attrs);
    00140         void
    00141         end (const XMLCh* const uri,
    00142                     const XMLCh* const localname,
    00143                     const XMLCh* const qname);
    00144       private:
    00145         std::string     value_;
    00146         bool            wait_begin_;
    00147         int             count_;
    00148
    00149         // What to do with value_.
    00150         monGenAction<U> action_;
    00151     };
    00152
    00156     template <typename T>
    00157     class FreeMonoidHandler : public Handler
    00158     {
    00159       public:
    00160         FreeMonoidHandler (xercesc::SAX2XMLReader* parser,
    00161                      Handler& root,
    00162                      T& monoid);
    00163
    00164         void
    00165         start (const XMLCh* const uri,
    00166                       const XMLCh* const localname,
    00167                       const XMLCh* const qname,
    00168                       const xercesc::Attributes& attrs);
    00169         void
    00170         end (const XMLCh* const uri,
    00171                     const XMLCh* const localname,
    00172                     const XMLCh* const qname);
    00173       private:
    00174         T&              monoid_;
    00175         bool            user_rep_;
    00176
    00177         Handler*        mongenh_;
    00178         UnsupHandler    unsuph_;
    00179     };
    00180
    00184     template <typename T>
    00185     class SeriesRepresentationHandler : public Handler
    00186     {
    00187       public:
    00188         SeriesRepresentationHandler(xercesc::SAX2XMLReader* parser,
    00189                                     Handler& root,
    00190                                     T& srep);
    00191
    00192         void start(const XMLCh* const uri,
    00193                    const XMLCh* const localname,
    00194                    const XMLCh* const qname,
    00195                    const xercesc::Attributes& attrs);
    00196
    00197         void end(const XMLCh* const uri,
    00198                  const XMLCh* const localname,
    00199                  const XMLCh* const qname);
    00200
    00201       private:
    00202         T&              rep_;
    00203
    00204         UnsupHandler    unsuph_;
    00205     };
    00206
    00207     namespace builders
    00208     {
    00209       template <typename T>
    00210       typename T::monoid_t*
    00211       create_monoid (T&,
    00212                      const XMLCh* const localname,
    00213                      const xercesc::Attributes& attrs,
    00214                      XMLEq&);
    00215
    00216       template <typename T>
    00217       Handler*
    00218       create_monoidh (T& monoid,
    00219                       const xercesc::Attributes& attrs,
    00220                       xercesc::SAX2XMLReader* parser,
    00221                       Handler& root);
    00222
    00223       template <typename T>
    00224       typename T::series_set_t::series_rep_t*
    00225       create_series_representation(T&,
    00226                                    const XMLCh* const localname,
    00227                                    const xercesc::Attributes& attrs,
    00228                                    XMLEq&);
    00229
    00230       template <typename T>
    00231       Handler*
    00232       create_series_representationh(T& srep,
    00233                                     const xercesc::Attributes& attrs,
    00234                                     xercesc::SAX2XMLReader* parser,
    00235                                     Handler& root,
    00236                                     XMLEq&);
    00237
    00238     } // ! builders
    00239
    00243     template <typename T>
    00244     class NumSemiringHandler : public Handler
    00245     {
    00246       public:
    00247         NumSemiringHandler (xercesc::SAX2XMLReader* parser,
    00248                      Handler& root,
    00249                      T& semiring);
    00250
    00251         void
    00252         start (const XMLCh* const uri,
    00253                       const XMLCh* const localname,
    00254                       const XMLCh* const qname,
    00255                       const xercesc::Attributes& attrs);
    00256         void
    00257         end (const XMLCh* const uri,
    00258                     const XMLCh* const localname,
    00259                     const XMLCh* const qname);
    00260       private:
    00261         T&              semiring_;
    00262
    00263         UnsupHandler    unsuph_;
    00264     };
    00265
    00266     namespace builders
    00267     {
    00268       template <typename T>
    00269       typename T::semiring_t*
    00270       create_semiring (T&,
    00271                        const XMLCh* const localname,
    00272                        const xercesc::Attributes& attrs);
    00273
    00274       template <typename T>
    00275       Handler*
    00276       create_semiringh (T& semiring,
    00277                         const xercesc::Attributes& attrs,
    00278                         xercesc::SAX2XMLReader* parser,
    00279                         Handler& root);
    00280
    00281     } // !builders
    00282
    00286     template <typename T>
    00287     class RegexpHandler;
    00288
    00289     namespace builders
    00290     {
    00291
    00292       template <typename S, typename T>
    00293       RegexpHandler<S>*
    00294       create_monElmth(xercesc::SAX2XMLReader* parser,
    00295                       RegexpHandler<T>& root,
    00296                       S param);
    00297
    00298       template <typename T>
    00299       RegexpHandler<T>*
    00300       create_weight(xercesc::SAX2XMLReader* parser,
    00301                     RegexpHandler<T>& root,
    00302                     T param,
    00303                     const xercesc::Attributes& attrs);
    00304     } // !builders
    00305
    00309     namespace builders
    00310     {
    00311       template <typename T>
    00312       void
    00313       check_monoid_consistency (T& param,
    00314                                 const XMLCh* const localname,
    00315                                 const xercesc::Attributes& attrs,
    00316                                 XMLEq&);
    00317
    00318       template <typename T>
    00319       void
    00320       check_semiring_consistency (T& param,
    00321                                   const XMLCh* const localname,
    00322                                   const xercesc::Attributes& attrs);
    00323     } // !builders
    00324
    00328     namespace builders
    00329     {
    00330       template <typename T>
    00331       void
    00332       create_semiring_node(const T& semiring,
    00333                            xercesc::DOMDocument* doc,
    00334                            xercesc::DOMElement* root);
    00335
    00336       template <typename T>
    00337       void
    00338       create_monoid_node(const T& monoid,
    00339                          xercesc::DOMDocument* doc,
    00340                          xercesc::DOMElement* root);
    00341
    00342       template <typename T>
    00343       void
    00344       create_regexp_node(const T&,
    00345                          xercesc::DOMDocument* doc,
    00346                          xercesc::DOMElement* root,
    00347                          const char* root_name = "label");
    00348
    00349       template <typename T>
    00350       void
    00351       create_monElmt_node(const T&,
    00352                           xercesc::DOMDocument* doc,
    00353                           xercesc::DOMElement* root);
    00354
    00355       template <typename T>
    00356       void
    00357       create_type_writingData_node(const T&,
    00358                                    xercesc::DOMDocument* doc,
    00359                                    xercesc::DOMElement* root);
    00360
    00361       // Functor to allow partial specialization.
    00362       template <typename T>
    00363       struct
    00364       create_monGen_node;
    00365
    00366     } // ! builders
    00367
    00368   } // ! xml
    00369
    00370 } // ! vcsn
    00371
    00372 # if !defined VCSN_USE_INTERFACE_ONLY || defined VCSN_USE_LIB
    00373 #  include <vaucanson/xml/builders.hxx>
    00374 # endif // VCSN_USE_INTERFACE_ONLY || !VCSN_USE_LIB
    00375
    00376 #endif // !VCSN_XML_BUILDERS_HH