test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DDLSAX2Handler.h
Go to the documentation of this file.
1 #ifndef DDLSAX2HANDLER_H
2 #define DDLSAX2HANDLER_H
3 
4 // ---------------------------------------------------------------------------
5 // Includes
6 // ---------------------------------------------------------------------------
7 
8 // Xerces C++ Dependencies
9 #include <xercesc/util/XercesDefs.hpp>
10 #include <xercesc/sax2/Attributes.hpp>
11 #include <xercesc/sax2/DefaultHandler.hpp>
12 
13 #include <string>
14 #include <vector>
15 #include <iostream>
16 
17 
19 
36 class DDLSAX2Handler : public XERCES_CPP_NAMESPACE::DefaultHandler
37 {
38 
39  public:
40  typedef XERCES_CPP_NAMESPACE::Attributes Attributes;
41  typedef XERCES_CPP_NAMESPACE::SAXParseException SAXParseException;
42 
43  // -----------------------------------------------------------------------
44  // Constructor and Destructor
45  // -----------------------------------------------------------------------
46 
47  // DDLSAX2Handler();
50 
51  // -----------------------------------------------------------------------
52  // Getter methods
53  // -----------------------------------------------------------------------
55  unsigned int getElementCount() const
56  {
57  return elementCount_;
58  }
60  unsigned int getAttrCount() const
61  {
62  return attrCount_;
63  }
65  unsigned int getCharacterCount() const
66  {
67  return characterCount_;
68  }
70  bool getSawErrors() const
71  {
72  return sawErrors_;
73  }
75  unsigned int getSpaceCount() const
76  {
77  return spaceCount_;
78  }
79 
80  // -----------------------------------------------------------------------
81  // Handlers for the SAX ContentHandler interface
82  // -----------------------------------------------------------------------
83 
84  virtual void startElement(const XMLCh* const uri, const XMLCh* const localname
85  , const XMLCh* const qname, const Attributes& attrs);
86  virtual void endElement(const XMLCh* const uri, const XMLCh* const localname
87  , const XMLCh* const qname);
88  virtual void characters(const XMLCh* const chars, const unsigned int length);
89  virtual void comment (const XMLCh *const chars, const unsigned int length );
90  virtual void ignorableWhitespace(const XMLCh* const chars, const unsigned int length);
91  virtual void resetDocument();
92 
93  // -----------------------------------------------------------------------
94  // Handlers for the SAX ErrorHandler interface
95  // -----------------------------------------------------------------------
96  virtual void warning(const SAXParseException& exception);
97  virtual void error(const SAXParseException& exception);
98  virtual void fatalError(const SAXParseException& exception);
99  virtual void dumpStats(const std::string& fname);
100 
101  protected:
102 
103  // -----------------------------------------------------------------------
104  // Protected data members
105  //
106  // attrCount_
107  // characterCount_
108  // elementCount_
109  // spaceCount_
110  // These are just counters that are run upwards based on the input
111  // from the document handlers.
112  //
113  // sawErrors
114  // This is set by the error handlers, and is queryable later to
115  // see if any errors occurred.
116  // -----------------------------------------------------------------------
117  unsigned int attrCount_;
118  unsigned int characterCount_;
119  unsigned int elementCount_;
120  unsigned int spaceCount_;
122  bool userNS_;
124 /* std::string getnmspace(const std::string& fname); */
125 
126  public:
132  virtual void setUserNS(bool userns);
133  virtual void setNameSpace(const std::string& nms);
134 };
135 
136 #endif
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)
bool getSawErrors() const
Did the XML parser see any errors?
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.
virtual void error(const SAXParseException &exception)
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)
DDLSAX2Handler inherits from Xerces C++ DefaultHandler.
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