CMS 3D CMS Logo

DDLSAX2Handler.h
Go to the documentation of this file.
1 #ifndef DETECTOR_DESCRIPTION_PARSER_DDL_SAX2_HANDLER_H
2 #define DETECTOR_DESCRIPTION_PARSER_DDL_SAX2_HANDLER_H
3 
4 #include <xercesc/sax2/Attributes.hpp>
5 #include <xercesc/sax2/DefaultHandler.hpp>
6 #include <iostream>
7 #include <string>
8 #include <vector>
9 
11 
27 class DDLSAX2Handler : public XERCES_CPP_NAMESPACE::DefaultHandler {
28 public:
29  using Attributes = XERCES_CPP_NAMESPACE::Attributes;
30  using SAXParseException = XERCES_CPP_NAMESPACE::SAXParseException;
31 
33  ~DDLSAX2Handler() override;
34 
36  unsigned int getElementCount() const { return elementCount_; }
38  unsigned int getAttrCount() const { return attrCount_; }
40  unsigned int getCharacterCount() const { return characterCount_; }
42  bool getSawErrors() const { return sawErrors_; }
44  unsigned int getSpaceCount() const { return spaceCount_; }
45 
46  // -----------------------------------------------------------------------
47  // Handlers for the SAX ContentHandler interface
48  // -----------------------------------------------------------------------
49 
50  void startElement(const XMLCh* uri, const XMLCh* localname, const XMLCh* qname, const Attributes& attrs) override;
51  void endElement(const XMLCh* uri, const XMLCh* localname, const XMLCh* qname) override;
52  void characters(const XMLCh* chars, XMLSize_t length) override;
53  void comment(const XMLCh* chars, XMLSize_t length) override;
54  void ignorableWhitespace(const XMLCh* chars, XMLSize_t length) override;
55  void resetDocument() override;
56 
57  // -----------------------------------------------------------------------
58  // Handlers for the SAX ErrorHandler interface
59  // -----------------------------------------------------------------------
60  void warning(const SAXParseException& exception) override;
61  void error(const SAXParseException& exception) override;
62  void fatalError(const SAXParseException& exception) override;
63  virtual void dumpStats(const std::string& fname);
64 
65 protected:
66  // -----------------------------------------------------------------------
67  // Protected data members
68  //
69  // attrCount_
70  // characterCount_
71  // elementCount_
72  // spaceCount_
73  // These are just counters that are run upwards based on the input
74  // from the document handlers.
75  //
76  // sawErrors
77  // This is set by the error handlers, and is queryable later to
78  // see if any errors occurred.
79  // -----------------------------------------------------------------------
80  XMLSize_t attrCount_;
81  XMLSize_t characterCount_;
82  XMLSize_t elementCount_;
83  XMLSize_t spaceCount_;
84  bool sawErrors_;
85  bool userNS_;
87 
88 public:
94  virtual void setUserNS(bool userns);
95  virtual void setNameSpace(const std::string& nms);
96 };
97 
98 #endif
DDLSAX2Handler::getSpaceCount
unsigned int getSpaceCount() const
Get the count of spaces processed so far.
Definition: DDLSAX2Handler.h:44
DDLSAX2Handler::characterCount_
XMLSize_t characterCount_
Definition: DDLSAX2Handler.h:81
DDLSAX2Handler::error
void error(const SAXParseException &exception) override
Definition: DDLSAX2Handler.cc:56
DDLSAX2Handler::SAXParseException
XERCES_CPP_NAMESPACE::SAXParseException SAXParseException
Definition: DDLSAX2Handler.h:30
DDLSAX2Handler::elementCount_
XMLSize_t elementCount_
Definition: DDLSAX2Handler.h:82
DDLSAX2Handler::spaceCount_
XMLSize_t spaceCount_
Definition: DDLSAX2Handler.h:83
DDLSAX2Handler::getElementCount
unsigned int getElementCount() const
Get the count of elements processed so far.
Definition: DDLSAX2Handler.h:36
DDLSAX2Handler::setUserNS
virtual void setUserNS(bool userns)
Definition: DDLSAX2Handler.cc:79
DDLSAX2Handler
DDLSAX2Handler inherits from Xerces C++ DefaultHandler.
Definition: DDLSAX2Handler.h:27
DDLSAX2Handler::attrCount_
XMLSize_t attrCount_
Definition: DDLSAX2Handler.h:80
DDLSAX2Handler::characters
void characters(const XMLCh *chars, XMLSize_t length) override
Definition: DDLSAX2Handler.cc:31
DDLSAX2Handler::DDLSAX2Handler
DDLSAX2Handler()
Definition: DDLSAX2Handler.cc:10
DDLSAX2Handler::comment
void comment(const XMLCh *chars, XMLSize_t length) override
Definition: DDLSAX2Handler.cc:33
DDLSAX2Handler::fatalError
void fatalError(const SAXParseException &exception) override
Definition: DDLSAX2Handler.cc:63
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
cppFunctionSkipper.exception
exception
Definition: cppFunctionSkipper.py:10
DDLSAX2Handler::getCharacterCount
unsigned int getCharacterCount() const
Get the count of characters processed so far.
Definition: DDLSAX2Handler.h:40
DDLSAX2Handler::endElement
void endElement(const XMLCh *uri, const XMLCh *localname, const XMLCh *qname) override
Definition: DDLSAX2Handler.cc:27
DDLSAX2Handler::userNS_
bool userNS_
Definition: DDLSAX2Handler.h:85
DDLSAX2Handler::nmspace_
std::string nmspace_
Definition: DDLSAX2Handler.h:86
DDLSAX2Handler::setNameSpace
virtual void setNameSpace(const std::string &nms)
Definition: DDLSAX2Handler.cc:81
DDLSAX2Handler::ignorableWhitespace
void ignorableWhitespace(const XMLCh *chars, XMLSize_t length) override
Definition: DDLSAX2Handler.cc:37
DDLSAX2Handler::getAttrCount
unsigned int getAttrCount() const
Get the count of attributes processed so far.
Definition: DDLSAX2Handler.h:38
alignmentValidation.fname
string fname
main script
Definition: alignmentValidation.py:959
DDLSAX2Handler::resetDocument
void resetDocument() override
Definition: DDLSAX2Handler.cc:39
DDLSAX2Handler::Attributes
XERCES_CPP_NAMESPACE::Attributes Attributes
Definition: DDLSAX2Handler.h:29
DDLSAX2Handler::sawErrors_
bool sawErrors_
Definition: DDLSAX2Handler.h:84
DDLSAX2Handler::getSawErrors
bool getSawErrors() const
Did the XML parser see any errors?
Definition: DDLSAX2Handler.h:42
DDLSAX2Handler::warning
void warning(const SAXParseException &exception) override
Definition: DDLSAX2Handler.cc:73
DDLSAX2Handler::startElement
void startElement(const XMLCh *uri, const XMLCh *localname, const XMLCh *qname, const Attributes &attrs) override
Definition: DDLSAX2Handler.cc:19
DDLSAX2Handler::~DDLSAX2Handler
~DDLSAX2Handler() override
Definition: DDLSAX2Handler.cc:13
DDLSAX2Handler::dumpStats
virtual void dumpStats(const std::string &fname)
Definition: DDLSAX2Handler.cc:46