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

using Attributes = XERCES_CPP_NAMESPACE::Attributes
 
using SAXParseException = XERCES_CPP_NAMESPACE::SAXParseException
 

Public Member Functions

void characters (const XMLCh *chars, XMLSize_t length) override
 
void comment (const XMLCh *chars, XMLSize_t length) override
 
 DDLSAX2Handler ()
 
virtual void dumpStats (const std::string &fname)
 
void endElement (const XMLCh *uri, const XMLCh *localname, const XMLCh *qname) override
 
void error (const SAXParseException &exception) override
 
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...
 
void ignorableWhitespace (const XMLCh *chars, XMLSize_t length) override
 
void resetDocument () override
 
virtual void setNameSpace (const std::string &nms)
 
virtual void setUserNS (bool userns)
 
void startElement (const XMLCh *uri, const XMLCh *localname, const XMLCh *qname, const Attributes &attrs) override
 
void warning (const SAXParseException &exception) override
 
 ~DDLSAX2Handler () override
 

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

◆ Attributes

using DDLSAX2Handler::Attributes = XERCES_CPP_NAMESPACE::Attributes

Definition at line 29 of file DDLSAX2Handler.h.

◆ SAXParseException

using DDLSAX2Handler::SAXParseException = XERCES_CPP_NAMESPACE::SAXParseException

Definition at line 30 of file DDLSAX2Handler.h.

Constructor & Destructor Documentation

◆ DDLSAX2Handler()

DDLSAX2Handler::DDLSAX2Handler ( void  )

Definition at line 10 of file DDLSAX2Handler.cc.

11  : attrCount_(0), characterCount_(0), elementCount_(0), spaceCount_(0), sawErrors_(false), userNS_(false) {}

◆ ~DDLSAX2Handler()

DDLSAX2Handler::~DDLSAX2Handler ( void  )
override

Definition at line 13 of file DDLSAX2Handler.cc.

13 {}

Member Function Documentation

◆ characters()

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

Definition at line 31 of file DDLSAX2Handler.cc.

31 { characterCount_ += length; }

References characterCount_.

◆ comment()

void DDLSAX2Handler::comment ( const XMLCh *  chars,
XMLSize_t  length 
)
override

Definition at line 33 of file DDLSAX2Handler.cc.

33  {
34  // do nothing default..
35 }

◆ dumpStats()

void DDLSAX2Handler::dumpStats ( const std::string &  fname)
virtual

Definition at line 46 of file DDLSAX2Handler.cc.

46  {
47  std::cout << "DetectorDescription/Parser/interface/DDLSAX2Handler::dumpStats, file: " << fname << " ("
48  << getElementCount() << " elems, " << getAttrCount() << " attrs, " << getSpaceCount() << " spaces, "
49  << getCharacterCount() << " chars)" << std::endl;
50 }

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

◆ endElement()

void DDLSAX2Handler::endElement ( const XMLCh *  uri,
const XMLCh *  localname,
const XMLCh *  qname 
)
override

Definition at line 27 of file DDLSAX2Handler.cc.

27  {
28  // do nothing
29 }

◆ error()

void DDLSAX2Handler::error ( const SAXParseException exception)
override

Definition at line 56 of file DDLSAX2Handler.cc.

56  {
57  sawErrors_ = true;
58  edm::LogError("DetectorDescription_Parser_DDLSAX2Handler")
59  << "\nError at file " << cStr(e.getSystemId()).ptr() << ", line " << e.getLineNumber() << ", char "
60  << e.getColumnNumber() << "\n Message: " << cStr(e.getMessage()).ptr() << std::endl;
61 }

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

Referenced by Page1Parser.Page1Parser::check_for_whole_start_tag().

◆ fatalError()

void DDLSAX2Handler::fatalError ( const SAXParseException exception)
override

Definition at line 63 of file DDLSAX2Handler.cc.

63  {
64  sawErrors_ = true;
65  edm::LogError("DetectorDescription_Parser_DDLSAX2Handler")
66  << "\nFatal Error at file " << cStr(e.getSystemId()).ptr() << ", line " << e.getLineNumber() << ", char "
67  << e.getColumnNumber() << "\n Message: " << cStr(e.getMessage()).ptr() << std::endl;
68  throw cms::Exception("DDException") << "DetectorDescription_Parser_Unrecoverable_Error_from_Xerces: "
69  << toString(e.getMessage()) << " file: " << toString(e.getSystemId())
70  << " line: " << e.getLineNumber() << " col: " << e.getColumnNumber();
71 }

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

◆ getAttrCount()

unsigned int DDLSAX2Handler::getAttrCount ( ) const
inline

Get the count of attributes processed so far.

Definition at line 38 of file DDLSAX2Handler.h.

38 { return attrCount_; }

References attrCount_.

Referenced by dumpStats().

◆ getCharacterCount()

unsigned int DDLSAX2Handler::getCharacterCount ( ) const
inline

Get the count of characters processed so far.

Definition at line 40 of file DDLSAX2Handler.h.

40 { return characterCount_; }

References characterCount_.

Referenced by dumpStats().

◆ getElementCount()

unsigned int DDLSAX2Handler::getElementCount ( ) const
inline

