Vaucanson 1.4
|
00001 // regexp.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, 2011 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_REGEXP_HH 00019 # define VCSN_XML_REGEXP_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 00047 namespace vcsn 00048 { 00049 namespace xml 00050 { 00054 template <typename T> 00055 class RegexpHandler : public Handler 00056 { 00057 public: 00058 RegexpHandler (xercesc::SAX2XMLReader* parser, 00059 Handler& root, 00060 T param); 00061 RegexpHandler (xercesc::SAX2XMLReader* parser, 00062 Handler& root, 00063 T param, 00064 XMLCh* end); 00065 virtual ~RegexpHandler (); 00066 00067 void 00068 start (const XMLCh* const uri, 00069 const XMLCh* const localname, 00070 const XMLCh* const qname, 00071 const xercesc::Attributes& attrs); 00072 void 00073 end (const XMLCh* const uri, 00074 const XMLCh* const localname, 00075 const XMLCh* const qname); 00076 00077 T& series(); 00078 00079 T& series(T& param); 00080 // Create the Handler accordingly to localname 00081 // Return 0 if localname is incorrect. 00082 RegexpHandler<T>* 00083 create (const XMLCh* const localname); 00084 00085 protected: 00086 RegexpHandler<T>* 00087 create_weight (const xercesc::Attributes& attrs); 00088 00089 XMLCh* end_; 00090 00091 T param_; 00092 00093 RegexpHandler<T>* lefth_; 00094 }; 00098 template <typename T> 00099 class WeightHandler : public RegexpHandler<T> 00100 { 00101 // Access to base class protected members. 00102 using RegexpHandler<T>::parser_; 00103 using RegexpHandler<T>::eq_; 00104 using RegexpHandler<T>::root_; 00105 using RegexpHandler<T>::end_; 00106 00107 public: 00108 WeightHandler (xercesc::SAX2XMLReader* parser, 00109 Handler& root, 00110 T param); 00111 00112 void 00113 start (const XMLCh* const uri, 00114 const XMLCh* const localname, 00115 const XMLCh* const qname, 00116 const xercesc::Attributes& attrs); 00117 void 00118 end (const XMLCh* const uri, 00119 const XMLCh* const localname, 00120 const XMLCh* const qname); 00121 }; 00125 template <typename T> 00126 class ExtMulHandler : public RegexpHandler<T> 00127 { 00128 // Access to base class protected members. 00129 using RegexpHandler<T>::parser_; 00130 using RegexpHandler<T>::eq_; 00131 using RegexpHandler<T>::root_; 00132 using RegexpHandler<T>::end_; 00133 using RegexpHandler<T>::param_; 00134 using RegexpHandler<T>::lefth_; 00135 using RegexpHandler<T>::create_weight; 00136 using RegexpHandler<T>::create; 00137 00138 public: 00139 ExtMulHandler (xercesc::SAX2XMLReader* parser, 00140 Handler& root, 00141 T param, 00142 bool left); 00143 virtual ~ExtMulHandler(); 00144 00145 void 00146 start (const XMLCh* const uri, 00147 const XMLCh* const localname, 00148 const XMLCh* const qname, 00149 const xercesc::Attributes& attrs); 00150 void 00151 end (const XMLCh* const uri, 00152 const XMLCh* const localname, 00153 const XMLCh* const qname); 00154 private: 00155 bool left_; 00156 RegexpHandler<T>* righth_; 00157 }; 00161 template <typename T> 00162 class StarHandler : public RegexpHandler<T> 00163 { 00164 // Access to base class protected members. 00165 using RegexpHandler<T>::parser_; 00166 using RegexpHandler<T>::eq_; 00167 using RegexpHandler<T>::root_; 00168 using RegexpHandler<T>::end_; 00169 using RegexpHandler<T>::param_; 00170 using RegexpHandler<T>::lefth_; 00171 using RegexpHandler<T>::create; 00172 00173 public: 00174 StarHandler (xercesc::SAX2XMLReader* parser, 00175 Handler& root, 00176 T param); 00177 00178 void 00179 start (const XMLCh* const uri, 00180 const XMLCh* const localname, 00181 const XMLCh* const qname, 00182 const xercesc::Attributes& attrs); 00183 void 00184 end (const XMLCh* const uri, 00185 const XMLCh* const localname, 00186 const XMLCh* const qname); 00187 private: 00188 int in_; 00189 }; 00193 template <typename T> 00194 class ProductHandler : public RegexpHandler<T> 00195 { 00196 // Access to base class protected members. 00197 using RegexpHandler<T>::parser_; 00198 using RegexpHandler<T>::eq_; 00199 using RegexpHandler<T>::root_; 00200 using RegexpHandler<T>::end_; 00201 using RegexpHandler<T>::param_; 00202 using RegexpHandler<T>::lefth_; 00203 using RegexpHandler<T>::create; 00204 00205 public: 00206 ProductHandler (xercesc::SAX2XMLReader* parser, 00207 Handler& root, 00208 T param); 00209 virtual ~ProductHandler (); 00210 00211 void 00212 start (const XMLCh* const uri, 00213 const XMLCh* const localname, 00214 const XMLCh* const qname, 00215 const xercesc::Attributes& attrs); 00216 void 00217 end (const XMLCh* const uri, 00218 const XMLCh* const localname, 00219 const XMLCh* const qname); 00220 private: 00221 int in_; 00222 RegexpHandler<T>* righth_; 00223 }; 00227 template <typename T> 00228 class SumHandler : public RegexpHandler<T> 00229 { 00230 // Access to base class protected members. 00231 using RegexpHandler<T>::parser_; 00232 using RegexpHandler<T>::eq_; 00233 using RegexpHandler<T>::root_; 00234 using RegexpHandler<T>::end_; 00235 using RegexpHandler<T>::param_; 00236 using RegexpHandler<T>::lefth_; 00237 using RegexpHandler<T>::create; 00238 00239 public: 00240 SumHandler (xercesc::SAX2XMLReader* parser, 00241 Handler& root, 00242 T param); 00243 virtual ~SumHandler (); 00244 00245 void 00246 start (const XMLCh* const uri, 00247 const XMLCh* const localname, 00248 const XMLCh* const qname, 00249 const xercesc::Attributes& attrs); 00250 void 00251 end (const XMLCh* const uri, 00252 const XMLCh* const localname, 00253 const XMLCh* const qname); 00254 private: 00255 int in_; 00256 RegexpHandler<T>* righth_; 00257 }; 00261 template <typename T> 00262 class MonElmtHandler : public RegexpHandler<T> 00263 { 00264 // Access to base class protected members. 00265 using RegexpHandler<T>::parser_; 00266 using RegexpHandler<T>::eq_; 00267 using RegexpHandler<T>::root_; 00268 using RegexpHandler<T>::end_; 00269 using RegexpHandler<T>::param_; 00270 00271 public: 00272 MonElmtHandler (xercesc::SAX2XMLReader* parser, 00273 Handler& root, 00274 T param); 00275 00276 void 00277 start (const XMLCh* const uri, 00278 const XMLCh* const localname, 00279 const XMLCh* const qname, 00280 const xercesc::Attributes& attrs); 00281 void 00282 end (const XMLCh* const uri, 00283 const XMLCh* const localname, 00284 const XMLCh* const qname); 00285 private: 00286 Handler* mongenh_; 00287 }; 00291 template <typename T> 00292 class AtomHandler : public RegexpHandler<T> 00293 { 00294 // Access to base class protected members. 00295 using RegexpHandler<T>::parser_; 00296 using RegexpHandler<T>::root_; 00297 using RegexpHandler<T>::end_; 00298 00299 public: 00300 AtomHandler (xercesc::SAX2XMLReader* parser, 00301 Handler& root, 00302 T param, 00303 XMLCh* end); 00304 void 00305 start (const XMLCh* const uri, 00306 const XMLCh* const localname, 00307 const XMLCh* const qname, 00308 const xercesc::Attributes& attrs); 00309 void 00310 end (const XMLCh* const uri, 00311 const XMLCh* const localname, 00312 const XMLCh* const qname); 00313 }; 00314 } // !xml 00315 } // !vcsn 00316 00317 # if ! defined VCSN_USE_INTERFACE_ONLY || defined VCSN_USE_LIB 00318 # include <vaucanson/xml/regexp.hxx> 00319 # endif // !VCSN_USE_INTERFACE_ONLY || VCSN_USE_LIB 00320 00321 #endif // !VCSN_XML_REGEXP_HH