CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
14 XERCES_CPP_NAMESPACE_USE
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  XMLPlatformUtils::Initialize();
57 
58  kTagHw = XMLString::transcode("system");
59  kTagAlgo = XMLString::transcode("algo");
60  kTagRunSettings = XMLString::transcode("run-settings");
61  kTagDb = XMLString::transcode("db");
62  kTagKey = XMLString::transcode("key");
63  kTagLoad = XMLString::transcode("load");
64  kTagContext = XMLString::transcode("context");
65  kTagParam = XMLString::transcode("param");
66  kTagMask = XMLString::transcode("mask");
67  kTagDisable = XMLString::transcode("disable");
68  kTagExclBoards = XMLString::transcode("excluded-boards");
69  kTagExclude = XMLString::transcode("exclude");
70  kTagColumns = XMLString::transcode("columns");
71  kTagTypes = XMLString::transcode("types");
72  kTagRow = XMLString::transcode("row");
73  kTagProcessor = XMLString::transcode("processor");
74  kTagRole = XMLString::transcode("role");
75  kTagCrate = XMLString::transcode("crate");
76  kTagSlot = XMLString::transcode("slot");
77  kTagDaqTtc = XMLString::transcode("daqttc-mgr");
78  kAttrId = XMLString::transcode("id");
79  kAttrType = XMLString::transcode("type");
80  kAttrDelim = XMLString::transcode("delimiter");
81  kAttrModule = XMLString::transcode("module");
82 
84  parser_ = new XercesDOMParser();
85  parser_->setValidationScheme(XercesDOMParser::Val_Auto);
86  parser_->setDoNamespaces(false);
87 
88  doc_ = nullptr;
89 }
90 
91 XmlConfigParser::XmlConfigParser(DOMDocument* doc)
92  : kTagHw(nullptr),
93  kTagAlgo(nullptr),
94  kTagRunSettings(nullptr),
95  kTagDb(nullptr),
96  kTagKey(nullptr),
97  kTagLoad(nullptr),
98  kTagContext(nullptr),
99  kTagParam(nullptr),
100  kTagMask(nullptr),
101  kTagDisable(nullptr),
102  kTagExclBoards(nullptr),
103  kTagExclude(nullptr),
104  kTagColumns(nullptr),
105  kTagTypes(nullptr),
106  kTagRow(nullptr),
107  kTagProcessor(nullptr),
108  kTagRole(nullptr),
109  kTagCrate(nullptr),
110  kTagSlot(nullptr),
111  kTagDaqTtc(nullptr),
112  kAttrId(nullptr),
113  kAttrType(nullptr),
114  kAttrDelim(nullptr),
115  kAttrModule(nullptr),
116  kTypeTable("table") {
117  XMLPlatformUtils::Initialize();
118 
119  kTagHw = XMLString::transcode("system");
120  kTagAlgo = XMLString::transcode("algo");
121  kTagRunSettings = XMLString::transcode("run-settings");
122  kTagDb = XMLString::transcode("db");
123  kTagKey = XMLString::transcode("key");
124  kTagLoad = XMLString::transcode("load");
125  kTagContext = XMLString::transcode("context");
126  kTagParam = XMLString::transcode("param");
127  kTagMask = XMLString::transcode("mask");
128  kTagDisable = XMLString::transcode("disable");
129  kTagExclBoards = XMLString::transcode("excluded-boards");
130  kTagExclude = XMLString::transcode("exclude");
131  kTagColumns = XMLString::transcode("columns");
132  kTagTypes = XMLString::transcode("types");
133  kTagRow = XMLString::transcode("row");
134  kTagProcessor = XMLString::transcode("processor");
135  kTagRole = XMLString::transcode("role");
136  kTagCrate = XMLString::transcode("crate");
137  kTagSlot = XMLString::transcode("slot");
138  kTagDaqTtc = XMLString::transcode("daqttc-mgr");
139  kAttrId = XMLString::transcode("id");
140  kAttrType = XMLString::transcode("type");
141  kAttrDelim = XMLString::transcode("delimiter");
142  kAttrModule = XMLString::transcode("module");
143 
144  parser_ = nullptr;
145  doc_ = doc;
146 }
147 
149  delete parser_;
150  XMLPlatformUtils::Terminate();
151 }
152 
153 void XmlConfigParser::readDOMFromString(const std::string& str, DOMDocument*& doc) {
154  MemBufInputSource xmlstr_buf((const XMLByte*)(str.c_str()), str.size(), "xmlstrbuf");
155  parser_->parse(xmlstr_buf);
156  doc = parser_->getDocument();
157  assert(doc);
158 }
159 
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 void XmlConfigParser::readDOMFromFile(const std::string& fName, DOMDocument*& doc) {
168  parser_->parse(fName.c_str());
169  doc = parser_->getDocument();
170 
171  if (!doc) {
172  edm::LogError("XmlConfigParser") << "Could not parse file " << fName << "\n";
173  }
174 
175  assert(doc);
176 }
177 
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 void XmlConfigParser::readRootElement(TriggerSystem& aTriggerSystem, const std::string& sysId) {
190  DOMElement* rootElement = doc_->getDocumentElement();
191  if (rootElement) {
192  if (rootElement->getNodeType() == DOMNode::ELEMENT_NODE) {
193  readElement(rootElement, aTriggerSystem, sysId);
194  }
195  } else {
196  throw std::runtime_error("No xml root element found");
197  }
198 }
199 
200 void XmlConfigParser::readElement(const DOMElement* element, TriggerSystem& aTriggerSystem, const std::string& sysId) {
201  if (XMLString::equals(element->getTagName(), kTagHw)) {
202  // in case this is a HW description
203  readHwDescription(element, aTriggerSystem, sysId);
204  } else if (XMLString::equals(element->getTagName(), kTagAlgo) ||
205  XMLString::equals(element->getTagName(), kTagRunSettings)) {
206  // in case this is a configuration snippet
207  readContext(element, sysId, aTriggerSystem);
208  }
209 }
210 
211 void XmlConfigParser::readHwDescription(const DOMElement* element,
212  TriggerSystem& aTriggerSystem,
213  const std::string& sysId) {
214  // if sysId == "" set the systemId of the trigsystem from the xml sytem id
215  if (!sysId.empty()) {
216  std::string sId = cms::xerces::toString(element->getAttribute(kAttrId));
217  pruneString(sId);
218  if (sId != sysId)
219  return;
220  }
221 
222  char* sysId_ = xercesc::XMLString::transcode(element->getAttribute(kAttrId));
223  aTriggerSystem.setSystemId(pruneString(sysId_));
225 
226  // handle processors
227  DOMNodeList* processors = element->getElementsByTagName(kTagProcessor);
228  XMLSize_t nodeCount = processors->getLength();
229  for (XMLSize_t xx = 0; xx < nodeCount; ++xx) {
230  DOMNode* currentNode = processors->item(xx);
231  if (currentNode->getNodeType() && currentNode->getNodeType() == DOMNode::ELEMENT_NODE) { //no null and is element
232  DOMElement* currentElement = static_cast<DOMElement*>(currentNode);
233 
234  string proc = cms::xerces::toString(currentElement->getAttribute(kAttrId));
235  pruneString(proc);
236  string role, crate, slot;
237 
238  DOMNodeList* roles = currentElement->getElementsByTagName(kTagRole);
239  // roles of this processor (should be only one)
240  if (roles->getLength() != 1)
241  throw std::runtime_error(string("Configutration specify not exactly one role"));
242  // for (XMLSize_t i = 0; i < roles->getLength(); ++i) {
243  {
244  XMLSize_t i = 0;
245  DOMNodeList* roleChilds = roles->item(i)->getChildNodes();
246  if (roleChilds->getLength() != 1)
247  throw std::runtime_error(string("Configutration specify not exactly one role"));
248  {
249  // for (XMLSize_t j = 0; j < roleChilds->getLength(); ++j) {
250  XMLSize_t j = 0;
251  if (roleChilds->item(j)->getNodeType() == DOMNode::TEXT_NODE) {
252  role = cms::xerces::toString(roleChilds->item(j)->getNodeValue());
253  pruneString(role);
254  }
255  }
256  }
257 
258  DOMNodeList* crates = currentElement->getElementsByTagName(kTagCrate);
259  // crates of this processor (should be only one)
260  if (crates->getLength() != 1)
261  throw std::runtime_error(string("Configutration specify not exactly one crate"));
262  // for (XMLSize_t i = 0; i < crates->getLength(); ++i) {
263  {
264  XMLSize_t i = 0;
265  DOMNodeList* crateChilds = crates->item(i)->getChildNodes();
266  if (crateChilds->getLength() != 1)
267  throw std::runtime_error(string("Configutration specify not exactly one crate"));
268  {
269  XMLSize_t j = 0;
270  // for (XMLSize_t j = 0; j < crateChilds->getLength(); ++j) {
271  if (crateChilds->item(j)->getNodeType() == DOMNode::TEXT_NODE) {
272  crate = cms::xerces::toString(crateChilds->item(j)->getNodeValue());
273  pruneString(crate);
274  }
275  }
276  }
277 
278  DOMNodeList* slots = currentElement->getElementsByTagName(kTagSlot);
279  // slots of this processor (should be only one)
280  if (slots->getLength() != 1)
281  throw std::runtime_error(string("Configutration specify not exactly one slot"));
282  // for (XMLSize_t i = 0; i < slots->getLength(); ++i) {
283  {
284  XMLSize_t i = 0;
285  DOMNodeList* slotChilds = slots->item(i)->getChildNodes();
286  if (slotChilds->getLength() != 1)
287  throw std::runtime_error(string("Configutration specify not exactly one slot"));
288  // for (XMLSize_t j = 0; j < slotChilds->getLength(); ++j) {
289  {
290  XMLSize_t j = 0;
291  if (slotChilds->item(j)->getNodeType() == DOMNode::TEXT_NODE) {
292  slot = cms::xerces::toString(slotChilds->item(j)->getNodeValue());
293  pruneString(slot);
294  }
295  }
296  }
297 
298  aTriggerSystem.addProcessor(proc.c_str(), role.c_str(), crate.c_str(), slot.c_str());
299  }
300  }
301 
302  // handle DAQ TTC managers
303  DOMNodeList* daqttcs = element->getElementsByTagName(kTagDaqTtc);
304  nodeCount = daqttcs->getLength();
305  for (XMLSize_t xx = 0; xx < nodeCount; ++xx) {
306  DOMNode* currentNode = daqttcs->item(xx);
307  if (currentNode->getNodeType() && currentNode->getNodeType() == DOMNode::ELEMENT_NODE) { //no null and is element
308  DOMElement* currentElement = static_cast<DOMElement*>(currentNode);
309  string daqttc = cms::xerces::toString(currentElement->getAttribute(kAttrId));
310  string role, crate;
311 
312  DOMNodeList* roles = currentElement->getElementsByTagName(kTagRole);
313  // roles of this DAQ TTC manager (should be only one)
314  if (roles->getLength() != 1)
315  throw std::runtime_error(string("Configutration specify not exactly one role"));
316  // for (XMLSize_t i = 0; i < roles->getLength(); ++i) {
317  {
318  XMLSize_t i = 0;
319  DOMNodeList* roleChilds = roles->item(i)->getChildNodes();
320  if (roleChilds->getLength() != 1)
321  throw std::runtime_error(string("Configutration specify not exactly one role"));
322  // for (XMLSize_t j = 0; j < roleChilds->getLength(); ++j) {
323  {
324  XMLSize_t j = 0;
325  if (roleChilds->item(j)->getNodeType() == DOMNode::TEXT_NODE) {
326  role = cms::xerces::toString(roleChilds->item(j)->getNodeValue());
327  pruneString(role);
328  }
329  }
330  }
331 
332  DOMNodeList* crates = currentElement->getElementsByTagName(kTagCrate);
333  // crates of this DAQ TTC manager (should be only one)
334  if (crates->getLength() != 1)
335  throw std::runtime_error(string("Configutration specify not exactly one crate"));
336  // for (XMLSize_t i = 0; i < crates->getLength(); ++i) {
337  {
338  XMLSize_t i = 0;
339  DOMNodeList* crateChilds = crates->item(i)->getChildNodes();
340  if (crateChilds->getLength() != 1)
341  throw std::runtime_error(string("Configutration specify not exactly one crate"));
342  // for (XMLSize_t j = 0; j < crateChilds->getLength(); ++j) {
343  {
344  XMLSize_t j = 0;
345  if (crateChilds->item(j)->getNodeType() == DOMNode::TEXT_NODE) {
346  crate = cms::xerces::toString(crateChilds->item(j)->getNodeValue());
347  pruneString(crate);
348  }
349  }
350  }
351 
352  aTriggerSystem.addDaq(daqttc.c_str(), role.c_str(), crate.c_str());
353  }
354  }
355 
356  // handle excluded boards
357  DOMNodeList* exclBoards = element->getElementsByTagName(kTagExclBoards);
358  for (XMLSize_t xx = 0; xx < exclBoards->getLength(); ++xx) {
359  DOMElement* exclBoardElem = static_cast<DOMElement*>(exclBoards->item(xx));
360 
361  for (DOMElement* elem = static_cast<DOMElement*>(exclBoardElem->getFirstChild()); elem;
362  elem = static_cast<DOMElement*>(elem->getNextSibling())) {
363  if (elem->getNodeType() == DOMNode::ELEMENT_NODE) {
364  if (XMLString::equals(elem->getTagName(), kTagExclude)) {
365  // found an excluded board
366  std::string id = cms::xerces::toString(elem->getAttribute(kAttrId));
367  pruneString(id);
368  aTriggerSystem.disableProcOrRoleOrDaq(
369  id.c_str()); // handle in the same way as disabled ids in the run-settings
370  }
371  }
372  }
373  }
374 }
375 
376 void XmlConfigParser::readContext(const DOMElement* element, const std::string& sysId, TriggerSystem& aTriggerSystem) {
377  std::string systemId = sysId;
378  if (systemId.empty()) {
379  systemId = aTriggerSystem.systemId();
380  }
381  if (cms::xerces::toString(element->getAttribute(kAttrId)) == systemId) {
382  DOMNodeList* contextElements = element->getElementsByTagName(kTagContext);
383 
384  for (XMLSize_t i = 0; i < contextElements->getLength(); ++i) {
385  DOMElement* contextElement = static_cast<DOMElement*>(contextElements->item(i));
386  std::string contextId = cms::xerces::toString(contextElement->getAttribute(kAttrId));
387  pruneString(contextId);
388 
389  for (DOMElement* elem = static_cast<DOMElement*>(contextElement->getFirstChild()); elem;
390  elem = static_cast<DOMElement*>(elem->getNextSibling())) {
391  if (elem->getNodeType() == DOMNode::ELEMENT_NODE) {
392  if (XMLString::equals(elem->getTagName(), kTagParam)) {
393  // found a parameter
394  string id = cms::xerces::toString(elem->getAttribute(kAttrId));
395  string type = cms::xerces::toString(elem->getAttribute(kAttrType));
396  string delim = cms::xerces::toString(elem->getAttribute(kAttrDelim));
397  pruneString(id);
398  pruneString(type);
399  pruneString(delim);
400 
401  // the type table needs special treatment since it consists of child nodes
402  if (type == kTypeTable) {
403  // get the columns string
404  std::string columnsStr = "";
405  DOMNodeList* colElements = elem->getElementsByTagName(kTagColumns);
406  for (XMLSize_t j = 0; j < colElements->getLength(); ++j) {
407  DOMNodeList* colChilds = colElements->item(j)->getChildNodes();
408  for (XMLSize_t k = 0; k < colChilds->getLength(); ++k) {
409  if (colChilds->item(k)->getNodeType() == DOMNode::TEXT_NODE) {
412  char* cStr = xercesc::XMLString::transcode(colChilds->item(k)->getNodeValue());
413  char *saveptr, first = 1;
414  for (char* item = strtok_r(cStr, delim.c_str(), &saveptr); item != nullptr;
415  item = strtok_r(nullptr, delim.c_str(), &saveptr), first = 0)
416  columnsStr += (first ? std::string("") : delim) + pruneString(item);
418  }
419  }
420  }
421 
422  // get the column type string
423  std::string typesStr = "";
424  DOMNodeList* colTypesElements = elem->getElementsByTagName(kTagTypes);
425  for (XMLSize_t j = 0; j < colTypesElements->getLength(); ++j) {
426  DOMNodeList* colTypesChilds = colTypesElements->item(j)->getChildNodes();
427  for (XMLSize_t k = 0; k < colTypesChilds->getLength(); ++k) {
428  if (colTypesChilds->item(k)->getNodeType() == DOMNode::TEXT_NODE) {
431  char* tStr = xercesc::XMLString::transcode(colTypesChilds->item(k)->getNodeValue());
432  char *saveptr, first = 1;
433  for (char* item = strtok_r(tStr, delim.c_str(), &saveptr); item != nullptr;
434  item = strtok_r(nullptr, delim.c_str(), &saveptr), first = 0)
435  typesStr += (first ? std::string("") : delim) + pruneString(item);
437  }
438  }
439  }
440 
441  // get the rows
442  std::vector<std::string> rowStrs;
443  DOMNodeList* rowElements = elem->getElementsByTagName(kTagRow);
444  for (XMLSize_t j = 0; j < rowElements->getLength(); ++j) {
445  DOMNodeList* rowChilds = rowElements->item(j)->getChildNodes();
446  for (XMLSize_t k = 0; k < rowChilds->getLength(); ++k) {
447  if (rowChilds->item(k)->getNodeType() == DOMNode::TEXT_NODE) {
451  char* rStr = xercesc::XMLString::transcode(rowChilds->item(k)->getNodeValue());
452  char *saveptr, first = 1;
453  std::string row;
454  for (char* item = strtok_r(rStr, delim.c_str(), &saveptr); item != nullptr;
455  item = strtok_r(nullptr, delim.c_str(), &saveptr), first = 0)
456  row += (first ? std::string("") : delim) + pruneString(item);
457 
458  rowStrs.push_back(row);
460  }
461  }
462  }
463  // std::cout << "param element node with id attribute " << id << " and type attribute " << typesStr << std::endl;
464  aTriggerSystem.addTable(
465  id.c_str(), contextId.c_str(), columnsStr.c_str(), typesStr.c_str(), rowStrs, delim.c_str());
466 
467  } else { // all types other than table
468  std::string value = "";
469  DOMNodeList* valNodes = elem->getChildNodes();
470  for (XMLSize_t j = 0; j < valNodes->getLength(); ++j) {
471  if (valNodes->item(j)->getNodeType() == DOMNode::TEXT_NODE) {
472  value += cms::xerces::toString(valNodes->item(j)->getNodeValue()); // should we prune?
473  }
474  }
475 
476  // strip leading and trailing line breaks and spaces
477  pruneString(value);
478 
479  // std::cout << "param element node with id attribute " << id << " and type attribute " << type << " with value: [" << value << "]" << std::endl;
480  aTriggerSystem.addParameter(id.c_str(), contextId.c_str(), type.c_str(), value.c_str(), delim.c_str());
481  }
482 
483  } else if (XMLString::equals(elem->getTagName(), kTagMask)) {
484  // found a Mask
485  std::string id = cms::xerces::toString(elem->getAttribute(kAttrId));
486  //std::cout << "Mask element node with id attribute " << id << std::endl;
487  pruneString(id);
488  aTriggerSystem.addMask(id.c_str(), contextId.c_str());
489 
490  } else if (XMLString::equals(elem->getTagName(), kTagDisable)) {
491  // found a disable
492  std::string id = cms::xerces::toString(elem->getAttribute(kAttrId));
493  pruneString(id);
494  aTriggerSystem.disableProcOrRoleOrDaq(id.c_str());
495  }
496  }
497  }
498  }
499  }
500 }
501 
502 void XmlConfigParser::readContexts(const std::string& key, const std::string& sysId, TriggerSystem& aTriggerSystem) {
503  DOMElement* keyElement = getKeyElement(key);
504  if (keyElement) {
505  for (DOMElement* elem = static_cast<DOMElement*>(keyElement->getFirstChild()); elem;
506  elem = static_cast<DOMElement*>(elem->getNextSibling())) {
507  if (elem->getNodeType() == DOMNode::ELEMENT_NODE) {
508  if (XMLString::equals(elem->getTagName(), kTagAlgo) || XMLString::equals(elem->getTagName(), kTagRunSettings)) {
509  readContext(elem, sysId, aTriggerSystem);
510  }
511  }
512  }
513  } else {
514  throw std::runtime_error("Key not found: " + key);
515  }
516 }
517 
519  DOMElement* rootElement = doc_->getDocumentElement();
520  if (XMLString::equals(rootElement->getTagName(), kTagDb)) {
521  DOMNodeList* keyElements = rootElement->getElementsByTagName(kTagKey);
522 
523  for (XMLSize_t i = 0; i < keyElements->getLength(); ++i) {
524  DOMElement* keyElement = static_cast<DOMElement*>(keyElements->item(i));
525  if (cms::xerces::toString(keyElement->getAttribute(kAttrId)) == key) { // we found the key we were looking for
526  return keyElement;
527  }
528  }
529  }
530  return nullptr;
531 }
532 
534  DOMElement* keyElement = getKeyElement(key);
535  if (keyElement) {
536  DOMNodeList* loadElements = keyElement->getElementsByTagName(kTagLoad);
537  for (XMLSize_t i = 0; i < loadElements->getLength(); ++i) {
538  DOMElement* loadElement = static_cast<DOMElement*>(loadElements->item(i));
539  std::string fileName = cms::xerces::toString(loadElement->getAttribute(kAttrModule));
540  if (fileName.find('/') != 0) { // load element has a relative path
541  // build an absolute path with directory of top xml file
542  size_t pos;
543  std::string topDir = "";
544  pos = topPath.find_last_of('/');
545  if (pos != std::string::npos) {
546  topDir = topPath.substr(0, pos + 1);
547  }
548  fileName = topDir + fileName;
549  }
550  //std::cout << "loading file " << fileName << std::endl;
551  DOMDocument* subDoc = nullptr;
552  readDOMFromFile(fileName, subDoc);
553  if (subDoc) {
554  appendNodesFromSubDoc(keyElement, subDoc);
555  }
556  }
557  }
558 }
559 
560 void XmlConfigParser::appendNodesFromSubDoc(DOMNode* parentNode, DOMDocument* subDoc) {
561  DOMElement* subDocRootElement = subDoc->getDocumentElement();
562  //std::cout << "root element tag: " << cms::xerces::toString(subDocRootElement->getTagName()) << std::endl;
563  if (XMLString::equals(subDocRootElement->getTagName(), kTagAlgo) ||
564  XMLString::equals(subDocRootElement->getTagName(), kTagRunSettings)) {
565  DOMNode* importedNode = doc_->importNode(subDocRootElement, true);
566  parentNode->appendChild(importedNode);
567  }
568 }
569 
570 // 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)
572  0, 0, 0, 0, 0, 0, 0, 0, 0, 1, // '\n'
573  1, 0, 0, 0, 0, 0, 0, 0, 0, 0, // '\t'
574  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, // ' '
575  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
576  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
577  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
578  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
579  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
580  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
581 
582 char* XmlConfigParser::pruneString(char*& str) {
583  size_t alphanumBegin = 0, alphanumEnd = strlen(str) - 1;
584 
585  while (str[alphanumBegin] && XmlConfigParser_reject_symbols[unsigned(str[alphanumBegin])])
586  alphanumBegin++;
587  while (alphanumEnd >= alphanumBegin && XmlConfigParser_reject_symbols[unsigned(str[alphanumEnd])])
588  alphanumEnd--;
589 
590  str[alphanumEnd + 1] = '\0';
591  return str + alphanumBegin;
592 }
593 
595  std::size_t alphanumBegin = str.find_first_not_of("\n\t ");
596  std::size_t alphanumEnd = str.find_last_not_of("\n\t ");
597  if (alphanumBegin != std::string::npos) {
598  if (alphanumEnd != std::string::npos) {
599  str = str.substr(alphanumBegin, alphanumEnd - alphanumBegin + 1);
600  } else {
601  str = str.substr(alphanumBegin);
602  }
603  }
604 }
void addDaq(const char *daq, const char *role, const char *crate)
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:72
const XMLCh * kTagExclBoards
const XMLCh * kTagRole
void readElement(const xercesc::DOMElement *element, TriggerSystem &aTriggerSystem, const std::string &sysId="")
const XMLCh * kTagProcessor
const XMLCh * kTagLoad
Log< level::Error, false > LogError
const char XmlConfigParser_reject_symbols[256]
assert(be >=bs)
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)
tuple key
prepare the HTCondor submission files and eventually submit them
void appendNodesFromSubDoc(xercesc::DOMNode *parentNode, xercesc::DOMDocument *subDoc)
void addMask(const char *id, const char *procOrRoleOrDaq)
xercesc::DOMDocument * doc_
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)
std::string systemId(void) const noexcept
Definition: TriggerSystem.h:71
void disableProcOrRoleOrDaq(const char *procOrRoleOrDaq)
const XMLCh * kTagHw
xercesc::XercesDOMParser * parser_
const XMLCh * kTagTypes
const XMLCh * kTagSlot
const XMLCh * kTagRunSettings