CMS 3D CMS Logo

DQMParserBase.cc
Go to the documentation of this file.
3 
4 #include <stdexcept>
12 using namespace xercesc;
13 
15 
17  delete parser;
18  parser = nullptr;
19 }
20 
21 void DQMParserBase::getDocument(std::string configFile, bool UseDB) {
22  parser = new XercesDOMParser;
23  parser->setValidationScheme(XercesDOMParser::Val_Auto);
24  parser->setDoNamespaces(false);
25  if (UseDB) {
26  // std::cout<<"=== This is config file from getDocument ====== "<<std::endl;
27  // std::cout<<configFile<<std::endl;
28  MemBufInputSource mb((const XMLByte*)configFile.c_str(), strlen(configFile.c_str()), "", false);
29  parser->parse(mb);
30  } else {
31  parser->parse(configFile.c_str());
32  }
33  xercesc::DOMDocument* doc = parser->getDocument();
34  assert(doc);
35 }
36 
37 void DQMParserBase::getNewDocument(std::string configFile, bool UseDB) {
38  parser->resetDocumentPool();
39  if (UseDB) {
40  std::cout << "=== This is config file from getNewDocument ==== " << std::endl;
41  std::cout << configFile << std::endl;
42  MemBufInputSource mb((const XMLByte*)configFile.c_str(), strlen(configFile.c_str()), "", false);
43  parser->parse(mb);
44  } else {
45  parser->parse(configFile.c_str());
46  }
47  xercesc::DOMDocument* doc = parser->getDocument();
48  assert(doc);
49 }
51  unsigned int tagsNum = parser->getDocument()->getElementsByTagName(qtxml::_toDOMS(tagName))->getLength();
52  return tagsNum;
53 }
void getDocument(std::string configFile, bool UseDB=false)
Methor that parses the xml file configFile.
int countNodes(std::string tagName)
Returns the number of nodes with given name.
void getNewDocument(std::string configFile, bool UseDB=false)
Parses a new Document.
DQMParserBase()
Creator.
virtual ~DQMParserBase()
Destructor.
XMLCh * _toDOMS(std::string temp)