CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch13/src/DQMServices/ClientConfig/src/DQMParserBase.cc

Go to the documentation of this file.
00001 #include "DQMServices/ClientConfig/interface/DQMParserBase.h"
00002 #include "DQMServices/ClientConfig/interface/ParserFunctions.h"
00003 
00004 
00005 #include <stdexcept>         
00016 using namespace xercesc;
00017 
00018 DQMParserBase::DQMParserBase(){
00019         parser=0; 
00020         doc=0; 
00021 }
00022 
00023 DQMParserBase::~DQMParserBase(){
00024         delete parser;
00025         parser=0; 
00026 }
00027 
00028 
00029 void DQMParserBase::getDocument(std::string configFile, bool UseDB){
00030         
00031     parser = new XercesDOMParser;     
00032     parser->setValidationScheme(XercesDOMParser::Val_Auto);
00033     parser->setDoNamespaces(false);
00034     if(UseDB){
00035 //       std::cout<<"=== This is config file from getDocument ====== "<<std::endl;
00036 //       std::cout<<configFile<<std::endl;
00037       MemBufInputSource mb((const XMLByte*)configFile.c_str(),strlen(configFile.c_str()),"",false);
00038       parser->parse(mb);
00039     }
00040     else{
00041       parser->parse(configFile.c_str()); 
00042     }
00043     doc = parser->getDocument();
00044     assert(doc);
00045 
00046 }
00047 
00048 void DQMParserBase::getNewDocument(std::string configFile, bool UseDB){
00049         //delete doc;
00050         //doc =0;
00051   parser->resetDocumentPool();
00052   if(UseDB){
00053     std::cout<<"=== This is config file from getNewDocument ==== "<<std::endl;
00054     std::cout<<configFile<<std::endl;
00055     MemBufInputSource mb((const XMLByte*)configFile.c_str(),strlen(configFile.c_str()),"",false);
00056     parser->parse(mb);
00057   }
00058   else{
00059     parser->parse(configFile.c_str()); 
00060   }
00061   doc = parser->getDocument();
00062   assert(doc);
00063 
00064 }
00065 int DQMParserBase::countNodes(std::string tagName){
00066         unsigned int tagsNum  = 
00067            doc->getElementsByTagName(qtxml::_toDOMS(tagName))->getLength();
00068         return tagsNum;
00069 }