CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
XMLDocument.h
Go to the documentation of this file.
1 #ifndef PhysicsTools_MVATrainer_XMLDocument_h
2 #define PhysicsTools_MVATrainer_XMLDocument_h
3 
4 #include <string>
5 #include <memory>
6 #include <iosfwd>
7 
8 #include <xercesc/dom/DOM.hpp>
9 #include <xercesc/dom/DOMImplementation.hpp>
10 #include <xercesc/parsers/XercesDOMParser.hpp>
11 #include <xercesc/sax/HandlerBase.hpp>
12 #include <xercesc/sax/InputSource.hpp>
13 #include <xercesc/dom/DOMDocument.hpp>
14 
15 class XMLDocument {
16  public:
17  XMLDocument(const std::string &fileName, bool write = false);
19  ~XMLDocument();
20 
21  inline XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *
22  getDocument() const { return doc; }
23 
24  inline XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *
25  getRootNode() const { return rootNode; }
26 
27  XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *
29 
30  static bool hasAttribute(XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *elem,
31  const char *name);
32  template<typename T>
34  const char *name);
35  template<typename T>
37  const char *name, const T &defValue);
38  template<typename T>
39  static void writeAttribute(XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *elem,
40  const char *name, const T &value);
41 
42  template<typename T>
43  static T readContent(XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *node);
44  template<typename T>
45  static void writeContent(XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *node,
47  const T &value);
48 
49  private:
51  public:
54 
55  private:
56  // do not make any kind of copies
57  XercesPlatform(const XercesPlatform &orig);
59 
60  static unsigned int instances;
61  };
62 
63  void openForRead(std::auto_ptr<std::istream> &inputStream);
64  void openForWrite(const std::string &fileName);
65 
66  std::auto_ptr<XercesPlatform> platform;
67  std::auto_ptr<XERCES_CPP_NAMESPACE_QUALIFIER InputSource> inputSource;
68 
70  bool write;
71 
72  std::auto_ptr<XERCES_CPP_NAMESPACE_QUALIFIER XercesDOMParser> parser;
73  std::auto_ptr<XERCES_CPP_NAMESPACE_QUALIFIER HandlerBase> errHandler;
75 
78 };
79 
80 #include "PhysicsTools/MVATrainer/interface/XMLDocument.icc"
81 
82 #endif // PhysicsTools_MVATrainer_XMLDocument_h
static T readContent(XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *node)
std::auto_ptr< XERCES_CPP_NAMESPACE_QUALIFIER InputSource > inputSource
Definition: XMLDocument.h:67
XERCES_CPP_NAMESPACE_QUALIFIER DOMImplementation * impl
Definition: XMLDocument.h:74
std::auto_ptr< XercesPlatform > platform
Definition: XMLDocument.h:66
#define XERCES_CPP_NAMESPACE_QUALIFIER
Definition: LHERunInfo.h:16
std::auto_ptr< XERCES_CPP_NAMESPACE_QUALIFIER HandlerBase > errHandler
Definition: XMLDocument.h:73
XercesPlatform & operator=(const XercesPlatform &orig)
static bool hasAttribute(XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *elem, const char *name)
Definition: XMLDocument.cc:303
XERCES_CPP_NAMESPACE_QUALIFIER DOMElement * rootNode
Definition: XMLDocument.h:77
static T readAttribute(XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *elem, const char *name)
static void writeContent(XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *node, XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *doc, const T &value)
XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument * doc
Definition: XMLDocument.h:76
void openForWrite(const std::string &fileName)
Definition: XMLDocument.cc:259
static void writeAttribute(XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *elem, const char *name, const T &value)
std::auto_ptr< XERCES_CPP_NAMESPACE_QUALIFIER XercesDOMParser > parser
Definition: XMLDocument.h:72
std::string fileName
Definition: XMLDocument.h:69
XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument * createDocument(const std::string &root)
Definition: XMLDocument.cc:266
XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument * getDocument() const
Definition: XMLDocument.h:22
void openForRead(std::auto_ptr< std::istream > &inputStream)
Definition: XMLDocument.cc:212
XERCES_CPP_NAMESPACE_QUALIFIER DOMElement * getRootNode() const
Definition: XMLDocument.h:25
static unsigned int instances
Definition: XMLDocument.h:60
long double T
DOMElement * root()
Definition: HcalDbXml.cc:126