Get the count of elements processed so far.

Definition at line 36 of file DDLSAX2Handler.h.

36 { return elementCount_; }

References elementCount_.

Referenced by dumpStats().

◆ getSawErrors()

bool DDLSAX2Handler::getSawErrors ( ) const
inline

Did the XML parser see any errors?

Definition at line 42 of file DDLSAX2Handler.h.

42 { return sawErrors_; }

References sawErrors_.

◆ getSpaceCount()

unsigned int DDLSAX2Handler::getSpaceCount ( ) const
inline

Get the count of spaces processed so far.

Definition at line 44 of file DDLSAX2Handler.h.

44 { return spaceCount_; }

References spaceCount_.

Referenced by dumpStats().

◆ ignorableWhitespace()

void DDLSAX2Handler::ignorableWhitespace ( const XMLCh *  chars,
XMLSize_t  length 
)
override

Definition at line 37 of file DDLSAX2Handler.cc.

37 { spaceCount_ += length; }

References spaceCount_.

◆ resetDocument()

void DDLSAX2Handler::resetDocument ( void  )
override

Definition at line 39 of file DDLSAX2Handler.cc.

39  {
40  attrCount_ = 0;
41  characterCount_ = 0;
42  elementCount_ = 0;
43  spaceCount_ = 0;
44 }

References attrCount_, characterCount_, elementCount_, and spaceCount_.

◆ setNameSpace()

void DDLSAX2Handler::setNameSpace ( const std::string &  nms)
virtual

Definition at line 81 of file DDLSAX2Handler.cc.

81 { nmspace_ = nms; }

References nmspace_.

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

◆ setUserNS()

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 79 of file DDLSAX2Handler.cc.

79 { userNS_ = userns; }

References userNS_.

◆ startElement()

void DDLSAX2Handler::startElement ( const XMLCh *  uri,
const XMLCh *  localname,
const XMLCh *  qname,
const Attributes attrs 
)
override

Definition at line 19 of file DDLSAX2Handler.cc.

22  {
23  ++elementCount_;
24  attrCount_ += attrs.getLength();
25 }

References attrCount_, and elementCount_.

◆ warning()

void DDLSAX2Handler::warning ( const SAXParseException exception)
override

Definition at line 73 of file DDLSAX2Handler.cc.

73  {
74  edm::LogWarning("DetectorDescription_Parser_DDLSAX2Handler")
75  << "\nWarning at file " << cStr(e.getSystemId()).ptr() << ", line " << e.getLineNumber() << ", char "
76  << e.getColumnNumber() << "\n Message: " << cStr(e.getMessage()).ptr() << std::endl;
77 }

References cms::xerces::cStr(), and MillePedeFileConverter_cfg::e.

Member Data Documentation

◆ attrCount_

XMLSize_t DDLSAX2Handler::attrCount_
protected

Definition at line 80 of file DDLSAX2Handler.h.

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

◆ characterCount_

XMLSize_t DDLSAX2Handler::characterCount_
protected

Definition at line 81 of file DDLSAX2Handler.h.

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

◆ elementCount_

XMLSize_t DDLSAX2Handler::elementCount_
protected

Definition at line 82 of file DDLSAX2Handler.h.

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

◆ nmspace_

std::string DDLSAX2Handler::nmspace_
protected

◆ sawErrors_

bool DDLSAX2Handler::sawErrors_
protected

Definition at line 84 of file DDLSAX2Handler.h.

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

◆ spaceCount_

XMLSize_t DDLSAX2Handler::spaceCount_
protected

Definition at line 83 of file DDLSAX2Handler.h.

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

◆ userNS_

bool DDLSAX2Handler::userNS_
protected

Definition at line 85 of file DDLSAX2Handler.h.

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

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
gather_cfg.cout
cout
Definition: gather_cfg.py:144
DDLSAX2Handler::elementCount_
XMLSize_t elementCount_
Definition: DDLSAX2Handler.h:82
DDLSAX2Handler::spaceCount_
XMLSize_t spaceCount_
Definition: DDLSAX2Handler.h:83
cms::xerces::cStr
ZStr< char > cStr(XMLCh const *str)
Definition: XercesStrUtils.h:32
DDLSAX2Handler::getElementCount
unsigned int getElementCount() const
Get the count of elements processed so far.
Definition: DDLSAX2Handler.h:36
toolbox::toString
std::string toString(const char *format,...)
Definition: xdaq_compat.cc:4
DDLSAX2Handler::attrCount_
XMLSize_t attrCount_
Definition: DDLSAX2Handler.h:80
edm::LogWarning
Definition: MessageLogger.h:141
DDLSAX2Handler::getCharacterCount
unsigned int getCharacterCount() const
Get the count of characters processed so far.
Definition: DDLSAX2Handler.h:40
edm::LogError
Definition: MessageLogger.h:183
DDLSAX2Handler::userNS_
bool userNS_
Definition: DDLSAX2Handler.h:85
DDLSAX2Handler::nmspace_
std::string nmspace_
Definition: DDLSAX2Handler.h:86
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
Exception
Definition: hltDiff.cc:246
DDLSAX2Handler::sawErrors_
bool sawErrors_
Definition: DDLSAX2Handler.h:84
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37