CMS 3D CMS Logo

CalibrationXML.h
Go to the documentation of this file.
1 #ifndef CALIBRATIONXML_H
2 #define CALIBRATIONXML_H
3 
4 #include <xercesc/util/XMLString.hpp>
5 #include <xercesc/dom/DOM.hpp>
6 #include <xercesc/dom/DOMElement.hpp>
7 #include <string>
8 #include <sstream>
9 #include <xercesc/sax/HandlerBase.hpp>
10 #include <xercesc/parsers/XercesDOMParser.hpp>
12 
14 public:
15  typedef XERCES_CPP_NAMESPACE::DOMDocument DOMDocument;
16  typedef XERCES_CPP_NAMESPACE::DOMElement DOMElement;
17  typedef XERCES_CPP_NAMESPACE::DOMNode DOMNode;
18  typedef XERCES_CPP_NAMESPACE::HandlerBase HandlerBase;
19  typedef XERCES_CPP_NAMESPACE::XercesDOMParser XercesDOMParser;
20  typedef XERCES_CPP_NAMESPACE::XMLPlatformUtils XMLPlatformUtils;
21  typedef XERCES_CPP_NAMESPACE::XMLString XMLString;
22 
25 
29  void openFile(const std::string &xmlFileName);
30 
34  void saveFile(const std::string &xmlFileName);
35 
36  void closeFile() {
37  delete errHandler;
38  delete parser;
40  errHandler = nullptr;
41  parser = nullptr;
42  }
47 
48  //Static function to make everything easier, less transcode and type conversion
52  template <class T>
53  static void writeAttribute(DOMElement *dom, const std::string &name, const T &value) {
54  std::ostringstream buffer;
55  buffer << value;
56  XMLCh *nameStr = XMLString::transcode(name.c_str());
57  XMLCh *valueStr = XMLString::transcode(buffer.str().c_str());
58  dom->setAttribute(nameStr, valueStr);
59  XMLString::release(&nameStr);
60  XMLString::release(&valueStr);
61  }
62 
66  template <class T>
68  XMLCh *nameStr = XMLString::transcode(name.c_str());
69  char *valueStr = XMLString::transcode(dom->getAttribute(nameStr));
70  std::istringstream buffer(valueStr);
71  T value;
72  buffer >> value;
73  XMLString::release(&nameStr);
74  XMLString::release(&valueStr);
75  return value;
76  }
77 
81  static DOMElement *addChild(DOMNode *dom, const std::string &name);
82 
83 private:
89 };
90 #endif
contentValuesFiles.dom
dom
Definition: contentValuesFiles.py:50
CalibrationXML::XMLString
XERCES_CPP_NAMESPACE::XMLString XMLString
Definition: CalibrationXML.h:21
CalibrationXML
Definition: CalibrationXML.h:13
CalibrationXML::calibrationDOM
DOMElement * calibrationDOM()
Definition: CalibrationXML.h:46
CalibrationXML::addChild
static DOMElement * addChild(DOMNode *dom, const std::string &name)
Definition: CalibrationXML.cc:114
edmScanValgrind.buffer
buffer
Definition: edmScanValgrind.py:171
CalibrationXML::writeAttribute
static void writeAttribute(DOMElement *dom, const std::string &name, const T &value)
Definition: CalibrationXML.h:53
CalibrationXML::errHandler
HandlerBase * errHandler
Definition: CalibrationXML.h:87
CalibrationXML::DOMNode
XERCES_CPP_NAMESPACE::DOMNode DOMNode
Definition: CalibrationXML.h:17
CalibrationXML::~CalibrationXML
~CalibrationXML()
Definition: CalibrationXML.cc:22
CalibrationXML::DOMDocument
XERCES_CPP_NAMESPACE::DOMDocument DOMDocument
Definition: CalibrationXML.h:15
CalibrationXML::CalibrationXML
CalibrationXML()
Definition: CalibrationXML.cc:20
CalibrationXML::doc
DOMDocument * doc
Definition: CalibrationXML.h:86
CalibrationXML::XercesDOMParser
XERCES_CPP_NAMESPACE::XercesDOMParser XercesDOMParser
Definition: CalibrationXML.h:19
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
fetchall_from_DQM_v2.release
release
Definition: fetchall_from_DQM_v2.py:92
CalibrationXML::HandlerBase
XERCES_CPP_NAMESPACE::HandlerBase HandlerBase
Definition: CalibrationXML.h:18
Xerces.h
cms::concurrency::xercesTerminate
void xercesTerminate()
Definition: Xerces.cc:23
value
Definition: value.py:1
CalibrationXML::readAttribute
static T readAttribute(DOMElement *dom, const std::string &name)
Definition: CalibrationXML.h:67
CalibrationXML::openFile
void openFile(const std::string &xmlFileName)
Definition: CalibrationXML.cc:32
CalibrationXML::parser
XercesDOMParser * parser
Definition: CalibrationXML.h:88
CalibrationXML::XMLPlatformUtils
XERCES_CPP_NAMESPACE::XMLPlatformUtils XMLPlatformUtils
Definition: CalibrationXML.h:20
CalibrationXML::saveFile
void saveFile(const std::string &xmlFileName)
Definition: CalibrationXML.cc:100
CalibrationXML::DOMElement
XERCES_CPP_NAMESPACE::DOMElement DOMElement
Definition: CalibrationXML.h:16
T
long double T
Definition: Basic3DVectorLD.h:48
relativeConstraints.value
value
Definition: relativeConstraints.py:53
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
CalibrationXML::m_calibrationDOM
DOMElement * m_calibrationDOM
Definition: CalibrationXML.h:85
CalibrationXML::closeFile
void closeFile()
Definition: CalibrationXML.h:36
CalibrationXML::m_xmlFileName
std::string m_xmlFileName
Definition: CalibrationXML.h:84