CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_9_patch3/src/DetectorDescription/Parser/interface/DDLSAX2Handler.h

Go to the documentation of this file.
00001 #ifndef DDLSAX2HANDLER_H
00002 #define DDLSAX2HANDLER_H
00003 
00004 // ---------------------------------------------------------------------------
00005 //  Includes
00006 // ---------------------------------------------------------------------------
00007 
00008 // Xerces C++ Dependencies
00009 #include <xercesc/util/XercesDefs.hpp>
00010 #include <xercesc/sax2/Attributes.hpp>
00011 #include <xercesc/sax2/DefaultHandler.hpp>
00012 
00013 #include <string>
00014 #include <vector>
00015 #include <iostream>
00016 
00017 
00019 
00036 class DDLSAX2Handler : public XERCES_CPP_NAMESPACE::DefaultHandler
00037 {
00038 
00039  public:
00040   typedef XERCES_CPP_NAMESPACE::Attributes Attributes;
00041   typedef XERCES_CPP_NAMESPACE::SAXParseException SAXParseException;
00042 
00043   // -----------------------------------------------------------------------
00044   //  Constructor and Destructor
00045   // -----------------------------------------------------------------------
00046 
00047   //  DDLSAX2Handler();
00048   DDLSAX2Handler();
00049   ~DDLSAX2Handler();
00050 
00051   // -----------------------------------------------------------------------
00052   //  Getter methods
00053   // -----------------------------------------------------------------------
00055   unsigned int getElementCount() const
00056     {
00057       return elementCount_;
00058     }
00060   unsigned int getAttrCount() const
00061     {
00062       return attrCount_;
00063     }
00065   unsigned int getCharacterCount() const
00066     {
00067       return characterCount_;
00068     }
00070   bool getSawErrors() const
00071     {
00072       return sawErrors_;
00073     }
00075   unsigned int getSpaceCount() const
00076     {
00077       return spaceCount_;
00078     }
00079 
00080   // -----------------------------------------------------------------------
00081   //  Handlers for the SAX ContentHandler interface
00082   // -----------------------------------------------------------------------
00083 
00084   virtual void startElement(const XMLCh* const uri, const XMLCh* const localname
00085                     , const XMLCh* const qname, const Attributes& attrs);
00086   virtual void endElement(const XMLCh* const uri, const XMLCh* const localname
00087                     , const XMLCh* const qname);
00088   virtual void characters(const XMLCh* const chars, const unsigned int length);
00089   virtual void comment (const XMLCh *const chars, const unsigned int length );
00090   virtual void ignorableWhitespace(const XMLCh* const chars, const unsigned int length);
00091   virtual void resetDocument();
00092 
00093   // -----------------------------------------------------------------------
00094   //  Handlers for the SAX ErrorHandler interface
00095   // -----------------------------------------------------------------------
00096   virtual void warning(const SAXParseException& exception);
00097   virtual void error(const SAXParseException& exception);
00098   virtual void fatalError(const SAXParseException& exception);
00099   virtual void dumpStats(const std::string& fname);
00100 
00101  protected:
00102 
00103   // -----------------------------------------------------------------------
00104   //  Protected data members
00105   //
00106   //  attrCount_
00107   //  characterCount_
00108   //  elementCount_
00109   //  spaceCount_
00110   //      These are just counters that are run upwards based on the input
00111   //      from the document handlers.
00112   //
00113   //  sawErrors
00114   //      This is set by the error handlers, and is queryable later to
00115   //      see if any errors occurred.
00116   // -----------------------------------------------------------------------
00117   unsigned int    attrCount_;
00118   unsigned int    characterCount_;
00119   unsigned int    elementCount_;
00120   unsigned int    spaceCount_;
00121   bool            sawErrors_;
00122   bool            userNS_;
00123   std::string     nmspace_;
00124 /*   std::string getnmspace(const std::string& fname); */
00125  
00126  public:
00132   virtual void setUserNS(bool userns);
00133   virtual void setNameSpace(const std::string& nms);
00134 };
00135 
00136 #endif