CMS 3D CMS Logo

DOMHelperFunctions.h
Go to the documentation of this file.
1 #ifndef _CondTools_Ecal_XMLHelperFunctions_
2 #define _CondTools_Ecal_XMLHelperFunctions_
3 
12 #include <xercesc/dom/DOMNode.hpp>
14 #include <string>
18 #include <xercesc/dom/DOM.hpp>
19 #include <sstream>
20 
21 namespace xuti {
22 
24  const DetId readCellId(xercesc::DOMElement* node);
25 
27  xercesc::DOMElement* writeCell(xercesc::DOMNode* node, const DetId& detid);
28 
30  xercesc::DOMNode* getChildNode(xercesc::DOMNode* node, const std::string& nodename);
31 
33  // white spaces instead of the templatized GetNodeData
34  void GetNodeStringData(xercesc::DOMNode* node, std::string& value);
35 
37  template <class T>
38  void GetNodeData(xercesc::DOMNode* node, T& value) {
39  std::string value_s = cms::xerces::toString(node->getTextContent());
40  std::stringstream value_ss(value_s);
41  value_ss >> value;
42  }
43 
45  template <class T>
46  void WriteNodeWithValue(xercesc::DOMNode* parentNode, const std::string& tag, const T& value) {
47  xercesc::DOMDocument* doc = parentNode->getOwnerDocument();
48  xercesc::DOMElement* new_node = doc->createElement(cms::xerces::uStr(tag.c_str()).ptr());
49  parentNode->appendChild(new_node);
50 
51  std::stringstream value_ss;
52  value_ss << value;
53 
54  xercesc::DOMText* tvalue = doc->createTextNode(cms::xerces::uStr(value_ss.str().c_str()).ptr());
55  new_node->appendChild(tvalue);
56  }
57 
59  void writeHeader(xercesc::DOMNode* parentNode, const EcalCondHeader& header);
60 
62  void readHeader(xercesc::DOMNode* parentNode, EcalCondHeader& header);
63 
66 } // namespace xuti
67 
68 #endif
xuti::getChildNode
xercesc::DOMNode * getChildNode(xercesc::DOMNode *node, const std::string &nodename)
get the child of
XercesStrUtils.h
common_cff.doc
doc
Definition: common_cff.py:54
xuti::writeHeader
void writeHeader(xercesc::DOMNode *parentNode, const EcalCondHeader &header)
write
Definition: DOMHelperFunctions.cc:151
xuti::writeCell
xercesc::DOMElement * writeCell(xercesc::DOMNode *node, const DetId &detid)
Append a Cell node with attributes to.
Definition: DOMHelperFunctions.cc:71
xuti::GetNodeStringData
void GetNodeStringData(xercesc::DOMNode *node, std::string &value)
get the node data as string. Needs to be used to avoid splitting
Definition: DOMHelperFunctions.cc:213
DetId
Definition: DetId.h:17
cms::xerces::toString
std::string toString(XMLCh const *toTranscode)
Definition: XercesStrUtils.h:34
GlobalPosition_Frontier_DevDB_cff.tag
tag
Definition: GlobalPosition_Frontier_DevDB_cff.py:11
xuti::WriteNodeWithValue
void WriteNodeWithValue(xercesc::DOMNode *parentNode, const std::string &tag, const T &value)
write a node with
Definition: DOMHelperFunctions.h:46
corrVsCorr.filename
filename
Definition: corrVsCorr.py:123
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
EcalCondHeader
Definition: EcalCondHeader.h:16
value
Definition: value.py:1
xuti
Definition: DOMHelperFunctions.h:21
cms::xerces::uStr
ZStr< XMLCh > uStr(char const *str)
Definition: XercesStrUtils.h:30
DetId.h
T
long double T
Definition: Basic3DVectorLD.h:48
EcalCondHeader.h
relativeConstraints.value
value
Definition: relativeConstraints.py:53
RecoTauValidation_cfi.header
header
Definition: RecoTauValidation_cfi.py:292
xuti::readCellId
const DetId readCellId(xercesc::DOMElement *node)
Assuming.
Definition: DOMHelperFunctions.cc:24
XMLTags.h
xuti::readHeader
void readHeader(xercesc::DOMNode *parentNode, EcalCondHeader &header)
read header from
Definition: DOMHelperFunctions.cc:164
xuti::GetNodeData
void GetNodeData(xercesc::DOMNode *node, T &value)
get the node data
Definition: DOMHelperFunctions.h:38