00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef VCSN_XML_HANDLERS_HH
00019 # define VCSN_XML_HANDLERS_HH
00020
00031 # include <map>
00032 # include <string>
00033
00034 # include <xercesc/sax2/SAX2XMLReader.hpp>
00035 # include <xercesc/sax2/XMLReaderFactory.hpp>
00036 # include <xercesc/sax2/DefaultHandler.hpp>
00037 # include <xercesc/sax2/Attributes.hpp>
00038
00039 # include <xercesc/sax/SAXException.hpp>
00040 # include <xercesc/util/XMLString.hpp>
00041
00042 # include <vaucanson/xml/xmleq.hh>
00043 # include <vaucanson/xml/strings.hh>
00044 # include <vaucanson/xml/handlers_base.hh>
00045 # include <vaucanson/xml/builders.hh>
00046 # include <vaucanson/xml/regexp.hh>
00047
00048 # include <vaucanson/algebra/implementation/series/series_rep.hh>
00049
00050 namespace vcsn
00051 {
00052 namespace xml
00053 {
00057 template <typename T>
00058 class GeometryHandler : public Handler
00059 {
00060 public:
00061 typedef typename T::hstate_t hstate_t;
00062
00063 GeometryHandler (xercesc::SAX2XMLReader* parser,
00064 Handler& root,
00065 T& aut,
00066 hstate_t state);
00067
00068 void
00069 start (const XMLCh* const uri,
00070 const XMLCh* const localname,
00071 const XMLCh* const qname,
00072 const xercesc::Attributes& attrs);
00073 void
00074 end (const XMLCh* const uri,
00075 const XMLCh* const localname,
00076 const XMLCh* const qname);
00077 private:
00078 T& aut_;
00079 hstate_t state_;
00080 };
00084 template <typename T>
00085 class StateHandler : public Handler
00086 {
00087 public:
00088 typedef typename T::hstate_t hstate_t;
00089
00090 StateHandler (xercesc::SAX2XMLReader* parser,
00091 Handler& root,
00092 T& aut,
00093 hstate_t state);
00094
00095 void
00096 start (const XMLCh* const uri,
00097 const XMLCh* const localname,
00098 const XMLCh* const qname,
00099 const xercesc::Attributes& attrs);
00100 void
00101 end (const XMLCh* const uri,
00102 const XMLCh* const localname,
00103 const XMLCh* const qname);
00104 private:
00105 T& aut_;
00106 hstate_t state_;
00107
00108 GeometryHandler<T> geometryh_;
00109 UnsupHandler unsuph_;
00110 };
00111
00115 template <typename T>
00116 class StatesHandler : public Handler
00117 {
00118 public:
00119 typedef typename T::hstate_t hstate_t;
00120 typedef std::map<std::string, hstate_t> map_t;
00121
00122 StatesHandler (xercesc::SAX2XMLReader* parser,
00123 Handler& root,
00124 T& aut,
00125 map_t& map);
00126
00127 void
00128 start (const XMLCh* const uri,
00129 const XMLCh* const localname,
00130 const XMLCh* const qname,
00131 const xercesc::Attributes& attrs);
00132 void
00133 end (const XMLCh* const uri,
00134 const XMLCh* const localname,
00135 const XMLCh* const qname);
00136 private:
00137 T& aut_;
00138 map_t& map_;
00139
00140 StateHandler<T>* stateh_;
00141 };
00142
00146 template <typename T>
00147 class TransitionHandler : public Handler
00148 {
00149 public:
00150 typedef typename T::hstate_t hstate_t;
00151 TransitionHandler (xercesc::SAX2XMLReader* parser,
00152 Handler& root,
00153 T& aut,
00154 hstate_t src,
00155 hstate_t dst);
00156
00157 void
00158 start (const XMLCh* const uri,
00159 const XMLCh* const localname,
00160 const XMLCh* const qname,
00161 const xercesc::Attributes& attrs);
00162 void
00163 end (const XMLCh* const uri,
00164 const XMLCh* const localname,
00165 const XMLCh* const qname);
00166
00167 private:
00168 typedef typename T::series_set_elt_t series_set_elt_t;
00169 T& aut_;
00170 hstate_t src_;
00171 hstate_t dst_;
00172
00173 series_set_elt_t s_;
00174
00175 RegexpHandler<series_set_elt_t> labelh_;
00176 UnsupHandler unsuph_;
00177 };
00178
00182 template <typename T>
00183 class InitFinalHandler : public Handler
00184 {
00185 public:
00186 typedef typename T::hstate_t hstate_t;
00187 InitFinalHandler (xercesc::SAX2XMLReader* parser,
00188 Handler& root,
00189 T& aut,
00190 hstate_t state,
00191 bool initial = true);
00192
00193 void
00194 start (const XMLCh* const uri,
00195 const XMLCh* const localname,
00196 const XMLCh* const qname,
00197 const xercesc::Attributes& attrs);
00198 void
00199 end (const XMLCh* const uri,
00200 const XMLCh* const localname,
00201 const XMLCh* const qname);
00202
00203 private:
00204 typedef typename T::series_set_elt_t series_set_elt_t;
00205 T& aut_;
00206 hstate_t state_;
00207
00208 bool initial_;
00209 series_set_elt_t s_;
00210
00211 RegexpHandler<series_set_elt_t> labelh_;
00212 UnsupHandler unsuph_;
00213 };
00214
00218 template <typename T>
00219 class TransitionsHandler : public Handler
00220 {
00221 public:
00222 typedef typename T::hstate_t hstate_t;
00223 typedef std::map<std::string, hstate_t> map_t;
00224
00225 TransitionsHandler (xercesc::SAX2XMLReader* parser,
00226 Handler& root,
00227 T& aut,
00228 map_t& map);
00229
00230 void
00231 start (const XMLCh* const uri,
00232 const XMLCh* const localname,
00233 const XMLCh* const qname,
00234 const xercesc::Attributes& attrs);
00235 void
00236 end (const XMLCh* const uri,
00237 const XMLCh* const localname,
00238 const XMLCh* const qname);
00239 private:
00240 T& aut_;
00241 map_t& map_;
00242
00243 Handler* transitionh_;
00244 };
00245
00249 template <typename T>
00250 class ContHandler : public Handler
00251 {
00252 public:
00253 ContHandler (xercesc::SAX2XMLReader* parser,
00254 Handler& root,
00255 T& aut);
00256
00257 void
00258 start (const XMLCh* const uri,
00259 const XMLCh* const localname,
00260 const XMLCh* const qname,
00261 const xercesc::Attributes& attrs);
00262 void
00263 end (const XMLCh* const uri,
00264 const XMLCh* const localname,
00265 const XMLCh* const qname);
00266 private:
00267 typedef typename T::hstate_t hstate_t;
00268 typedef std::map<std::string, hstate_t> map_t;
00269
00270 T& aut_;
00271 map_t map_;
00272
00273
00274 StatesHandler<T> statesh_;
00275 TransitionsHandler<T> transitionsh_;
00276 };
00277
00281 template <typename T>
00282 class TypeHandler : public Handler
00283 {
00284 public:
00285 TypeHandler (xercesc::SAX2XMLReader* parser,
00286 Handler& root,
00287 T& param);
00288
00289 void
00290 start (const XMLCh* const uri,
00291 const XMLCh* const localname,
00292 const XMLCh* const qname,
00293 const xercesc::Attributes& attrs);
00294 void
00295 end (const XMLCh* const uri,
00296 const XMLCh* const localname,
00297 const XMLCh* const qname);
00298 private:
00299 typedef typename T::monoid_t monoid_t;
00300 typedef typename T::semiring_t semiring_t;
00301 typedef typename T::series_set_t series_set_t;
00302
00303 monoid_t* monoid_;
00304 semiring_t* semiring_;
00305 algebra::series_rep<semiring_t, monoid_t> rep_;
00306
00307
00308
00309 T& param_;
00310 Handler* monoidh_;
00311 Handler* semiringh_;
00312 UnsupHandler unsuph_;
00313 };
00314
00318 template <typename T>
00319 class AutHandler : public Handler
00320 {
00321 public:
00322 AutHandler (xercesc::SAX2XMLReader* parser,
00323 Handler& root,
00324 T& aut);
00325
00326 void
00327 start (const XMLCh* const uri,
00328 const XMLCh* const localname,
00329 const XMLCh* const qname,
00330 const xercesc::Attributes& attrs);
00331 void
00332 end (const XMLCh* const uri,
00333 const XMLCh* const localname,
00334 const XMLCh* const qname);
00335 private:
00336 T& aut_;
00337
00338 TypeHandler<T> typeh_;
00339 ContHandler<T> contenth_;
00340 UnsupHandler unsuph_;
00341 };
00342
00347 template <typename T>
00348 class DocHandler : public Handler
00349 {
00350 public:
00351 DocHandler (xercesc::SAX2XMLReader* parser,
00352 xercesc::DefaultHandler& root,
00353 T& aut,
00354 XMLEq& eq);
00355 void
00356 start (const XMLCh* const uri,
00357 const XMLCh* const localname,
00358 const XMLCh* const qname,
00359 const xercesc::Attributes& attrs);
00360 void
00361 end (const XMLCh* const uri,
00362 const XMLCh* const localname,
00363 const XMLCh* const qname);
00364 private:
00365 T& aut_;
00366
00367 AutHandler<T> auth_;
00368
00369 };
00370
00371 }
00372 }
00373
00374 # if ! defined VCSN_USE_INTERFACE_ONLY || defined VCSN_USE_LIB
00375 # include <vaucanson/xml/handlers.hxx>
00376 # endif // !VCSN_USE_INTERFACE_ONLY || VCSN_USE_LIB
00377
00378 #endif // !VCSN_XML_HANDLERS_HH