CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Protected Attributes
DDLSAX2Handler Class Reference

DDLSAX2Handler inherits from Xerces C++ DefaultHandler. More...

#include <DDLSAX2Handler.h>

Inheritance diagram for DDLSAX2Handler:
DDLSAX2ConfigHandler DDLSAX2FileHandler DDLSAX2ExpressionHandler

Public Types

typedef XERCES_CPP_NAMESPACE::Attributes Attributes
 
typedef XERCES_CPP_NAMESPACE::SAXParseException SAXParseException
 

Public Member Functions

virtual void characters (const XMLCh *const chars, const XMLSize_t length) override
 
virtual void comment (const XMLCh *const chars, const XMLSize_t length) override
 
 DDLSAX2Handler ()
 
virtual void dumpStats (const std::string &fname)
 
virtual void endElement (const XMLCh *const uri, const XMLCh *const localname, const XMLCh *const qname) override
 
virtual void error (const SAXParseException &exception) override
 
virtual void fatalError (const SAXParseException &exception) override
 
unsigned int getAttrCount () const
 Get the count of attributes processed so far. More...
 
unsigned int getCharacterCount () const
 Get the count of characters processed so far. More...
 
unsigned int getElementCount () const
 Get the count of elements processed so far. More...
 
bool getSawErrors () const
 Did the XML parser see any errors? More...
 
unsigned int getSpaceCount () const
 Get the count of spaces processed so far. More...
 
virtual void ignorableWhitespace (const XMLCh *const chars, const XMLSize_t length) override
 
virtual void resetDocument () override
 
virtual void setNameSpace (const std::string &nms)
 
virtual void setUserNS (bool userns)
 
virtual void startElement (const XMLCh *const uri, const XMLCh *const localname, const XMLCh *const qname, const Attributes &attrs) override
 
virtual void warning (const SAXParseException &exception) override
 
 ~DDLSAX2Handler ()
 

Protected Attributes

XMLSize_t attrCount_
 
XMLSize_t characterCount_
 
XMLSize_t elementCount_
 
std::string nmspace_
 
bool sawErrors_
 
XMLSize_t spaceCount_
 
bool userNS_
 

Detailed Description

DDLSAX2Handler inherits from Xerces C++ DefaultHandler.

Author
Michael Case

DDLSAX2Handler.h - description

begin: Mon Oct 22 2001

The DefaultHandler of Xerces C++ provides an interface to the SAX2 event driven processing of XML documents. It does so by providing methods which are redefined by the inheriting class (DDLSAX2Handler in this case) to provide the desired processing for each event.

In this case, we accumulate some statistics. This class does nothing with startElement and endElement events.

Definition at line 27 of file DDLSAX2Handler.h.

Member Typedef Documentation

typedef XERCES_CPP_NAMESPACE::Attributes DDLSAX2Handler::Attributes

Definition at line 30 of file DDLSAX2Handler.h.

typedef XERCES_CPP_NAMESPACE::SAXParseException DDLSAX2Handler::SAXParseException

Definition at line 31 of file DDLSAX2Handler.h.

Constructor & Destructor Documentation

DDLSAX2Handler::DDLSAX2Handler ( void  )

Definition at line 9 of file DDLSAX2Handler.cc.

10  : attrCount_(0),
11  characterCount_(0),
12  elementCount_(0),
13  spaceCount_(0),
14  sawErrors_(false),
15  userNS_(false)
16 {}
XMLSize_t spaceCount_
XMLSize_t characterCount_
XMLSize_t attrCount_
XMLSize_t elementCount_
DDLSAX2Handler::~DDLSAX2Handler ( void  )

Definition at line 18 of file DDLSAX2Handler.cc.

19 {}

Member Function Documentation

void DDLSAX2Handler::characters ( const XMLCh *const  chars,
const XMLSize_t  length 
)
overridevirtual

Reimplemented in DDLSAX2FileHandler.

Definition at line 44 of file DDLSAX2Handler.cc.

References characterCount_.

Referenced by getSpaceCount().

46 {
47  characterCount_ += length;
48 }
XMLSize_t characterCount_
void DDLSAX2Handler::comment ( const XMLCh *const  chars,
const XMLSize_t  length 
)
overridevirtual

Reimplemented in DDLSAX2FileHandler.

Definition at line 51 of file DDLSAX2Handler.cc.

Referenced by getSpaceCount().

52 {
53  // do nothing default..
54 }
void DDLSAX2Handler::dumpStats ( const std::string &  fname)
virtual

Definition at line 73 of file DDLSAX2Handler.cc.

References gather_cfg::cout, getAttrCount(), getCharacterCount(), getElementCount(), and getSpaceCount().

