CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_8_patch3/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 }
00021 
00022 DQMParserBase::~DQMParserBase(){
00023         delete parser;
00024         parser=0; 
00025 }
00026 
00027 
00028 void DQMParserBase::getDocument(std::string configFile, bool UseDB){
00029         
00030     parser = new XercesDOMParser;     
00031     parser->setValidationScheme(XercesDOMParser::Val_Auto);
00032     parser->setDoNamespaces(false);
00033     if(UseDB){
00034 //       std::cout<<"=== This is config file from getDocument ====== "<<std::endl;
00035 //       std::cout<<configFile<<std::endl;
00036       MemBufInputSource mb((const XMLByte*)configFile.c_str(),strlen(configFile.c_str()),"",false);
00037       parser->parse(mb);
00038     }
00039     else{
00040       parser->parse(configFile.c_str()); 
00041     }
00042     xercesc::DOMDocument* doc = parser->getDocument();
00043     assert(doc);
00044 
00045 }
00046 
00047 void DQMParserBase::getNewDocument(std::string configFile, bool UseDB){
00048   parser->resetDocumentPool();
00049   if(UseDB){
00050     std::cout<<"=== This is config file from getNewDocument ==== "<<std::endl;
00051     std::cout<<configFile<<std::endl;
00052     MemBufInputSource mb((const XMLByte*)configFile.c_str(),strlen(configFile.c_str()),"",false);
00053     parser->parse(mb);
00054   }
00055   else{
00056     parser->parse(configFile.c_str()); 
00057   }
00058   xercesc::DOMDocument* doc = parser->getDocument();
00059   assert(doc);
00060 
00061 }
00062 int DQMParserBase::countNodes(std::string tagName){
00063         unsigned int tagsNum  = 
00064           parser->getDocument()->getElementsByTagName(qtxml::_toDOMS(tagName))->getLength();
00065         return tagsNum;
00066 }