CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 unsigned int length)
 
virtual void comment (const XMLCh *const chars, const unsigned int length)
 
 DDLSAX2Handler ()
 
virtual void dumpStats (const std::string &fname)
 
virtual void endElement (const XMLCh *const uri, const XMLCh *const localname, const XMLCh *const qname)
 
virtual void error (const SAXParseException &exception)
 
virtual void fatalError (const SAXParseException &exception)
 
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 unsigned int length)
 
virtual void resetDocument ()
 
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)
 
virtual void warning (const SAXParseException &exception)
 
 ~DDLSAX2Handler ()
 

Protected Attributes

unsigned int attrCount_
 
unsigned int characterCount_
 
unsigned int elementCount_
 
std::string nmspace_
 
bool sawErrors_
 
unsigned int spaceCount_
 
bool userNS_
 

Detailed Description

DDLSAX2Handler inherits from Xerces C++ DefaultHandler.

Author
Michael Case

DDLSAX2Handler.h - description

begin: Mon Oct 22 2001 email: case@.nosp@m.ucdh.nosp@m.ep.uc.nosp@m.davi.nosp@m.s.edu

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 36 of file DDLSAX2Handler.h.

Member Typedef Documentation

typedef XERCES_CPP_NAMESPACE::Attributes DDLSAX2Handler::Attributes

Definition at line 40 of file DDLSAX2Handler.h.

typedef XERCES_CPP_NAMESPACE::SAXParseException DDLSAX2Handler::SAXParseException

Definition at line 41 of file DDLSAX2Handler.h.

Constructor & Destructor Documentation

DDLSAX2Handler::DDLSAX2Handler ( void  )

Definition at line 19 of file DDLSAX2Handler.cc.

20  : attrCount_(0),
21  characterCount_(0),
22  elementCount_(0),
23  spaceCount_(0),
24  sawErrors_(false),
25  userNS_(false)
26 {}
unsigned int characterCount_
unsigned int spaceCount_
unsigned int elementCount_
unsigned int attrCount_
DDLSAX2Handler::~DDLSAX2Handler ( void  )

Definition at line 28 of file DDLSAX2Handler.cc.

29 {}

Member Function Documentation

void DDLSAX2Handler::characters ( const XMLCh *const  chars,
const unsigned int  length 
)
virtual

Reimplemented in DDLSAX2FileHandler.

Definition at line 54 of file DDLSAX2Handler.cc.

References characterCount_.

56 {
57  characterCount_ += length;
58 }
unsigned int characterCount_
void DDLSAX2Handler::comment ( const XMLCh *const  chars,
const unsigned int  length 
)
virtual

Reimplemented in DDLSAX2FileHandler.

Definition at line 61 of file DDLSAX2Handler.cc.

62 {
63  // do nothing default..
64 }
void DDLSAX2Handler::dumpStats ( const std::string &  fname)
virtual

Definition at line 83 of file DDLSAX2Handler.cc.

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

84 {
85  std::cout << "DetectorDescription/Parser/interface/DDLSAX2Handler::dumpStats, file: "
86  << fname << " ("
87  << getElementCount() << " elems, "
88  << getAttrCount() << " attrs, "
89  << getSpaceCount() << " spaces, "
90  << getCharacterCount() << " chars)" << std::endl;
91 }
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
tuple cout
Definition: gather_cfg.py:145
void DDLSAX2Handler::endElement ( const XMLCh *const  uri,
const XMLCh *const  localname,
const XMLCh *const  qname 
)
virtual

Reimplemented in DDLSAX2FileHandler, and DDLSAX2ExpressionHandler.

Definition at line 46 of file DDLSAX2Handler.cc.

49 {
50  // do nothing
51 }
void DDLSAX2Handler::error ( const SAXParseException exception)
virtual
void DDLSAX2Handler::fatalError ( const SAXParseException exception)
virtual

Definition at line 109 of file DDLSAX2Handler.cc.

References Exception, sawErrors_, and AlCaHLTBitMon_QueryRunRegistry::string.

110 {
111  sawErrors_ = true;
112  edm::LogError("DetectorDescription_Parser_DDLSAX2Handler")
113  << "\nFatal Error at file " << StrX(e.getSystemId())
114  << ", line " << e.getLineNumber()
115  << ", char " << e.getColumnNumber()
116  << "\n Message: "
117  << StrX(e.getMessage()) << std::endl;
118  throw cms::Exception("DDException") << "DetectorDescription_Parser_Unrecoverable_Error_from_Xerces: "
119  << std::string(StrX(e.getMessage()).localForm())
120  << " file: " << std::string(StrX(e.getSystemId()).localForm())
121  << " line: " << e.getLineNumber() << " col: " << e.getColumnNumber();
122 }
Definition: StrX.h:32
unsigned int DDLSAX2Handler::getAttrCount ( ) const
inline

