CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
65  int readHeader(const std::string& filename, EcalCondHeader& header);
66 } // namespace xuti
67 
68 #endif
void GetNodeStringData(xercesc::DOMNode *node, std::string &value)
get the node data as string. Needs to be used to avoid splitting
void WriteNodeWithValue(xercesc::DOMNode *parentNode, const std::string &tag, const T &value)
write a node with
std::string toString(XMLCh const *toTranscode)
void readHeader(xercesc::DOMNode *parentNode, EcalCondHeader &header)
read header from
void writeHeader(xercesc::DOMNode *parentNode, const EcalCondHeader &header)
write
ZStr< XMLCh > uStr(char const *str)
Definition: DetId.h:17
void GetNodeData(xercesc::DOMNode *node, T &value)
get the node data
xercesc::DOMNode * getChildNode(xercesc::DOMNode *node, const std::string &nodename)
get the child of
tuple filename
Definition: lut2db_cfg.py:20
xercesc::DOMElement * writeCell(xercesc::DOMNode *node, const DetId &detid)
Append a Cell node with attributes to.
long double T
const DetId readCellId(xercesc::DOMElement *node)
Assuming.