test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DOMHelperFunctions.h
Go to the documentation of this file.
1 #ifndef _CondTools_Ecal_XMLHelperFunctions_
2 #define _CondTools_Ecal_XMLHelperFunctions_
3 
4 
13 #include <xercesc/dom/DOMNode.hpp>
15 #include <string>
19 #include <xercesc/dom/DOM.hpp>
20 #include <sstream>
21 
22 
23 
24 namespace xuti {
25 
27  const DetId readCellId(xercesc::DOMElement* node);
28 
30  xercesc::DOMElement* writeCell(xercesc::DOMNode* node, const DetId& detid);
31 
33  xercesc::DOMNode * getChildNode(xercesc::DOMNode * node,
34  const std::string& nodename );
35 
37  // white spaces instead of the templatized GetNodeData
38  void GetNodeStringData(xercesc::DOMNode* node, std::string& value);
39 
40 
41 
43  template <class T> void GetNodeData(xercesc::DOMNode* node, T& value)
44  {
45  std::string value_s = toNative(node->getTextContent());
46  std::stringstream value_ss(value_s);
47  value_ss>> value;
48  }
49 
50 
52  template <class T> void WriteNodeWithValue(xercesc::DOMNode* parentNode,
53  const std::string& tag,
54  const T& value)
55  {
56 
57  xercesc::DOMDocument * doc = parentNode->getOwnerDocument();
58  xercesc::DOMElement* new_node = doc->createElement(fromNative(tag).c_str());
59  parentNode->appendChild(new_node);
60 
61  std::stringstream value_ss;
62  value_ss <<value;
63 
64  xercesc::DOMText* tvalue =
65  doc->createTextNode(fromNative(value_ss.str()).c_str());
66  new_node->appendChild(tvalue);
67 
68  }
69 
70 
72  void writeHeader (xercesc::DOMNode* parentNode,
73  const EcalCondHeader& header );
74 
76  void readHeader(xercesc::DOMNode* parentNode, EcalCondHeader& header);
77 
78 
80  int readHeader(const std::string& filename, EcalCondHeader& header);
81 }
82 
83 
84 #endif
85 
86 
87 
88 
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
void readHeader(xercesc::DOMNode *parentNode, EcalCondHeader &header)
read header from
void writeHeader(xercesc::DOMNode *parentNode, const EcalCondHeader &header)
write
Definition: DetId.h:18
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
XercesString fromNative(const char *str)
Definition: XercesString.h:31
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.
std::string toNative(const XMLCh *str)
Definition: XercesString.h:42