CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_13_patch3/src/CondTools/Ecal/interface/DOMHelperFunctions.h

Go to the documentation of this file.
00001 #ifndef _CondTools_Ecal_XMLHelperFunctions_
00002 #define _CondTools_Ecal_XMLHelperFunctions_
00003 
00004 
00013 #include <xercesc/dom/DOMNode.hpp>
00014 #include "DataFormats/DetId/interface/DetId.h"
00015 #include <string>
00016 #include "CondTools/Ecal/interface/EcalCondHeader.h"
00017 #include "CondTools/Ecal/interface/XMLTags.h"
00018 #include "CondTools/Ecal/interface/XercesString.h"
00019 #include <xercesc/dom/DOM.hpp>
00020 #include <sstream>
00021 
00022 
00023 
00024 namespace xuti {
00025 
00027   const DetId readCellId(xercesc::DOMElement* node);
00028 
00030   xercesc::DOMElement*  writeCell(xercesc::DOMNode* node, const DetId& detid);
00031   
00033   xercesc::DOMNode * getChildNode(xercesc::DOMNode * node,  
00034                                   const std::string& nodename );
00035 
00037   //  white spaces instead of the templatized GetNodeData
00038   void GetNodeStringData(xercesc::DOMNode* node, std::string& value);
00039   
00040 
00041   
00043   template <class T> void GetNodeData(xercesc::DOMNode* node, T& value)
00044     {
00045       std::string value_s = toNative(node->getTextContent());
00046       std::stringstream value_ss(value_s);
00047       value_ss>> value; 
00048     }
00049   
00050 
00052   template <class T> void WriteNodeWithValue(xercesc::DOMNode* parentNode,
00053                                              const std::string& tag,
00054                                              const T& value)
00055     {
00056 
00057       xercesc::DOMDocument * doc = parentNode->getOwnerDocument();
00058       xercesc::DOMElement* new_node = doc->createElement(fromNative(tag).c_str());
00059       parentNode->appendChild(new_node);
00060       
00061       std::stringstream value_ss;
00062       value_ss <<value;
00063  
00064       xercesc::DOMText* tvalue = 
00065         doc->createTextNode(fromNative(value_ss.str()).c_str());
00066       new_node->appendChild(tvalue);
00067       
00068     }
00069  
00070 
00072   void writeHeader (xercesc::DOMNode* parentNode, 
00073                     const EcalCondHeader& header );
00074   
00076   void readHeader(xercesc::DOMNode* parentNode, EcalCondHeader& header); 
00077 
00078 
00080   int readHeader(const std::string& filename, EcalCondHeader& header);
00081 }
00082 
00083 
00084 #endif
00085 
00086 
00087 
00088