Referenced by getSpaceCount().

74 {
75  std::cout << "DetectorDescription/Parser/interface/DDLSAX2Handler::dumpStats, file: "
76  << fname << " ("
77  << getElementCount() << " elems, "
78  << getAttrCount() << " attrs, "
79  << getSpaceCount() << " spaces, "
80  << getCharacterCount() << " chars)" << std::endl;
81 }
unsigned int getAttrCount() const
Get the count of attributes processed so far.
unsigned int getElementCount() const
Get the count of elements processed so far.
unsigned int getCharacterCount() const
Get the count of characters processed so far.
unsigned int getSpaceCount() const
Get the count of spaces processed so far.
string fname
main script
void DDLSAX2Handler::endElement ( const XMLCh *const  uri,
const XMLCh *const  localname,
const XMLCh *const  qname 
)
overridevirtual

Reimplemented in DDLSAX2FileHandler, and DDLSAX2ExpressionHandler.

Definition at line 36 of file DDLSAX2Handler.cc.

Referenced by getSpaceCount().

39 {
40  // do nothing
41 }
void DDLSAX2Handler::error ( const SAXParseException exception)
overridevirtual

Definition at line 88 of file DDLSAX2Handler.cc.

References cms::xerces::cStr(), and sawErrors_.

Referenced by argparse.ArgumentParser::_get_option_tuples(), python.rootplot.argparse.ArgumentParser::_get_option_tuples(), argparse.ArgumentParser::_parse_known_args(), python.rootplot.argparse.ArgumentParser::_parse_known_args(), argparse.ArgumentParser::_parse_optional(), python.rootplot.argparse.ArgumentParser::_parse_optional(), argparse.ArgumentParser::_read_args_from_files(), python.rootplot.argparse.ArgumentParser::_read_args_from_files(), argparse.ArgumentParser::add_subparsers(), python.rootplot.argparse.ArgumentParser::add_subparsers(), Page1Parser.Page1Parser::check_for_whole_start_tag(), getSpaceCount(), argparse.ArgumentParser::parse_args(), python.rootplot.argparse.ArgumentParser::parse_args(), argparse.ArgumentParser::parse_known_args(), and python.rootplot.argparse.ArgumentParser::parse_known_args().

89 {
90  sawErrors_ = true;
91  edm::LogError("DetectorDescription_Parser_DDLSAX2Handler")
92  << "\nError at file " << cStr(e.getSystemId()).ptr()
93  << ", line " << e.getLineNumber()
94  << ", char " << e.getColumnNumber()
95  << "\n Message: " << cStr(e.getMessage()).ptr() << std::endl;
96 }
ZStr< char > cStr(XMLCh const *str)
void DDLSAX2Handler::fatalError ( const SAXParseException exception)
overridevirtual

Definition at line 99 of file DDLSAX2Handler.cc.

References cms::xerces::cStr(), Exception, sawErrors_, and toolbox::toString().

Referenced by getSpaceCount().

100 {
101  sawErrors_ = true;
102  edm::LogError("DetectorDescription_Parser_DDLSAX2Handler")
103  << "\nFatal Error at file " << cStr(e.getSystemId()).ptr()
104  << ", line " << e.getLineNumber()
105  << ", char " << e.getColumnNumber()
106  << "\n Message: "
107  << cStr(e.getMessage()).ptr() << std::endl;
108  throw cms::Exception("DDException") << "DetectorDescription_Parser_Unrecoverable_Error_from_Xerces: "
109  << toString(e.getMessage())
110  << " file: " << toString(e.getSystemId())
111  << " line: " << e.getLineNumber() << " col: " << e.getColumnNumber();
112 }
ZStr< char > cStr(XMLCh const *str)
std::string toString(const char *format,...)
Definition: xdaq_compat.cc:4
unsigned int DDLSAX2Handler::getAttrCount ( ) const
inline

Get the count of attributes processed so far.

Definition at line 42 of file DDLSAX2Handler.h.

References attrCount_.

Referenced by dumpStats().

43  {
44  return attrCount_;
45  }
XMLSize_t attrCount_
unsigned int DDLSAX2Handler::getCharacterCount ( ) const
inline

Get the count of characters processed so far.

Definition at line 47 of file DDLSAX2Handler.h.

References characterCount_.

Referenced by dumpStats().

48  {
49  return characterCount_;
50  }
XMLSize_t characterCount_
unsigned int DDLSAX2Handler::getElementCount ( ) const
inline

Get the count of elements processed so far.

Definition at line 37 of file DDLSAX2Handler.h.

References elementCount_.

Referenced by dumpStats().

