CMS 3D CMS Logo

XmlConfigParser.cc
Go to the documentation of this file.
1 #include <iostream>
2 //#include <algorithm>
3 //#include <utility>
4 using namespace std;
5 
8 
11 
12 #include "xercesc/util/PlatformUtils.hpp"
13 
15 
16 using namespace l1t;
17 
18 //inline std::string _toString(XMLCh const* toTranscode) {
19 // char *c = xercesc::XMLString::transcode(toTranscode);
20 // std::string retval = c;
21 // xercesc::XMLString::release(&c);
22 // return retval;
23 //}
24 //
25 //inline XMLCh* _toDOMS(std::string temp) {
26 // XMLCh* buff = XMLString::transcode(temp.c_str());
27 // return buff;
28 //}
29 
30 XmlConfigParser::XmlConfigParser() :
31  kTagHw(nullptr),
32  kTagAlgo(nullptr),
33  kTagRunSettings(nullptr),
34  kTagDb(nullptr),
35  kTagKey(nullptr),
36  kTagLoad(nullptr),
37  kTagContext(nullptr),
38  kTagParam(nullptr),
39  kTagMask(nullptr),
40  kTagDisable(nullptr),
41  kTagExclBoards(nullptr),
42  kTagExclude(nullptr),
43  kTagColumns(nullptr),
44  kTagTypes(nullptr),
45  kTagRow(nullptr),
46  kTagProcessor( nullptr),
47  kTagRole(nullptr),
48  kTagCrate(nullptr),
49  kTagSlot(nullptr),
50  kTagDaqTtc(nullptr),
51  kAttrId(nullptr),
52  kAttrType(nullptr),
53  kAttrDelim(nullptr),
54  kAttrModule(nullptr),
55  kTypeTable("table")
56 {
57  XMLPlatformUtils::Initialize();
58 
59  kTagHw = XMLString::transcode("system");
60  kTagAlgo = XMLString::transcode("algo");
61  kTagRunSettings = XMLString::transcode("run-settings");
62  kTagDb = XMLString::transcode("db");
63  kTagKey = XMLString::transcode("key");
64  kTagLoad = XMLString::transcode("load");
65  kTagContext = XMLString::transcode("context");
66  kTagParam = XMLString::transcode("param");
67  kTagMask = XMLString::transcode("mask");
68  kTagDisable = XMLString::transcode("disable");
69  kTagExclBoards = XMLString::transcode("excluded-boards");
70  kTagExclude = XMLString::transcode("exclude");
71  kTagColumns = XMLString::transcode("columns");
72  kTagTypes = XMLString::transcode("types");
73  kTagRow = XMLString::transcode("row");
74  kTagProcessor = XMLString::transcode("processor");
75  kTagRole = XMLString::transcode("role");
76  kTagCrate = XMLString::transcode("crate");
77  kTagSlot = XMLString::transcode("slot");
78  kTagDaqTtc = XMLString::transcode("daqttc-mgr");
79  kAttrId = XMLString::transcode("id");
80  kAttrType = XMLString::transcode("type");
81  kAttrDelim = XMLString::transcode("delimiter");
82  kAttrModule = XMLString::transcode("module");
83 
85  parser_ = new XercesDOMParser();
86  parser_->setValidationScheme(XercesDOMParser::Val_Auto);
87  parser_->setDoNamespaces(false);
88 
89  doc_ = nullptr;
90 }
91 
92 
94  kTagHw(nullptr),
95  kTagAlgo(nullptr),
96  kTagRunSettings(nullptr),
97  kTagDb(nullptr),
98  kTagKey(nullptr),
99  kTagLoad(nullptr),
100  kTagContext(nullptr),
101  kTagParam(nullptr),
102  kTagMask(nullptr),
103  kTagDisable(nullptr),
104  kTagExclBoards(nullptr),
105  kTagExclude(nullptr),
106  kTagColumns(nullptr),
107  kTagTypes(nullptr),
108  kTagRow(nullptr),
109  kTagProcessor(nullptr),
110  kTagRole(nullptr),
111  kTagCrate(nullptr),
112  kTagSlot(nullptr),
113  kTagDaqTtc(nullptr),
114  kAttrId(nullptr),
115  kAttrType(nullptr),
116  kAttrDelim(nullptr),
117  kAttrModule(nullptr),
118  kTypeTable("table")
119 {
120  XMLPlatformUtils::Initialize();
121 
122  kTagHw = XMLString::transcode("system");
123  kTagAlgo = XMLString::transcode("algo");
124  kTagRunSettings = XMLString::transcode("run-settings");
125  kTagDb = XMLString::transcode("db");
126  kTagKey = XMLString::transcode("key");
127  kTagLoad = XMLString::transcode("load");
128  kTagContext = XMLString::transcode("context");
129  kTagParam = XMLString::transcode("param");
130  kTagMask = XMLString::transcode("mask");
131  kTagDisable = XMLString::transcode("disable");
132  kTagExclBoards = XMLString::transcode("excluded-boards");
133  kTagExclude = XMLString::transcode("exclude");
134  kTagColumns = XMLString::transcode("columns");
135  kTagTypes = XMLString::transcode("types");
136  kTagRow = XMLString::transcode("row");
137  kTagProcessor = XMLString::transcode("processor");
138  kTagRole = XMLString::transcode("role");
139  kTagCrate = XMLString::transcode("crate");
140  kTagSlot = XMLString::transcode("slot");
141  kTagDaqTtc = XMLString::transcode("daqttc-mgr");
142  kAttrId = XMLString::transcode("id");
143  kAttrType = XMLString::transcode("type");
144  kAttrDelim = XMLString::transcode("delimiter");
145  kAttrModule = XMLString::transcode("module");
146 
147  parser_ = nullptr;
148  doc_ = doc;
149 }
150 
151 
153 {
154  delete parser_;
155  XMLPlatformUtils::Terminate();
156 }
157 
158 
159 void XmlConfigParser::readDOMFromString(const std::string& str, DOMDocument*& doc)
160 {
161  MemBufInputSource xmlstr_buf((const XMLByte*)(str.c_str()), str.size(), "xmlstrbuf");
162  parser_->parse(xmlstr_buf);
163  doc = parser_->getDocument();
164  assert(doc);
165 }
166 
167 
169 {
170  MemBufInputSource xmlstr_buf((const XMLByte*)(str.c_str()), str.size(), "xmlstrbuf");
171  parser_->parse(xmlstr_buf);
172  doc_ = parser_->getDocument();
173  assert(doc_);
174 }
175 
176 
177 void XmlConfigParser::readDOMFromFile(const std::string& fName, DOMDocument*& doc)
178 {
179  parser_->parse(fName.c_str());
180  doc = parser_->getDocument();
181 
182  if (! doc) {
183  edm::LogError("XmlConfigParser") << "Could not parse file " << fName << "\n";
184  }
185 
186  assert(doc);
187 }
188 
189 
191 {
192  parser_->parse(fName.c_str());
193  doc_ = parser_->getDocument();
194 
195  if (! doc_) {
196  edm::LogError("XmlConfigParser") << "Could not parse file " << fName << "\n";
197  }
198 
199  assert(doc_);
200 }
201 
202 
203 void XmlConfigParser::readRootElement(TriggerSystem& aTriggerSystem, const std::string& sysId)
204 {
205  DOMElement* rootElement = doc_->getDocumentElement();
206  if (rootElement) {
207  if (rootElement->getNodeType() == DOMNode::ELEMENT_NODE) {
208  readElement(rootElement, aTriggerSystem, sysId);
209  }
210  } else {
211  throw std::runtime_error("No xml root element found");
212  }
213 }
214 
215 
216 void XmlConfigParser::readElement(const DOMElement* element, TriggerSystem& aTriggerSystem, const std::string& sysId)
217 {
218  if (XMLString::equals(element->getTagName(), kTagHw)) {
219  // in case this is a HW description
220  readHwDescription(element, aTriggerSystem, sysId);
221  } else if (XMLString::equals(element->getTagName(), kTagAlgo) || XMLString::equals(element->getTagName(), kTagRunSettings)) {
222  // in case this is a configuration snippet
223  readContext(element, sysId, aTriggerSystem);
224  }
225 }
226 
227 
228 void XmlConfigParser::readHwDescription(const DOMElement* element, TriggerSystem& aTriggerSystem, const std::string& sysId)
229 {
230  // if sysId == "" set the systemId of the trigsystem from the xml sytem id
231  if (sysId != ""){
232  std::string sId = cms::xerces::toString(element->getAttribute(kAttrId));
233  pruneString(sId);
234  if( sId != sysId ) return;
235  }
236 
237  char *sysId_ = xercesc::XMLString::transcode( element->getAttribute(kAttrId) );
238  aTriggerSystem.setSystemId( pruneString(sysId_) );
240 
241  // handle processors
242  DOMNodeList* processors = element->getElementsByTagName(kTagProcessor);
243  XMLSize_t nodeCount = processors->getLength();
244  for (XMLSize_t xx = 0; xx < nodeCount; ++xx) {
245  DOMNode* currentNode = processors->item(xx);
246  if (currentNode->getNodeType() && currentNode->getNodeType() == DOMNode::ELEMENT_NODE) { //no null and is element
247  DOMElement* currentElement = static_cast<DOMElement*>( currentNode );
248 
249  string proc = cms::xerces::toString( currentElement->getAttribute(kAttrId) );
250  pruneString(proc);
251  string role, crate, slot;
252 
253  DOMNodeList* roles = currentElement->getElementsByTagName(kTagRole);
254  // roles of this processor (should be only one)
255  if( roles->getLength() != 1 )
256  throw std::runtime_error( string("Configutration specify not exactly one role") );
257 // for (XMLSize_t i = 0; i < roles->getLength(); ++i) {
258  {
259  XMLSize_t i = 0;
260  DOMNodeList* roleChilds = roles->item(i)->getChildNodes();
261  if( roleChilds->getLength() != 1 )
262  throw std::runtime_error( string("Configutration specify not exactly one role") );
263  {
264 // for (XMLSize_t j = 0; j < roleChilds->getLength(); ++j) {
265  XMLSize_t j = 0;
266  if (roleChilds->item(j)->getNodeType() == DOMNode::TEXT_NODE) {
267  role = cms::xerces::toString( roleChilds->item(j)->getNodeValue() );
268  pruneString(role);
269  }
270  }
271  }
272 
273  DOMNodeList* crates = currentElement->getElementsByTagName(kTagCrate);
274  // crates of this processor (should be only one)
275  if( crates->getLength() != 1 )
276  throw std::runtime_error( string("Configutration specify not exactly one crate") );
277 // for (XMLSize_t i = 0; i < crates->getLength(); ++i) {
278  {
279  XMLSize_t i = 0;
280  DOMNodeList* crateChilds = crates->item(i)->getChildNodes();
281  if( crateChilds->getLength() != 1 )
282  throw std::runtime_error( string("Configutration specify not exactly one crate") );
283  {
284  XMLSize_t j = 0;
285 // for (XMLSize_t j = 0; j < crateChilds->getLength(); ++j) {
286  if (crateChilds->item(j)->getNodeType() == DOMNode::TEXT_NODE) {
287  crate = cms::xerces::toString( crateChilds->item(j)->getNodeValue() );
288  pruneString(crate);
289  }
290  }
291  }
292 
293  DOMNodeList* slots = currentElement->getElementsByTagName(kTagSlot);
294  // slots of this processor (should be only one)
295  if( slots->getLength() != 1 )
296  throw std::runtime_error( string("Configutration specify not exactly one slot") );
297 // for (XMLSize_t i = 0; i < slots->getLength(); ++i) {
298  {
299  XMLSize_t i = 0;
300  DOMNodeList* slotChilds = slots->item(i)->getChildNodes();
301  if( slotChilds->getLength() != 1 )
302  throw std::runtime_error( string("Configutration specify not exactly one slot") );
303 // for (XMLSize_t j = 0; j < slotChilds->getLength(); ++j) {
304  {
305  XMLSize_t j = 0;
306  if (slotChilds->item(j)->getNodeType() == DOMNode::TEXT_NODE) {
307  slot = cms::xerces::toString( slotChilds->item(j)->getNodeValue() );
308  pruneString(slot);
309  }
310  }
311  }
312 
313  aTriggerSystem.addProcessor(proc.c_str(), role.c_str(), crate.c_str(), slot.c_str());
314  }
315  }
316 
317  // handle DAQ TTC managers
318  DOMNodeList* daqttcs = element->getElementsByTagName(kTagDaqTtc);
319  nodeCount = daqttcs->getLength();
320  for (XMLSize_t xx = 0; xx < nodeCount; ++xx) {
321  DOMNode* currentNode = daqttcs->item(xx);
322  if (currentNode->getNodeType() && currentNode->getNodeType() == DOMNode::ELEMENT_NODE) { //no null and is element
323  DOMElement* currentElement = static_cast<DOMElement*>( currentNode );
324  string daqttc = cms::xerces::toString( currentElement->getAttribute(kAttrId) );
325  string role, crate;
326 
327  DOMNodeList* roles = currentElement->getElementsByTagName(kTagRole);
328  // roles of this DAQ TTC manager (should be only one)
329  if( roles->getLength() != 1 )
330  throw std::runtime_error( string("Configutration specify not exactly one role") );
331 // for (XMLSize_t i = 0; i < roles->getLength(); ++i) {
332  {
333  XMLSize_t i = 0;
334  DOMNodeList* roleChilds = roles->item(i)->getChildNodes();
335  if( roleChilds->getLength() != 1 )
336  throw std::runtime_error( string("Configutration specify not exactly one role") );
337 // for (XMLSize_t j = 0; j < roleChilds->getLength(); ++j) {
338  {
339  XMLSize_t j = 0;
340  if (roleChilds->item(j)->getNodeType() == DOMNode::TEXT_NODE) {
341  role = cms::xerces::toString(roleChilds->item(j)->getNodeValue());
342  pruneString(role);
343  }
344  }
345  }
346 
347  DOMNodeList* crates = currentElement->getElementsByTagName(kTagCrate);
348  // crates of this DAQ TTC manager (should be only one)
349  if( crates->getLength() != 1 )
350  throw std::runtime_error( string("Configutration specify not exactly one crate") );
351 // for (XMLSize_t i = 0; i < crates->getLength(); ++i) {
352  {
353  XMLSize_t i = 0;
354  DOMNodeList* crateChilds = crates->item(i)->getChildNodes();
355  if( crateChilds->getLength() != 1 )
356  throw std::runtime_error( string("Configutration specify not exactly one crate") );
357 // for (XMLSize_t j = 0; j < crateChilds->getLength(); ++j) {
358  {
359  XMLSize_t j = 0;
360  if (crateChilds->item(j)->getNodeType() == DOMNode::TEXT_NODE) {
361  crate = cms::xerces::toString(crateChilds->item(j)->getNodeValue());
362  pruneString(crate);
363  }
364  }
365  }
366 
367  aTriggerSystem.addDaq(daqttc.c_str(), role.c_str(), crate.c_str());
368  }
369  }
370 
371  // handle excluded boards
372  DOMNodeList* exclBoards = element->getElementsByTagName(kTagExclBoards);
373  for (XMLSize_t xx = 0; xx < exclBoards->getLength(); ++xx) {
374  DOMElement* exclBoardElem = static_cast<DOMElement*>(exclBoards->item(xx));
375 
376  for (DOMElement* elem = static_cast<DOMElement*>(exclBoardElem->getFirstChild()); elem; elem = static_cast<DOMElement*>(elem->getNextSibling())) {
377  if (elem->getNodeType() == DOMNode::ELEMENT_NODE) {
378  if (XMLString::equals(elem->getTagName(), kTagExclude)) {
379  // found an excluded board
380  std::string id = cms::xerces::toString(elem->getAttribute(kAttrId));
381  pruneString(id);
382  aTriggerSystem.disableProcOrRoleOrDaq(id.c_str()); // handle in the same way as disabled ids in the run-settings
383  }
384  }
385  }
386  }
387 }
388 
389 
390 void XmlConfigParser::readContext(const DOMElement* element, const std::string& sysId, TriggerSystem& aTriggerSystem)
391 {
392  std::string systemId = sysId;
393  if (systemId == "") {
394  systemId = aTriggerSystem.systemId();
395  }
396  if (cms::xerces::toString(element->getAttribute(kAttrId)) == systemId) {
397  DOMNodeList* contextElements = element->getElementsByTagName(kTagContext);
398 
399  for (XMLSize_t i = 0; i < contextElements->getLength(); ++i) {
400  DOMElement* contextElement = static_cast<DOMElement*>(contextElements->item(i));
401  std::string contextId = cms::xerces::toString(contextElement->getAttribute(kAttrId));
402  pruneString(contextId);
403 
404  for (DOMElement* elem = static_cast<DOMElement*>(contextElement->getFirstChild()); elem; elem = static_cast<DOMElement*>(elem->getNextSibling())) {
405  if (elem->getNodeType() == DOMNode::ELEMENT_NODE) {
406  if (XMLString::equals(elem->getTagName(), kTagParam)) {
407  // found a parameter
408  string id = cms::xerces::toString( elem->getAttribute(kAttrId) );
409  string type = cms::xerces::toString( elem->getAttribute(kAttrType) );
410  string delim = cms::xerces::toString( elem->getAttribute(kAttrDelim) );
411  pruneString(id);
412  pruneString(type);
413  pruneString(delim);
414 
415  // the type table needs special treatment since it consists of child nodes
416  if (type == kTypeTable) {
417 
418  // get the columns string
419  std::string columnsStr = "";
420  DOMNodeList* colElements = elem->getElementsByTagName(kTagColumns);
421  for (XMLSize_t j = 0; j < colElements->getLength(); ++j) {
422  DOMNodeList* colChilds = colElements->item(j)->getChildNodes();
423  for (XMLSize_t k = 0; k < colChilds->getLength(); ++k) {
424  if (colChilds->item(k)->getNodeType() == DOMNode::TEXT_NODE) {
427  char *cStr = xercesc::XMLString::transcode( colChilds->item(k)->getNodeValue() );
428  char *saveptr, first = 1;
429  for(char *item=strtok_r(cStr,delim.c_str(),&saveptr);
430  item != nullptr;
431  item = strtok_r(nullptr,delim.c_str(),&saveptr), first=0
432  ) columnsStr += (first ? std::string("") : delim) + pruneString(item);
434  }
435  }
436  }
437 
438  // get the column type string
439  std::string typesStr = "";
440  DOMNodeList* colTypesElements = elem->getElementsByTagName(kTagTypes);
441  for (XMLSize_t j = 0; j < colTypesElements->getLength(); ++j) {
442  DOMNodeList* colTypesChilds = colTypesElements->item(j)->getChildNodes();
443  for (XMLSize_t k = 0; k < colTypesChilds->getLength(); ++k) {
444  if (colTypesChilds->item(k)->getNodeType() == DOMNode::TEXT_NODE) {
447  char *tStr = xercesc::XMLString::transcode( colTypesChilds->item(k)->getNodeValue() );
448  char *saveptr, first = 1;
449  for(char *item=strtok_r(tStr,delim.c_str(),&saveptr);
450  item != nullptr;
451  item = strtok_r(nullptr,delim.c_str(),&saveptr), first=0
452  ) typesStr += (first ? std::string("") : delim) + pruneString(item);
454  }
455  }
456  }
457 
458  // get the rows
459  std::vector<std::string> rowStrs;
460  DOMNodeList* rowElements = elem->getElementsByTagName(kTagRow);
461  for (XMLSize_t j = 0; j < rowElements->getLength(); ++j) {
462  DOMNodeList* rowChilds = rowElements->item(j)->getChildNodes();
463  for (XMLSize_t k = 0; k < rowChilds->getLength(); ++k) {
464  if (rowChilds->item(k)->getNodeType() == DOMNode::TEXT_NODE) {
468  char *rStr = xercesc::XMLString::transcode( rowChilds->item(k)->getNodeValue() );
469  char *saveptr, first = 1;
470  std::string row;
471  for(char *item=strtok_r(rStr,delim.c_str(),&saveptr);
472  item != nullptr;
473  item = strtok_r(nullptr,delim.c_str(),&saveptr), first=0
474  ) row += (first ? std::string("") : delim) + pruneString(item);
475 
476  rowStrs.push_back(row);
478  }
479  }
480  }
481 // std::cout << "param element node with id attribute " << id << " and type attribute " << typesStr << std::endl;
482  aTriggerSystem.addTable(id.c_str(), contextId.c_str(), columnsStr.c_str(), typesStr.c_str(), rowStrs, delim.c_str());
483 
484  } else { // all types other than table
485  std::string value = "";
486  DOMNodeList* valNodes = elem->getChildNodes();
487  for (XMLSize_t j = 0; j < valNodes->getLength(); ++j) {
488  if (valNodes->item(j)->getNodeType() == DOMNode::TEXT_NODE) {
489  value += cms::xerces::toString(valNodes->item(j)->getNodeValue()); // should we prune?
490  }
491  }
492 
493  // strip leading and trailing line breaks and spaces
494  pruneString(value);
495 
496 // std::cout << "param element node with id attribute " << id << " and type attribute " << type << " with value: [" << value << "]" << std::endl;
497  aTriggerSystem.addParameter(id.c_str(), contextId.c_str(), type.c_str(), value.c_str(), delim.c_str());
498 
499  }
500 
501  } else if (XMLString::equals(elem->getTagName(), kTagMask)) {
502  // found a Mask
503  std::string id = cms::xerces::toString(elem->getAttribute(kAttrId));
504  //std::cout << "Mask element node with id attribute " << id << std::endl;
505  pruneString(id);
506  aTriggerSystem.addMask(id.c_str(), contextId.c_str());
507 
508  } else if (XMLString::equals(elem->getTagName(), kTagDisable)) {
509  // found a disable
510  std::string id = cms::xerces::toString(elem->getAttribute(kAttrId));
511  pruneString(id);
512  aTriggerSystem.disableProcOrRoleOrDaq(id.c_str());
513  }
514  }
515  }
516  }
517  }
518 }
519 
520 
521 void XmlConfigParser::readContexts(const std::string& key, const std::string& sysId, TriggerSystem& aTriggerSystem)
522 {
523  DOMElement* keyElement = getKeyElement(key);
524  if (keyElement) {
525  for (DOMElement* elem = static_cast<DOMElement*>(keyElement->getFirstChild()); elem; elem = static_cast<DOMElement*>(elem->getNextSibling())) {
526  if (elem->getNodeType() == DOMNode::ELEMENT_NODE) {
527  if (XMLString::equals(elem->getTagName(), kTagAlgo) || XMLString::equals(elem->getTagName(), kTagRunSettings)) {
528  readContext(elem, sysId, aTriggerSystem);
529  }
530  }
531  }
532  } else {
533  throw std::runtime_error("Key not found: " + key);
534  }
535 }
536 
537 
539 {
540  DOMElement* rootElement = doc_->getDocumentElement();
541  if (XMLString::equals(rootElement->getTagName(), kTagDb)) {
542  DOMNodeList* keyElements = rootElement->getElementsByTagName(kTagKey);
543 
544  for (XMLSize_t i = 0; i < keyElements->getLength(); ++i) {
545  DOMElement* keyElement = static_cast<DOMElement*>(keyElements->item(i));
546  if (cms::xerces::toString(keyElement->getAttribute(kAttrId)) == key) { // we found the key we were looking for
547  return keyElement;
548  }
549  }
550  }
551  return nullptr;
552 }
553 
554 
556 {
557  DOMElement* keyElement = getKeyElement(key);
558  if (keyElement) {
559  DOMNodeList* loadElements = keyElement->getElementsByTagName(kTagLoad);
560  for (XMLSize_t i = 0; i < loadElements->getLength(); ++i) {
561  DOMElement* loadElement = static_cast<DOMElement*>(loadElements->item(i));
562  std::string fileName = cms::xerces::toString(loadElement->getAttribute(kAttrModule));
563  if (fileName.find("/") != 0) { // load element has a relative path
564  // build an absolute path with directory of top xml file
565  size_t pos;
566  std::string topDir = "";
567  pos = topPath.find_last_of("/");
568  if (pos != std::string::npos) {
569  topDir = topPath.substr(0, pos+1);
570  }
571  fileName = topDir + fileName;
572  }
573  //std::cout << "loading file " << fileName << std::endl;
574  DOMDocument* subDoc = nullptr;
575  readDOMFromFile(fileName, subDoc);
576  if (subDoc) {
577  appendNodesFromSubDoc(keyElement, subDoc);
578  }
579  }
580  }
581 }
582 
583 
584 void XmlConfigParser::appendNodesFromSubDoc(DOMNode* parentNode, DOMDocument* subDoc)
585 {
586  DOMElement* subDocRootElement = subDoc->getDocumentElement();
587  //std::cout << "root element tag: " << cms::xerces::toString(subDocRootElement->getTagName()) << std::endl;
588  if (XMLString::equals(subDocRootElement->getTagName(), kTagAlgo) || XMLString::equals(subDocRootElement->getTagName(), kTagRunSettings)) {
589  DOMNode* importedNode = doc_->importNode(subDocRootElement, true);
590  parentNode->appendChild(importedNode);
591  }
592 }
593 
594 // the small static look up table below indicates in O(1) time if the symbol is '\n', (ascii code 10) '\t' (code 9), or ' ' (code 32)
596 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, // '\n'
597 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, // '\t'
598 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
599 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, // ' '
600 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
601 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
602 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
603 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
604 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
605 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
606 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
607 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
608 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
609 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
610 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
611 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
612 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
613 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
614 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
615 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
616 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
617 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
618 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
619 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
620 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
621 0, 0, 0, 0, 0, 0};
622 
624 {
625  size_t alphanumBegin = 0, alphanumEnd = strlen(str)-1;
626 
627  while( str[alphanumBegin] && XmlConfigParser_reject_symbols[ unsigned(str[alphanumBegin]) ] ) alphanumBegin++;
628  while( alphanumEnd >= alphanumBegin && XmlConfigParser_reject_symbols[ unsigned(str[alphanumEnd] ) ] ) alphanumEnd--;
629 
630  str[alphanumEnd+1] = '\0';
631  return str + alphanumBegin;
632 }
633 
635 {
636  std::size_t alphanumBegin = str.find_first_not_of("\n\t ");
637  std::size_t alphanumEnd = str.find_last_not_of("\n\t ");
638  if (alphanumBegin != std::string::npos) {
639  if (alphanumEnd != std::string::npos) {
640  str = str.substr(alphanumBegin, alphanumEnd - alphanumBegin + 1);
641  } else {
642  str = str.substr(alphanumBegin);
643  }
644  }
645 }
646 
647 
void addDaq(const char *daq, const char *role, const char *crate)
type
Definition: HCALResponse.h:21
void pruneString(std::string &str)
const XMLCh * kTagMask
const std::string kTypeTable
const XMLCh * kTagAlgo
const XMLCh * kAttrDelim
void readDOMFromFile(const std::string &fName, xercesc::DOMDocument *&doc)
const XMLCh * kTagCrate
const XMLCh * kTagRow
void setSystemId(const char *id) noexcept
Definition: TriggerSystem.h:71
TrainProcessor *const proc
Definition: MVATrainer.cc:101
const XMLCh * kTagExclBoards
const XMLCh * kTagRole
void readElement(const xercesc::DOMElement *element, TriggerSystem &aTriggerSystem, const std::string &sysId="")
#define nullptr
const XMLCh * kTagProcessor
delete x;
Definition: CaloConfig.h:22
const XMLCh * kTagLoad
const char XmlConfigParser_reject_symbols[256]
const XMLCh * kAttrId
const XMLCh * kAttrType
const XMLCh * kTagContext
const XMLCh * kTagParam
void readContext(const xercesc::DOMElement *element, const std::string &sysId, TriggerSystem &aTriggerSystem)
std::string toString(XMLCh const *toTranscode)
const XMLCh * kTagColumns
const XMLCh * kTagKey
void readDOMFromString(const std::string &str, xercesc::DOMDocument *&doc)
void addTable(const char *id, const char *procOrRole, const char *columns, const char *types, const std::vector< std::string > &rows, const char *delim)
void buildGlobalDoc(const std::string &key, const std::string &topPath="")
ZStr< char > cStr(XMLCh const *str)
void appendNodesFromSubDoc(xercesc::DOMNode *parentNode, xercesc::DOMDocument *subDoc)
void addMask(const char *id, const char *procOrRoleOrDaq)
xercesc::DOMDocument * doc_
Definition: value.py:1
def elem(elemtype, innerHTML='', html_class='', kwargs)
Definition: HTMLExport.py:19
int k[5][pyjets_maxn]
std::string systemId(void) const noexcept
Definition: TriggerSystem.h:70
xercesc::DOMElement * getKeyElement(const std::string &key)
bool equals(const edm::RefToBase< Jet > &j1, const edm::RefToBase< Jet > &j2)
const XMLCh * kTagExclude
const XMLCh * kTagDb
const XMLCh * kTagDisable
void readRootElement(TriggerSystem &aTriggerSystem, const std::string &sysId="")
void readContexts(const std::string &key, const std::string &sysId, TriggerSystem &aTriggerSystem)
void addProcessor(const char *processor, const char *role, const char *crate, const char *slot)
const XMLCh * kTagDaqTtc
void addParameter(const char *id, const char *procOrRole, const char *type, const char *value, const char *delim=",")
const XMLCh * kAttrModule
void readHwDescription(const xercesc::DOMElement *element, TriggerSystem &aTriggerSystem, const std::string &sysId="")
#define str(s)
void disableProcOrRoleOrDaq(const char *procOrRoleOrDaq)
const XMLCh * kTagHw
xercesc::XercesDOMParser * parser_
const XMLCh * kTagTypes
const XMLCh * kTagSlot
const XMLCh * kTagRunSettings