File indexing completed on 2024-04-06 12:02:49
0001 #ifndef _CondTools_Ecal_XMLHelperFunctions_
0002 #define _CondTools_Ecal_XMLHelperFunctions_
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #include <xercesc/dom/DOMNode.hpp>
0013 #include "DataFormats/DetId/interface/DetId.h"
0014 #include <string>
0015 #include "CondTools/Ecal/interface/EcalCondHeader.h"
0016 #include "CondTools/Ecal/interface/XMLTags.h"
0017 #include "Utilities/Xerces/interface/XercesStrUtils.h"
0018 #include <xercesc/dom/DOM.hpp>
0019 #include <sstream>
0020
0021 namespace xuti {
0022
0023
0024 const DetId readCellId(xercesc::DOMElement* node);
0025
0026
0027 xercesc::DOMElement* writeCell(xercesc::DOMNode* node, const DetId& detid);
0028
0029
0030 xercesc::DOMNode* getChildNode(xercesc::DOMNode* node, const std::string& nodename);
0031
0032
0033
0034 void GetNodeStringData(xercesc::DOMNode* node, std::string& value);
0035
0036
0037 template <class T>
0038 void GetNodeData(xercesc::DOMNode* node, T& value) {
0039 std::string value_s = cms::xerces::toString(node->getTextContent());
0040 std::stringstream value_ss(value_s);
0041 value_ss >> value;
0042 }
0043
0044
0045 template <class T>
0046 void WriteNodeWithValue(xercesc::DOMNode* parentNode, const std::string& tag, const T& value) {
0047 xercesc::DOMDocument* doc = parentNode->getOwnerDocument();
0048 xercesc::DOMElement* new_node = doc->createElement(cms::xerces::uStr(tag.c_str()).ptr());
0049 parentNode->appendChild(new_node);
0050
0051 std::stringstream value_ss;
0052 value_ss << value;
0053
0054 xercesc::DOMText* tvalue = doc->createTextNode(cms::xerces::uStr(value_ss.str().c_str()).ptr());
0055 new_node->appendChild(tvalue);
0056 }
0057
0058
0059 void writeHeader(xercesc::DOMNode* parentNode, const EcalCondHeader& header);
0060
0061
0062 void readHeader(xercesc::DOMNode* parentNode, EcalCondHeader& header);
0063
0064
0065 int readHeader(const std::string& filename, EcalCondHeader& header);
0066 }
0067
0068 #endif