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