38  {
39  return elementCount_;
40  }
XMLSize_t elementCount_
bool DDLSAX2Handler::getSawErrors ( ) const
inline

Did the XML parser see any errors?

Definition at line 52 of file DDLSAX2Handler.h.

References sawErrors_.

53  {
54  return sawErrors_;
55  }
unsigned int DDLSAX2Handler::getSpaceCount ( ) const
inline
void DDLSAX2Handler::ignorableWhitespace ( const XMLCh *const  chars,
const XMLSize_t  length 
)
overridevirtual

Definition at line 57 of file DDLSAX2Handler.cc.

References spaceCount_.

Referenced by getSpaceCount().

59 {
60  spaceCount_ += length;
61 }
XMLSize_t spaceCount_
void DDLSAX2Handler::resetDocument ( void  )
overridevirtual

Definition at line 64 of file DDLSAX2Handler.cc.

References attrCount_, characterCount_, elementCount_, and spaceCount_.

Referenced by getSpaceCount().

65 {
66  attrCount_ = 0;
67  characterCount_ = 0;
68  elementCount_ = 0;
69  spaceCount_ = 0;
70 }
XMLSize_t spaceCount_
XMLSize_t characterCount_
XMLSize_t attrCount_
XMLSize_t elementCount_
void DDLSAX2Handler::setNameSpace ( const std::string &  nms)
virtual

Definition at line 131 of file DDLSAX2Handler.cc.

References nmspace_.

Referenced by DDLParser::parse(), and DDLParser::parseOneFile().

132 {
133  nmspace_ = nms;
134 }
std::string nmspace_
void DDLSAX2Handler::setUserNS ( bool  userns)
virtual

This allows the DDLSAX2Handler and objects that inherit from it to set the userNS_ flag to indicate false[default] use the filename of the file being handled as the DD namespace true assume ALL the "name" attributes have DD namespace specified.

Definition at line 125 of file DDLSAX2Handler.cc.

References userNS_.

Referenced by XMLIdealGeometryESSource::produce(), XMLIdealMagneticFieldGeometryESProducer::produce(), and XMLIdealGeometryESProducer::produce().

126 {
127  userNS_ = userns;
128 }
void DDLSAX2Handler::startElement ( const XMLCh *const  uri,
const XMLCh *const  localname,
const XMLCh *const  qname,
const Attributes attrs 
)
overridevirtual

Reimplemented in DDLSAX2FileHandler, DDLSAX2ConfigHandler, and DDLSAX2ExpressionHandler.

Definition at line 26 of file DDLSAX2Handler.cc.

References attrCount_, and elementCount_.

Referenced by getSpaceCount().

30 {
31  ++elementCount_;
32  attrCount_ += attrs.getLength();
33 }
XMLSize_t attrCount_
XMLSize_t elementCount_
void DDLSAX2Handler::warning ( const SAXParseException exception)
overridevirtual

Definition at line 115 of file DDLSAX2Handler.cc.

References cms::xerces::cStr().

Referenced by getSpaceCount().

116 {
117  edm::LogWarning("DetectorDescription_Parser_DDLSAX2Handler")
118  << "\nWarning at file " << cStr(e.getSystemId()).ptr()
119  << ", line " << e.getLineNumber()
120  << ", char " << e.getColumnNumber()
121  << "\n Message: " << cStr(e.getMessage()).ptr() << std::endl;
122 }
ZStr< char > cStr(XMLCh const *str)

Member Data Documentation

XMLSize_t DDLSAX2Handler::attrCount_
protected

Definition at line 99 of file DDLSAX2Handler.h.

Referenced by getAttrCount(), resetDocument(), and startElement().

XMLSize_t DDLSAX2Handler::characterCount_
protected

Definition at line 100 of file DDLSAX2Handler.h.

Referenced by characters(), getCharacterCount(), and resetDocument().

XMLSize_t DDLSAX2Handler::elementCount_
protected

Definition at line 101 of file DDLSAX2Handler.h.

Referenced by getElementCount(), resetDocument(), and startElement().

std::string DDLSAX2Handler::nmspace_
protected
bool DDLSAX2Handler::sawErrors_
protected

Definition at line 103 of file DDLSAX2Handler.h.

Referenced by error(), fatalError(), and getSawErrors().

XMLSize_t DDLSAX2Handler::spaceCount_
protected

Definition at line 102 of file DDLSAX2Handler.h.

Referenced by getSpaceCount(), ignorableWhitespace(), and resetDocument().

bool DDLSAX2Handler::userNS_
protected

Definition at line 104 of file DDLSAX2Handler.h.

Referenced by DDLSAX2FileHandler::endElement(), and setUserNS().