test
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 
16 
18 
20  : attrCount_(0),
21  characterCount_(0),
22  elementCount_(0),
23  spaceCount_(0),
24  sawErrors_(false),
25  userNS_(false)
26 {}
27 
29 {}
30 
31 // ---------------------------------------------------------------------------
32 // DDLSAX2Handler: Implementation of the SAX DocumentHandler interface
33 // ---------------------------------------------------------------------------
34 
35 void
36 DDLSAX2Handler::startElement( const XMLCh* const uri,
37  const XMLCh* const localname,
38  const XMLCh* const qname,
39  const Attributes& attrs )
40 {
41  ++elementCount_;
42  attrCount_ += attrs.getLength();
43 }
44 
45 void
46 DDLSAX2Handler::endElement( const XMLCh* const uri,
47  const XMLCh* const localname,
48  const XMLCh* const qname )
49 {
50  // do nothing
51 }
52 
53 void
54 DDLSAX2Handler::characters( const XMLCh* const chars,
55  const unsigned int length )
56 {
57  characterCount_ += length;
58 }
59 
60 void
61 DDLSAX2Handler::comment( const XMLCh *const chars, const unsigned int length )
62 {
63  // do nothing default..
64 }
65 
66 void
67 DDLSAX2Handler::ignorableWhitespace( const XMLCh* const chars,
68  const unsigned int length )
69 {
70  spaceCount_ += length;
71 }
72 
73 void
75 {
76  attrCount_ = 0;
77  characterCount_ = 0;
78  elementCount_ = 0;
79  spaceCount_ = 0;
80 }
81 
82 void
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 }
92 
93 // ---------------------------------------------------------------------------
94 // DDLSAX2Handler: Overrides of the SAX ErrorHandler interface
95 // Implements ALL required by the Xerces ErrorHandler interface as of 2007-06-26.
96 // ---------------------------------------------------------------------------
97 void
99 {
100  sawErrors_ = true;
101  edm::LogError("DetectorDescription_Parser_DDLSAX2Handler")
102  << "\nError at file " << StrX(e.getSystemId())
103  << ", line " << e.getLineNumber()
104  << ", char " << e.getColumnNumber()
105  << "\n Message: " << StrX(e.getMessage()) << std::endl;
106 }
107 
108 void
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 }
123 
124 void
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 }
133 
134 void
136 {
137  userNS_ = userns;
138 }
139 
140 void
142 {
143  nmspace_ = nms;
144 }
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_
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:121
virtual void dumpStats(const std::string &fname)
volatile std::atomic< bool > shutdown_flag false
virtual void startElement(const XMLCh *const uri, const XMLCh *const localname, const XMLCh *const qname, const Attributes &attrs)
XERCES_CPP_NAMESPACE::Attributes Attributes