Fawkes API  Fawkes Development Version
parser.cpp
1 
2 /***************************************************************************
3  * parser.cpp - Interface config parser
4  *
5  * Created: Tue Oct 10 17:41:13 2006
6  * Copyright 2006-2015 Tim Niemueller [www.niemueller.de]
7  ****************************************************************************/
8 
9 /* This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU Library General Public License for more details.
18  *
19  * Read the full text in the LICENSE.GPL file in the doc directory.
20  */
21 
22 #include "parser.h"
23 
24 #include "checker.h"
25 #include "exceptions.h"
26 
27 #include <interface/interface.h>
28 #include <libxml++/libxml++.h>
29 #include <utils/misc/string_conversions.h>
30 
31 #include <iostream>
32 #include <vector>
33 
34 using namespace std;
35 using namespace xmlpp;
36 
37 /** @class InterfaceParser interfaces/generator/parser.h
38  * Parser used to get information out of interface template. Uses
39  * XML parser internally.
40  */
41 
42 /** Constructor
43  * @param config_filename file name of config (interface template)
44  */
45 InterfaceParser::InterfaceParser(std::string config_filename)
46 {
47  dom = new DomParser();
48  //dom->set_validate();
49  dom->set_substitute_entities();
50  dom->parse_file(config_filename);
51  root = dom->get_document()->get_root_node();
52  if (root == NULL) {
53  throw InterfaceGeneratorInvalidDocumentException("root == NULL");
54  }
55 }
56 
57 /** Destructor. */
59 {
60  delete dom;
61 }
62 
63 /** Get parsed fields.
64  * Get fields stored below the given node.
65  * @param node root node where to start searching
66  * @param reserved_names reserved names which may not be used as identifiers
67  * @return vector of field representations.
68  */
69 std::vector<InterfaceField>
70 InterfaceParser::getFields(xmlpp::Node *node, const std::set<std::string> &reserved_names)
71 {
72  vector<InterfaceField> result;
73  NodeSet set = node->find("field");
74  for (NodeSet::iterator i = set.begin(); i != set.end(); ++i) {
75  InterfaceField f(&enum_constants);
76 
77  const Element *el = dynamic_cast<const Element *>(*i);
78  if (el) {
79  // valid element
80  const Element::AttributeList &attrs = el->get_attributes();
81  for (Element::AttributeList::const_iterator iter = attrs.begin(); iter != attrs.end();
82  ++iter) {
83  const Attribute *attr = *iter;
84  //std::cout << " Attribute " << attr->get_name() << " = " << attr->get_value() << std::endl;
85  f.setAttribute(attr->get_name(), attr->get_value());
86  }
87  } else {
88  throw InterfaceGeneratorInvalidContentException("constant is not an element");
89  }
90 
91  // Get field comment
92  NodeSet nameset = (*i)->find("text()");
93  if (nameset.size() == 0) {
94  throw InterfaceGeneratorInvalidContentException("no comment for field %s",
95  f.getName().c_str());
96  }
97  const TextNode *comment_node = dynamic_cast<const TextNode *>(nameset[0]);
98  if (!comment_node) {
99  throw InterfaceGeneratorInvalidContentException("comment node not text node for constant");
100  }
101  f.setComment(comment_node->get_content());
102 
103  //std::cout << "Field name: " << field_name << std::endl;
104  f.valid(reserved_names);
105  result.push_back(f);
106  }
107  for (vector<InterfaceField>::iterator i = result.begin(); i != result.end(); ++i) {
108  for (vector<InterfaceField>::iterator j = i + 1; j != result.end(); ++j) {
109  if ((*i).getName() == (*j).getName()) {
110  throw InterfaceGeneratorAmbiguousNameException((*i).getName().c_str(), "field");
111  }
112  }
113  }
114 
115  return result;
116 }
117 
118 /** Get parsed pseudo maps.
119  * Get pseudo maps stored below the given node.
120  * @param node root node where to start searching
121  * @param fields vector of parsed fields, used to detect name clashes
122  * @return vector of pseudo map representations.
123  */
124 std::vector<InterfacePseudoMap>
125 InterfaceParser::getPseudoMaps(xmlpp::Node *node, std::vector<InterfaceField> &fields)
126 {
127  vector<InterfacePseudoMap> result;
128  NodeSet set = node->find("pseudomap");
129  for (NodeSet::iterator i = set.begin(); i != set.end(); ++i) {
130  const Element *el = dynamic_cast<const Element *>(*i);
131  std::string pm_name, pm_type, pm_keytype;
132 
133  if (el) {
134  Attribute *attr;
135  attr = el->get_attribute("name");
136  if (!attr)
137  throw InterfaceGeneratorInvalidContentException("no name for pseudo map");
138  pm_name = attr->get_value();
139 
140  attr = el->get_attribute("type");
141  if (!attr)
142  throw InterfaceGeneratorInvalidContentException("no type for pseudo map");
143  pm_type = attr->get_value();
144 
145  attr = el->get_attribute("keytype");
146  if (!attr)
147  throw InterfaceGeneratorInvalidContentException("no key type for pseudo map");
148  pm_keytype = attr->get_value();
149  } else {
150  throw InterfaceGeneratorInvalidContentException("pseudo map is not an element");
151  }
152 
153  NodeSet comment_set = (*i)->find("text()");
154  if (comment_set.size() == 0) {
155  throw InterfaceGeneratorInvalidContentException("pseudo map without comment");
156  }
157  std::string pm_comment = "";
158  const TextNode *comment_node = dynamic_cast<const TextNode *>(comment_set[0]);
159  if (comment_node) {
160  pm_comment = comment_node->get_content();
161  } else {
162  throw InterfaceGeneratorInvalidContentException("pseudo map comment not a text node");
163  }
164 
165  InterfacePseudoMap pm(pm_name, pm_type, pm_keytype, pm_comment);
166 
167  NodeSet ref_nodes = (*i)->find("mapref");
168  for (NodeSet::iterator r = ref_nodes.begin(); r != ref_nodes.end(); ++r) {
169  NodeSet ref_set = (*r)->find("text()");
170  if (ref_set.size() == 0) {
171  throw InterfaceGeneratorInvalidContentException("pseudo map without referenced field");
172  }
173 
174  const Element *el = dynamic_cast<const Element *>(*r);
175  Attribute * attr;
176  attr = el->get_attribute("key");
177  if (!attr)
178  throw InterfaceGeneratorInvalidContentException("no key for mapref map");
179  std::string mapref_key = attr->get_value();
180 
181  const TextNode *text_node = dynamic_cast<const TextNode *>(ref_set[0]);
182  if (text_node) {
183  // find field in data fields
184  bool found = false;
185  for (vector<InterfaceField>::iterator j = fields.begin(); j != fields.end(); ++j) {
186  if ((*j).getName() == text_node->get_content()) {
187  // field found
188  if (j->getLengthValue() > 0) {
190  "pseudomap references may only point to non-map types");
191  }
192  pm.addRef(text_node->get_content(), mapref_key);
193  found = true;
194  break;
195  }
196  }
197  if (!found) {
198  throw InterfaceGeneratorInvalidContentException("reference to non-existing data field");
199  }
200 
201  } else {
202  throw InterfaceGeneratorInvalidContentException("message ref not a text node");
203  }
204  }
205 
206  try {
207  pm.valid();
208  result.push_back(pm);
209  } catch (fawkes::Exception &e) {
210  e.print_trace();
211  }
212  }
213  for (vector<InterfacePseudoMap>::iterator i = result.begin(); i != result.end(); ++i) {
214  for (vector<InterfacePseudoMap>::iterator j = i + 1; j != result.end(); ++j) {
215  if ((*i).getName() == (*j).getName()) {
216  throw InterfaceGeneratorAmbiguousNameException((*i).getName().c_str(), "field");
217  }
218  }
219  for (vector<InterfaceField>::iterator f = fields.begin(); f != fields.end(); ++f) {
220  if (i->getName() == f->getName()) {
221  throw InterfaceGeneratorAmbiguousNameException((*i).getName().c_str(), "pseudo map");
222  }
223  }
224  }
225 
226  return result;
227 }
228 
229 /** Print fields.
230  * Print fields to stdout.
231  * @param fields fields to print
232  */
233 void
234 InterfaceParser::printFields(vector<InterfaceField> &fields)
235 {
236  for (vector<InterfaceField>::iterator i = fields.begin(); i != fields.end(); ++i) {
237  cout << " Field: name=" << (*i).getName() << " type=" << (*i).getType();
238  if ((*i).getLength() != "") {
239  cout << " length=" << (*i).getLength();
240  }
241  if ((*i).getValidFor() != "") {
242  cout << " validfor=" << (*i).getValidFor();
243  }
244  if ((*i).getDefaultValue() != "") {
245  cout << " default=" << (*i).getDefaultValue();
246  }
247  vector<string> flags = (*i).getFlags();
248  if (flags.size() > 0) {
249  cout << " flags=";
250  vector<string>::iterator j = flags.begin();
251  while (j != flags.end()) {
252  cout << *j;
253  ++j;
254  if (j != flags.end()) {
255  cout << ",";
256  }
257  }
258  }
259  cout << endl;
260  }
261 }
262 
263 /** Print pseudo maps.
264  * @param pseudo_maps pseudo maps to print
265  */
266 void
267 InterfaceParser::printPseudoMaps(vector<InterfacePseudoMap> &pseudo_maps)
268 {
269  for (vector<InterfacePseudoMap>::iterator i = pseudo_maps.begin(); i != pseudo_maps.end(); ++i) {
270  cout << " PseudoMap: name=" << i->getName() << " type=" << i->getType()
271  << " keytype=" << i->getKeyType() << endl;
272  InterfacePseudoMap::RefList &reflist = i->getRefList();
273 
274  InterfacePseudoMap::RefList::iterator j;
275  for (j = reflist.begin(); j != reflist.end(); ++j) {
276  cout << " Ref: field=" << j->first << " key=" << j->second << endl;
277  }
278 
279  cout << endl;
280  }
281 }
282 
283 /** Print parsed config.
284  * @param constants parsed constants
285  * @param enum_constants parsed enum_constants
286  * @param data_fields parsed data fields
287  * @param pseudo_maps pseudo maps
288  * @param messages parsed messages.
289  */
290 void
291 InterfaceParser::printParsed(vector<InterfaceConstant> & constants,
292  vector<InterfaceEnumConstant> &enum_constants,
293  vector<InterfaceField> & data_fields,
294  vector<InterfacePseudoMap> & pseudo_maps,
295  vector<InterfaceMessage> & messages)
296 {
297  cout << "Constants" << endl;
298  for (vector<InterfaceConstant>::iterator i = constants.begin(); i != constants.end(); ++i) {
299  cout << " Constant: name=" << (*i).getName() << " type=" << (*i).getType()
300  << " value=" << (*i).getValue() << endl;
301  }
302 
303  cout << "EnumConstants" << endl;
304  for (vector<InterfaceEnumConstant>::iterator i = enum_constants.begin();
305  i != enum_constants.end();
306  ++i) {
307  cout << " EnumConstant: name=" << (*i).get_name() << endl;
308  vector<InterfaceEnumConstant::EnumItem> items = (*i).get_items();
309  vector<InterfaceEnumConstant::EnumItem>::iterator j;
310  for (j = items.begin(); j != items.end(); ++j) {
311  cout << " Item: " << j->name << "(" << j->comment << ")" << endl;
312  }
313  }
314 
315  cout << "Data block" << endl;
316  printFields(data_fields);
317  printPseudoMaps(pseudo_maps);
318  for (vector<InterfaceMessage>::iterator i = messages.begin(); i != messages.end(); ++i) {
319  cout << "Message: name=" << (*i).getName() << endl;
320  vector<InterfaceField> msg_fields = (*i).getFields();
321  printFields(msg_fields);
322  }
323 }
324 
325 /** Print parsed data. */
326 void
328 {
329  printParsed(constants, enum_constants, data_fields, pseudo_maps, messages);
330 }
331 
332 /** Parse config. */
333 void
335 {
336  NodeSet set;
337 
338  constants.clear();
339  enum_constants.clear();
340  data_fields.clear();
341  messages.clear();
342 
343  /*
344  * Name and author
345  *
346  */
347  const Element *el = dynamic_cast<const Element *>(root);
348  if (el) {
349  // valid element
350  Attribute *attr;
351  attr = el->get_attribute("name");
352  if (!attr) {
353  throw InterfaceGeneratorInvalidContentException("no name for interface");
354  }
355  name = attr->get_value();
356  if (name.length() > INTERFACE_TYPE_SIZE_) {
357  throw InterfaceGeneratorInvalidContentException("Interface name too long, max length is %u",
358  INTERFACE_TYPE_SIZE_);
359  }
360 
361  attr = el->get_attribute("author");
362  if (attr) {
363  author = attr->get_value();
364  }
365  attr = el->get_attribute("year");
366  if (attr) {
367  year = attr->get_value();
368  }
369  attr = el->get_attribute("created");
370  if (attr) {
371  creation_date = attr->get_value();
372  }
373  } else {
374  throw InterfaceGeneratorInvalidContentException("root is not an element");
375  }
376 
377  /*
378  * constants
379  *
380  */
381  NodeSet constants_set = root->find("/interface/constants");
382  if (constants_set.size() > 1) {
383  throw InterfaceGeneratorInvalidContentException("more than one constants block");
384  }
385  if (constants_set.size() == 1) {
386  // there are actually constants
387  set = constants_set[0]->find("constant");
388  for (NodeSet::iterator i = set.begin(); i != set.end(); ++i) {
389  // Get constant name
390  NodeSet nameset = (*i)->find("text()");
391  if (nameset.size() == 0) {
392  throw InterfaceGeneratorInvalidContentException("no name for constant");
393  }
394  const TextNode *comment_node = dynamic_cast<const TextNode *>(nameset[0]);
395  if (!comment_node) {
396  throw InterfaceGeneratorInvalidContentException("name node not text node for constant");
397  }
398  std::string const_comment = comment_node->get_content();
399  //std::cout << "Constant name: " << const_name << std::endl;
400 
401  // Get attributes
402  std::string type;
403  std::string value;
404  std::string const_name;
405 
406  el = dynamic_cast<const Element *>(*i);
407  if (el) {
408  // valid element
409  Attribute *attr;
410  attr = el->get_attribute("type");
411  if (!attr) {
412  throw InterfaceGeneratorInvalidContentException("no type for constant");
413  }
414  type = attr->get_value();
415 
416  attr = el->get_attribute("name");
417  if (!attr) {
418  throw InterfaceGeneratorInvalidContentException("no name for constant");
419  }
420  const_name = attr->get_value();
421 
422  attr = el->get_attribute("value");
423  if (!attr) {
424  throw InterfaceGeneratorInvalidContentException("no value for constant");
425  }
426  value = attr->get_value();
427  } else {
428  throw InterfaceGeneratorInvalidContentException("constant is not an element");
429  }
430 
431  // Generate constant object
432  try {
433  InterfaceConstant constant(const_name, type, value, const_comment);
434  constants.push_back(constant);
436  e.print_trace();
438  e.print_trace();
439  }
440  }
441  for (vector<InterfaceConstant>::iterator i = constants.begin(); i != constants.end(); ++i) {
442  for (vector<InterfaceConstant>::iterator j = i + 1; j != constants.end(); ++j) {
443  if ((*i).getName() == (*j).getName()) {
444  throw InterfaceGeneratorAmbiguousNameException((*i).getName().c_str(), "constant");
445  }
446  }
447  }
448 
449  /*
450  * enums
451  *
452  */
453  set = constants_set[0]->find("enum");
454  for (NodeSet::iterator i = set.begin(); i != set.end(); ++i) {
455  std::string enum_comment;
456  NodeSet comment_set = (*i)->find("comment/text()");
457  if (comment_set.size() == 0) {
458  throw InterfaceGeneratorInvalidContentException("no comment for enum");
459  } else {
460  const TextNode *comment_node = dynamic_cast<const TextNode *>(comment_set[0]);
461  if (comment_node) {
462  enum_comment = comment_node->get_content();
463  } else {
464  throw InterfaceGeneratorInvalidContentException("enum comment not a text node");
465  }
466  }
467 
468  string enum_name;
469  el = dynamic_cast<const Element *>(*i);
470  if (el) {
471  // valid element
472  Attribute *attr;
473  attr = el->get_attribute("name");
474  if (!attr) {
475  throw InterfaceGeneratorInvalidContentException("no name for enum");
476  }
477  enum_name = attr->get_value();
478 
479  } else {
480  throw InterfaceGeneratorInvalidContentException("enum is not an element");
481  }
482 
483  InterfaceEnumConstant enum_constant(enum_name, enum_comment);
484 
485  // Get constant name
486  NodeSet items = (*i)->find("item");
487  if (items.size() == 0) {
488  throw InterfaceGeneratorInvalidContentException("no items for enum");
489  }
490 
491  for (NodeSet::iterator j = items.begin(); j != items.end(); ++j) {
492  std::string item_name;
493  std::string item_value;
494  el = dynamic_cast<const Element *>(*j);
495  if (el) {
496  // valid element
497  Attribute *attr;
498  attr = el->get_attribute("name");
499  if (!attr) {
500  throw InterfaceGeneratorInvalidContentException("no name for enum item");
501  }
502  item_name = attr->get_value();
503 
504  Attribute *val_attr;
505  val_attr = el->get_attribute("value");
506  if (val_attr) {
507  item_value = val_attr->get_value();
508  }
509 
510  } else {
511  throw InterfaceGeneratorInvalidContentException("enum item is not an element");
512  }
513 
514  comment_set = (*j)->find("text()");
515  if (comment_set.size() == 0) {
516  throw InterfaceGeneratorInvalidContentException("enum item without comment");
517  }
518  const TextNode *comment_node = dynamic_cast<const TextNode *>(comment_set[0]);
519  if (comment_node) {
520  if (item_value != "") {
521  enum_constant.add_item(item_name,
522  comment_node->get_content(),
524  } else {
525  enum_constant.add_item(item_name, comment_node->get_content());
526  }
527  } else {
528  throw InterfaceGeneratorInvalidContentException("enum comment not a text node");
529  }
530  }
531 
532  enum_constants.push_back(enum_constant);
533  }
534  vector<InterfaceEnumConstant>::iterator i;
535  for (i = enum_constants.begin(); i != enum_constants.end(); ++i) {
536  vector<InterfaceEnumConstant>::iterator j;
537  for (j = i + 1; j != enum_constants.end(); ++j) {
538  if (i->get_name() == j->get_name()) {
539  throw InterfaceGeneratorAmbiguousNameException((*i).get_name().c_str(), "enum constant");
540  }
541  }
542  }
543  }
544 
545  /*
546  * data
547  *
548  */
549  set = root->find("/interface/data");
550  if (set.size() > 1) {
551  throw InterfaceGeneratorInvalidContentException("more than one data block");
552  } else if (set.size() == 0) {
553  throw InterfaceGeneratorInvalidContentException("no data block");
554  }
555 
556  data_fields = getFields(set[0], reserved_names_interface());
557  if (data_fields.size() == 0) {
558  throw InterfaceGeneratorInvalidContentException("data block contains no field");
559  }
560 
561  pseudo_maps = getPseudoMaps(set[0], data_fields);
562 
563  NodeSet comment_set = root->find("/interface/data/comment/text()");
564  if (comment_set.size() == 0) {
565  throw InterfaceGeneratorInvalidContentException("data block without comment");
566  }
567  const TextNode *comment_node = dynamic_cast<const TextNode *>(comment_set[0]);
568  if (comment_node) {
569  data_comment = comment_node->get_content();
570  } else {
571  throw InterfaceGeneratorInvalidContentException("data block comment not a text node");
572  }
573 
574  /*
575  * Messages
576  *
577  */
578  set = root->find("/interface/message");
579  for (NodeSet::iterator i = set.begin(); i != set.end(); ++i) {
580  std::string msg_name;
581  std::string msg_comment;
582 
583  el = dynamic_cast<const Element *>(*i);
584  if (el) {
585  Attribute *attr;
586  attr = el->get_attribute("name");
587  if (!attr) {
588  throw InterfaceGeneratorInvalidContentException("no name for message");
589  }
590  msg_name = attr->get_value();
591  } else {
592  throw InterfaceGeneratorInvalidContentException("message is not an element");
593  }
594 
595  comment_set = (*i)->find("text()");
596  if (comment_set.size() == 0) {
597  throw InterfaceGeneratorInvalidContentException("message without comment");
598  }
599  comment_node = dynamic_cast<const TextNode *>(comment_set[0]);
600  if (comment_node) {
601  msg_comment = comment_node->get_content();
602  } else {
603  throw InterfaceGeneratorInvalidContentException("message comment not a text node");
604  }
605 
606  vector<InterfaceField> msg_fields = getFields(*i, reserved_names_message());
607 
608  NodeSet ref_nodes = (*i)->find("ref/text()");
609  for (NodeSet::iterator r = ref_nodes.begin(); r != ref_nodes.end(); ++r) {
610  const TextNode *text_node = dynamic_cast<const TextNode *>(*r);
611  if (text_node) {
612  // find field in data fields
613  bool found = false;
614  for (vector<InterfaceField>::iterator j = data_fields.begin(); j != data_fields.end();
615  ++j) {
616  if ((*j).getName() == text_node->get_content()) {
617  // field found
618  msg_fields.push_back(*j);
619  found = true;
620  break;
621  }
622  }
623  if (!found) {
624  throw InterfaceGeneratorInvalidContentException("reference to non-existing data field");
625  }
626  } else {
627  throw InterfaceGeneratorInvalidContentException("message ref not a text node");
628  }
629  }
630  for (vector<InterfaceField>::iterator k = msg_fields.begin(); k != msg_fields.end(); ++k) {
631  for (vector<InterfaceField>::iterator j = k + 1; j != msg_fields.end(); ++j) {
632  if ((*k).getName() == (*j).getName()) {
633  throw InterfaceGeneratorAmbiguousNameException((*k).getName().c_str(), "message field");
634  }
635  }
636  }
637 
638  InterfaceMessage msg(msg_name, msg_comment);
639  msg.setFields(msg_fields);
640 
641  messages.push_back(msg);
642  }
643 }
644 
645 /** Get interface name.
646  * Only valid after parse().
647  * @return interface name.
648  */
649 std::string
651 {
652  return name;
653 }
654 
655 /** Get interface author.
656  * Only valid after parse().
657  * @return interface author.
658  */
659 std::string
661 {
662  return author;
663 }
664 
665 /** Get interface copyright year.
666  * Only valid after parse().
667  * @return interface copyright year
668  */
669 std::string
671 {
672  return year;
673 }
674 
675 /** Get interface creation date as string
676  * Only valid after parse().
677  * @return interface creation date
678  */
679 std::string
681 {
682  return creation_date;
683 }
684 
685 /** Get constants.
686  * Only valid after parse().
687  * @return constants.
688  */
689 std::vector<InterfaceConstant>
691 {
692  return constants;
693 }
694 
695 /** Get enum constants.
696  * Only valid after parse().
697  * @return enum constants.
698  */
699 std::vector<InterfaceEnumConstant>
701 {
702  return enum_constants;
703 }
704 
705 /** Get data fields.
706  * Only valid after parse().
707  * @return data fields.
708  */
709 std::vector<InterfaceField>
711 {
712  return data_fields;
713 }
714 
715 /** Get data pseudo maps.
716  * Only valid after parse().
717  * @return pseudo maps
718  */
719 std::vector<InterfacePseudoMap>
721 {
722  return pseudo_maps;
723 }
724 
725 /** Get data comment.
726  * Only valid after parse().
727  * @return data comment.
728  */
729 std::string
731 {
732  return data_comment;
733 }
734 
735 /** Get messages.
736  * Only valid after parse().
737  * @return messages.
738  */
739 std::vector<InterfaceMessage>
741 {
742  return messages;
743 }
InterfaceParser(std::string config_filename)
Constructor.
Definition: parser.cpp:45
void setFields(const std::vector< InterfaceField > &fields)
Set fields of message.
Definition: message.cpp:68
Thrown if document contains illegal content.
Definition: exceptions.h:52
Interface generator internal representation of a constant as parsed from the XML template file.
Definition: constant.h:28
void printParsed(std::vector< InterfaceConstant > &constants, std::vector< InterfaceEnumConstant > &enum_constants, std::vector< InterfaceField > &data_fields, std::vector< InterfacePseudoMap > &pseudo_maps, std::vector< InterfaceMessage > &messages)
Print parsed config.
Definition: parser.cpp:291
void parse()
Parse config.
Definition: parser.cpp:334
Interface generator internal representation of a enum constant as parsed from the XML template file.
Definition: enum_constant.h:30
void printPseudoMaps(std::vector< InterfacePseudoMap > &pseudo_maps)
Print pseudo maps.
Definition: parser.cpp:267
std::vector< InterfaceField > getFields(xmlpp::Node *node, const std::set< std::string > &reserved_names)
Get parsed fields.
Definition: parser.cpp:70
void printFields(std::vector< InterfaceField > &fields)
Print fields.
Definition: parser.cpp:234
std::string getName() const
Get name of field.
Definition: field.cpp:50
Interface generator internal representation of a field as parsed from the XML template file.
Definition: field.h:32
void print()
Print parsed data.
Definition: parser.cpp:327
Interface generator internal representation of a message as parsed from the XML template file.
Definition: message.h:31
static int to_int(std::string s)
Convert string to an int value.
Thrown if illegal value is supplied.
Definition: exceptions.h:90
std::vector< InterfacePseudoMap > getPseudoMaps()
Get data pseudo maps.
Definition: parser.cpp:720
~InterfaceParser()
Destructor.
Definition: parser.cpp:58
std::string getInterfaceAuthor()
Get interface author.
Definition: parser.cpp:660
std::string getDataComment()
Get data comment.
Definition: parser.cpp:730
Base class for exceptions in Fawkes.
Definition: exception.h:35
std::list< std::pair< std::string, std::string > > RefList
Reference list.
Definition: pseudomap.h:35
Thrown if name is ambiguous.
Definition: exceptions.h:158
void setComment(const std::string &comment)
Set comment of field.
Definition: field.cpp:257
std::vector< InterfaceMessage > getMessages()
Get messages.
Definition: parser.cpp:740
std::vector< InterfaceField > getDataFields()
Get data fields.
Definition: parser.cpp:710
Interface generator internal representation of a pseudo map as parsed from the XML template file.
Definition: pseudomap.h:31
void valid(const std::set< std::string > &reserved_names)
Assert validity.
Definition: field.cpp:357
std::string getInterfaceCreationDate()
Get interface creation date as string Only valid after parse().
Definition: parser.cpp:680
void print_trace()
Prints trace to stderr.
Definition: exception.cpp:601
void addRef(std::string fieldname, std::string key)
Add reference.
Definition: pseudomap.cpp:127
std::string getInterfaceName()
Get interface name.
Definition: parser.cpp:650
Thrown if document was invalid.
Definition: exceptions.h:32
std::vector< InterfaceEnumConstant > getEnumConstants()
Get enum constants.
Definition: parser.cpp:700
void valid()
Assert validity.
Definition: pseudomap.cpp:98
std::string getInterfaceYear()
Get interface copyright year.
Definition: parser.cpp:670
void add_item(std::string name, std::string comment)
Add an item without custom value.
std::vector< InterfaceConstant > getConstants()
Get constants.
Definition: parser.cpp:690
void setAttribute(const std::string &attr_name, const std::string &attr_value)
Set attribute.
Definition: field.cpp:329
Thrown if illegal type is supplied.
Definition: exceptions.h:72