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

- File List
- File Members

# handlers_base.hh

    00001 // handlers_base.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 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_HANDLERS_BASE_HH
    00019 # define VCSN_XML_HANDLERS_BASE_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
    00045 namespace vcsn
    00046 {
    00047   namespace xml
    00048   {
    00049     /*
    00050      * ErrHandler class, error handler.
    00051      */
    00052     class ErrHandler : public xercesc::DefaultHandler
    00053     {
    00054       public:
    00055         ErrHandler () : DefaultHandler() {}
    00056
    00057         void
    00058         warning (const xercesc::SAXParseException& exc);
    00059         // Receive notification of a warning.
    00060         void
    00061         error (const xercesc::SAXParseException& exc);
    00062         // Receive notification of a recoverable error.
    00063         void
    00064         fatalError (const xercesc::SAXParseException& exc);
    00065         // Receive notification of a non-recoverable error.
    00066         void
    00067         resetErrors () {}
    00068         // Reset the Error handler object on its reuse.
    00069     };
    00070
    00071     namespace error
    00072     {
    00073       void token(const XMLCh* const localname);
    00074       void attrs(const XMLCh* const localname,
    00075                  const std::string& name,
    00076                  const std::string& value);
    00077       void missattrs(const XMLCh* const localname,
    00078                      const std::string& name);
    00079       void notletter(const std::string&);
    00080     } // !error
    00081     /*
    00082      * Handler class
    00083      */
    00084     class Handler : public xercesc::DefaultHandler
    00085     {
    00086       public:
    00087         Handler (xercesc::SAX2XMLReader* parser,
    00088                  Handler& root);
    00089         Handler (xercesc::SAX2XMLReader* parser,
    00090                  xercesc::DefaultHandler& root,
    00091                  XMLEq& eq);
    00092
    00093         void
    00094         startElement (const XMLCh* const uri,
    00095                       const XMLCh* const localname,
    00096                       const XMLCh* const qname,
    00097                       const xercesc::Attributes& attrs);
    00098         void
    00099         endElement (const XMLCh* const uri,
    00100                     const XMLCh* const localname,
    00101                     const XMLCh* const qname);
    00102
    00103         virtual void
    00104         start (const XMLCh* const uri,
    00105                       const XMLCh* const localname,
    00106                       const XMLCh* const qname,
    00107                       const xercesc::Attributes& attrs) = 0;
    00108         virtual void
    00109         end (const XMLCh* const uri,
    00110                     const XMLCh* const localname,
    00111                     const XMLCh* const qname) = 0;
    00112
    00113         XMLEq& eq() { return eq_; };
    00114 # ifdef DEBUG
    00115         static int      indent_;
    00116 # endif
    00117       protected:
    00118         // Required to enable a change of the Handler while parsing.
    00119         xercesc::SAX2XMLReader*         parser_;
    00120         xercesc::DefaultHandler&        root_;
    00121
    00122         XMLEq&  eq_;
    00123     };
    00124 # ifdef DEBUG
    00125     int Handler::indent_ = 0;
    00126 # endif
    00127
    00132     class UnsupHandler : public Handler
    00133     {
    00134       public:
    00135         UnsupHandler(xercesc::SAX2XMLReader* parser,
    00136                      Handler& root);
    00137
    00138         void
    00139         start (const XMLCh* const uri,
    00140                       const XMLCh* const localname,
    00141                       const XMLCh* const qname,
    00142                       const xercesc::Attributes& attrs);
    00143         void
    00144         end (const XMLCh* const uri,
    00145                     const XMLCh* const localname,
    00146                     const XMLCh* const qname);
    00147       private:
    00148         int                             depth_;
    00149     };
    00150   } // !xml
    00151 } // !vcsn
    00152
    00153 # if ! defined VCSN_USE_INTERFACE_ONLY || defined VCSN_USE_LIB
    00154 #  include <vaucanson/xml/handlers_base.hxx>
    00155 # endif // !VCSN_USE_INTERFACE_ONLY || VCSN_USE_LIB
    00156
    00157 #endif // !VCSN_XML_HANDLERS_BASE_HH