CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DDLSAX2Handler.cc
Go to the documentation of this file.
1 /***************************************************************************
2  DDLSAX2Handler.cc - description
3  -------------------
4  begin : Mon Oct 22 2001
5  email : case@ucdhep.ucdavis.edu
6  ***************************************************************************/
7 
8 /***************************************************************************
9  * *
10  * DDDParser sub-component of DDD *
11  * *
12  ***************************************************************************/
13 
17 
19 
21  : attrCount_(0),
22  characterCount_(0),
23  elementCount_(0),
24  spaceCount_(0),
25  sawErrors_(false),
26  userNS_(false)
27 {}
28 
30 {}
31 
32 // ---------------------------------------------------------------------------
33 // DDLSAX2Handler: Implementation of the SAX DocumentHandler interface
34 // ---------------------------------------------------------------------------
35 
36 void
37 DDLSAX2Handler::startElement( const XMLCh* const uri,
38  const XMLCh* const localname,
39  const XMLCh* const qname,
40  const Attributes& attrs )
41 {
42  ++elementCount_;
43  attrCount_ += attrs.getLength();
44 }
45 
46 void
47 DDLSAX2Handler::endElement( const XMLCh* const uri,
48  const XMLCh* const localname,
49  const XMLCh* const qname )
50 {
51  // do nothing
52 }
53 
54 void
55 DDLSAX2Handler::characters( const XMLCh* const chars,
56  const unsigned int length )
57 {
58  characterCount_ += length;
59 }
60 
61 void
62 DDLSAX2Handler::comment( const XMLCh *const chars, const unsigned int length )
63 {
64  // do nothing default..
65 }
66 
67 void
68 DDLSAX2Handler::ignorableWhitespace( const XMLCh* const chars,
69  const unsigned int length )
70 {
71  spaceCount_ += length;
72 }
73 
74 void
76 {
77  attrCount_ = 0;
78  characterCount_ = 0;
79  elementCount_ = 0;
80  spaceCount_ = 0;
81 }
82 
83 void
84 DDLSAX2Handler::dumpStats( const std::string& fname )
85 {
86  std::cout << "DetectorDescription/Parser/interface/DDLSAX2Handler::dumpStats, file: "
87  << fname << " ("
88  << getElementCount() << " elems, "
89  << getAttrCount() << " attrs, "
90  << getSpaceCount() << " spaces, "
91  << getCharacterCount() << " chars)" << std::endl;
92 }
93 
94 // ---------------------------------------------------------------------------
95 // DDLSAX2Handler: Overrides of the SAX ErrorHandler interface
96 // Implements ALL required by the Xerces ErrorHandler interface as of 2007-06-26.
97 // ---------------------------------------------------------------------------
98 void
100 {
101  sawErrors_ = true;
102  edm::LogError("DetectorDescription_Parser_DDLSAX2Handler")
103  << "\nError at file " << StrX(e.getSystemId())
104  << ", line " << e.getLineNumber()
105  << ", char " << e.getColumnNumber()
106  << "\n Message: " << StrX(e.getMessage()) << std::endl;
107 }
108 
109 void
111 {
112  sawErrors_ = true;
113  edm::LogError("DetectorDescription_Parser_DDLSAX2Handler")
114  << "\nFatal Error at file " << StrX(e.getSystemId())
115  << ", line " << e.getLineNumber()
116  << ", char " << e.getColumnNumber()
117  << "\n Message: "
118  << StrX(e.getMessage()) << std::endl;
119  throw DDException(std::string("DetectorDescription_Parser_Unrecoverable_Error_from_Xerces: "))
120  << std::string(StrX(e.getMessage()).localForm())
121  << " file: " << std::string(StrX(e.getSystemId()).localForm())
122  << " line: " << e.getLineNumber() << " col: " << e.getColumnNumber();
123 }
124 
125 void
127 {
128  edm::LogWarning("DetectorDescription_Parser_DDLSAX2Handler")
129  << "\nWarning at file " << StrX(e.getSystemId())
130  << ", line " << e.getLineNumber()
131  << ", char " << e.getColumnNumber()
132  << "\n Message: " << StrX(e.getMessage()) << std::endl;
133 }
134 
135 void
137 {
138  userNS_ = userns;
139 }
140 
141 void
142 DDLSAX2Handler::setNameSpace( const std::string& nms )
143 {
144  nmspace_ = nms;
145 }
virtual void characters(const XMLCh *const chars, const unsigned int length)
unsigned int characterCount_
unsigned int getAttrCount() const
Get the count of attributes processed so far.
unsigned int spaceCount_
An exception for DDD errors.
Definition: DDException.h:23
virtual void endElement(const XMLCh *const uri, const XMLCh *const localname, const XMLCh *const qname)
unsigned int elementCount_
virtual void resetDocument()
virtual void warning(const SAXParseException &exception)
XERCES_CPP_NAMESPACE::SAXParseException SAXParseException
virtual void ignorableWhitespace(const XMLCh *const chars, const unsigned int length)
virtual void setUserNS(bool userns)
virtual void fatalError(const SAXParseException &exception)
std::string nmspace_
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.
def qname
Definition: asciidump.py:315
virtual void error(const SAXParseException &exception)
Definition: StrX.h:32
string fname
main script
virtual void setNameSpace(const std::string &nms)
unsigned int attrCount_
virtual void comment(const XMLCh *const chars, const unsigned int length)
tuple cout
Definition: gather_cfg.py:41
virtual void dumpStats(const std::string &fname)
virtual void startElement(const XMLCh *const uri, const XMLCh *const localname, const XMLCh *const qname, const Attributes &attrs)
XERCES_CPP_NAMESPACE::Attributes Attributes