00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
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
00080 RegexpHandler<T>*
00081 create (const XMLCh* const localname);
00082
00083 protected:
00084 RegexpHandler<T>*
00085 create_weight (const xercesc::Attributes& attrs);
00086
00087 XMLCh* end_;
00088
00089 T param_;
00090
00091 RegexpHandler<T>* lefth_;
00092 };
00096 template <typename T>
00097 class WeightHandler : public RegexpHandler<T>
00098 {
00099 public:
00100 WeightHandler (xercesc::SAX2XMLReader* parser,
00101 Handler& root,
00102 T param);
00103
00104 void
00105 start (const XMLCh* const uri,
00106 const XMLCh* const localname,
00107 const XMLCh* const qname,
00108 const xercesc::Attributes& attrs);
00109 void
00110 end (const XMLCh* const uri,
00111 const XMLCh* const localname,
00112 const XMLCh* const qname);
00113 };
00117 template <typename T>
00118 class ExtMulHandler : public RegexpHandler<T>
00119 {
00120 public:
00121 ExtMulHandler (xercesc::SAX2XMLReader* parser,
00122 Handler& root,
00123 T param,
00124 bool left);
00125 virtual ~ExtMulHandler();
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 bool left_;
00138 RegexpHandler<T>* righth_;
00139 };
00143 template <typename T>
00144 class StarHandler : public RegexpHandler<T>
00145 {
00146 public:
00147 StarHandler (xercesc::SAX2XMLReader* parser,
00148 Handler& root,
00149 T param);
00150
00151 void
00152 start (const XMLCh* const uri,
00153 const XMLCh* const localname,
00154 const XMLCh* const qname,
00155 const xercesc::Attributes& attrs);
00156 void
00157 end (const XMLCh* const uri,
00158 const XMLCh* const localname,
00159 const XMLCh* const qname);
00160 private:
00161 int in_;
00162 };
00166 template <typename T>
00167 class ProductHandler : public RegexpHandler<T>
00168 {
00169 public:
00170 ProductHandler (xercesc::SAX2XMLReader* parser,
00171 Handler& root,
00172 T param);
00173 virtual ~ProductHandler ();
00174
00175 void
00176 start (const XMLCh* const uri,
00177 const XMLCh* const localname,
00178 const XMLCh* const qname,
00179 const xercesc::Attributes& attrs);
00180 void
00181 end (const XMLCh* const uri,
00182 const XMLCh* const localname,
00183 const XMLCh* const qname);
00184 private:
00185 int in_;
00186 RegexpHandler<T>* righth_;
00187 };
00191 template <typename T>
00192 class SumHandler : public RegexpHandler<T>
00193 {
00194 public:
00195 SumHandler (xercesc::SAX2XMLReader* parser,
00196 Handler& root,
00197 T param);
00198 virtual ~SumHandler ();
00199
00200 void
00201 start (const XMLCh* const uri,
00202 const XMLCh* const localname,
00203 const XMLCh* const qname,
00204 const xercesc::Attributes& attrs);
00205 void
00206 end (const XMLCh* const uri,
00207 const XMLCh* const localname,
00208 const XMLCh* const qname);
00209 private:
00210 int in_;
00211 RegexpHandler<T>* righth_;
00212 };
00216 template <typename T>
00217 class MonElmtHandler : public RegexpHandler<T>
00218 {
00219 public:
00220 MonElmtHandler (xercesc::SAX2XMLReader* parser,
00221 Handler& root,
00222 T param);
00223
00224 void
00225 start (const XMLCh* const uri,
00226 const XMLCh* const localname,
00227 const XMLCh* const qname,
00228 const xercesc::Attributes& attrs);
00229 void
00230 end (const XMLCh* const uri,
00231 const XMLCh* const localname,
00232 const XMLCh* const qname);
00233 };
00237 template <typename T>
00238 class AtomHandler : public RegexpHandler<T>
00239 {
00240 public:
00241 AtomHandler (xercesc::SAX2XMLReader* parser,
00242 Handler& root,
00243 T param,
00244 XMLCh* end);
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 };
00255 }
00256 }
00257
00258 # if ! defined VCSN_USE_INTERFACE_ONLY || defined VCSN_USE_LIB
00259 # include <vaucanson/xml/regexp.hxx>
00260 # endif // !VCSN_USE_INTERFACE_ONLY || VCSN_USE_LIB
00261
00262 #endif // !VCSN_XML_REGEXP_HH