Get the count of attributes processed so far.

Definition at line 60 of file DDLSAX2Handler.h.

References attrCount_.

Referenced by dumpStats().

61  {
62  return attrCount_;
63  }
unsigned int attrCount_
unsigned int DDLSAX2Handler::getCharacterCount ( ) const
inline

Get the count of characters processed so far.

Definition at line 65 of file DDLSAX2Handler.h.

References characterCount_.

Referenced by dumpStats().

66  {
67  return characterCount_;
68  }
unsigned int characterCount_
unsigned int DDLSAX2Handler::getElementCount ( ) const
inline

Get the count of elements processed so far.

Definition at line 55 of file DDLSAX2Handler.h.

References elementCount_.

Referenced by dumpStats().

56  {
57  return elementCount_;
58  }
unsigned int elementCount_
bool DDLSAX2Handler::getSawErrors ( ) const
inline

Did the XML parser see any errors?

Definition at line 70 of file DDLSAX2Handler.h.

References sawErrors_.

71  {
72  return sawErrors_;
73  }
unsigned int DDLSAX2Handler::getSpaceCount ( ) const
inline

Get the count of spaces processed so far.

Definition at line 75 of file DDLSAX2Handler.h.

References spaceCount_.

Referenced by dumpStats().

76  {
77  return spaceCount_;
78  }
unsigned int spaceCount_
void DDLSAX2Handler::ignorableWhitespace ( const XMLCh *const  chars,
const unsigned int  length 
)
virtual

Definition at line 67 of file DDLSAX2Handler.cc.

References spaceCount_.

69 {
70  spaceCount_ += length;
71 }
unsigned int spaceCount_
void DDLSAX2Handler::resetDocument ( void  )
virtual

Definition at line 74 of file DDLSAX2Handler.cc.

References attrCount_, characterCount_, elementCount_, and spaceCount_.

75 {
76  attrCount_ = 0;
77  characterCount_ = 0;
78  elementCount_ = 0;
79  spaceCount_ = 0;
80 }
unsigned int characterCount_
unsigned int spaceCount_
unsigned int elementCount_
unsigned int attrCount_
void DDLSAX2Handler::setNameSpace ( const std::string &  nms)
virtual

Definition at line 141 of file DDLSAX2Handler.cc.

References nmspace_.

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

142 {
143  nmspace_ = nms;
144 }
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 135 of file DDLSAX2Handler.cc.

References userNS_.

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

136 {
137  userNS_ = userns;
138 }
void DDLSAX2Handler::startElement ( const XMLCh *const  uri,
const XMLCh *const  localname,
const XMLCh *const  qname,
const Attributes attrs 
)
virtual

Reimplemented in DDLSAX2FileHandler, DDLSAX2ConfigHandler, and DDLSAX2ExpressionHandler.

Definition at line 36 of file DDLSAX2Handler.cc.

References attrCount_, and elementCount_.

40 {
41  ++elementCount_;
42  attrCount_ += attrs.getLength();
43 }
unsigned int elementCount_
unsigned int attrCount_
void DDLSAX2Handler::warning ( const SAXParseException exception)
virtual

Definition at line 125 of file DDLSAX2Handler.cc.

126 {
127  edm::LogWarning("DetectorDescription_Parser_DDLSAX2Handler")
128  << "\nWarning at file " << StrX(e.getSystemId())
129  << ", line " << e.getLineNumber()
130  << ", char " << e.getColumnNumber()
131  << "\n Message: " << StrX(e.getMessage()) << std::endl;
132 }
Definition: StrX.h:32

Member Data Documentation

unsigned int DDLSAX2Handler::attrCount_
protected
unsigned int DDLSAX2Handler::characterCount_
protected

Definition at line 118 of file DDLSAX2Handler.h.

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

unsigned int DDLSAX2Handler::elementCount_
protected
std::string DDLSAX2Handler::nmspace_
protected
bool DDLSAX2Handler::sawErrors_
protected

Definition at line 121 of file DDLSAX2Handler.h.

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

unsigned int DDLSAX2Handler::spaceCount_
protected

Definition at line 120 of file DDLSAX2Handler.h.

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

bool DDLSAX2Handler::userNS_
protected

Definition at line 122 of file DDLSAX2Handler.h.

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