Fawkes API  Fawkes Development Version
parser.cpp
1 
2 /***************************************************************************
3  * parser.cpp - Interface config parser
4  *
5  * Generated: Tue Oct 10 17:41:13 2006
6  * Copyright 2006 Tim Niemueller [www.niemueller.de]
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Library General Public License for more details.
19  *
20  * Read the full text in the LICENSE.GPL file in the doc directory.
21  */
22 
23 #include "parser.h"
24 #include "exceptions.h"
25 
26 #include <utils/misc/string_conversions.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 
362  attr = el->get_attribute("author");
363  if ( attr ) {
364  author = attr->get_value();
365  }
366  attr = el->get_attribute("year");
367  if ( attr ) {
368  year = attr->get_value();
369  }
370  attr = el->get_attribute("created");
371  if ( attr ) {
372  creation_date = attr->get_value();
373  }
374  } else {
375  throw InterfaceGeneratorInvalidContentException("root is not an element");
376  }
377 
378  /*
379  * constants
380  *
381  */
382  NodeSet constants_set = root->find("/interface/constants");
383  if ( constants_set.size() > 1 ) {
384  throw InterfaceGeneratorInvalidContentException("more than one constants block");
385  }
386  if ( constants_set.size() == 1 ) {
387  // there are actually constants
388  set = constants_set[0]->find("constant");
389  for (NodeSet::iterator i = set.begin(); i != set.end(); ++i) {
390 
391  // Get constant name
392  NodeSet nameset = (*i)->find("text()");
393  if ( nameset.size() == 0 ) {
394  throw InterfaceGeneratorInvalidContentException("no name for constant");
395  }
396  const TextNode *comment_node = dynamic_cast<const TextNode *>(nameset[0]);
397  if ( ! comment_node ) {
398  throw InterfaceGeneratorInvalidContentException("name node not text node for constant");
399  }
400  std::string const_comment = comment_node->get_content();
401  //std::cout << "Constant name: " << const_name << std::endl;
402 
403  // Get attributes
404  std::string type;
405  std::string value;
406  std::string const_name;
407 
408  el = dynamic_cast<const Element *>(*i);
409  if ( el ) {
410  // valid element
411  Attribute *attr;
412  attr = el->get_attribute("type");
413  if ( ! attr ) {
414  throw InterfaceGeneratorInvalidContentException("no type for constant");
415  }
416  type = attr->get_value();
417 
418  attr = el->get_attribute("name");
419  if ( ! attr ) {
420  throw InterfaceGeneratorInvalidContentException("no name for constant");
421  }
422  const_name = attr->get_value();
423 
424  attr = el->get_attribute("value");
425  if ( ! attr ) {
426  throw InterfaceGeneratorInvalidContentException("no value for constant");
427  }
428  value = attr->get_value();
429  } else {
430  throw InterfaceGeneratorInvalidContentException("constant is not an element");
431  }
432 
433  // Generate constant object
434  try {
435  InterfaceConstant constant(const_name, type, value, const_comment);
436  constants.push_back(constant);
438  e.print_trace();
440  e.print_trace();
441  }
442  }
443  for (vector<InterfaceConstant>::iterator i = constants.begin(); i != constants.end(); ++i) {
444  for (vector<InterfaceConstant>::iterator j = i + 1; j != constants.end(); ++j) {
445  if ( (*i).getName() == (*j).getName() ) {
446  throw InterfaceGeneratorAmbiguousNameException((*i).getName().c_str(), "constant");
447  }
448  }
449  }
450 
451  /*
452  * enums
453  *
454  */
455  set = constants_set[0]->find("enum");
456  for (NodeSet::iterator i = set.begin(); i != set.end(); ++i) {
457 
458  std::string enum_comment;
459  NodeSet comment_set = (*i)->find("comment/text()");
460  if ( comment_set.size() == 0 ) {
461  throw InterfaceGeneratorInvalidContentException("no comment for enum");
462  } else {
463  const TextNode *comment_node = dynamic_cast<const TextNode *>(comment_set[0]);
464  if ( comment_node ) {
465  enum_comment = comment_node->get_content();
466  } else {
467  throw InterfaceGeneratorInvalidContentException("enum comment not a text node");
468  }
469  }
470 
471  string enum_name;
472  el = dynamic_cast<const Element *>(*i);
473  if ( el ) {
474  // valid element
475  Attribute *attr;
476  attr = el->get_attribute("name");
477  if ( ! attr ) {
478  throw InterfaceGeneratorInvalidContentException("no name for enum");
479  }
480  enum_name = attr->get_value();
481 
482  } else {
483  throw InterfaceGeneratorInvalidContentException("enum is not an element");
484  }
485 
486  InterfaceEnumConstant enum_constant(enum_name, enum_comment);
487 
488  // Get constant name
489  NodeSet items = (*i)->find("item");
490  if ( items.size() == 0 ) {
491  throw InterfaceGeneratorInvalidContentException("no items for enum");
492  }
493 
494  for (NodeSet::iterator j = items.begin(); j != items.end(); ++j) {
495 
496  std::string item_name;
497  std::string item_value;
498  el = dynamic_cast<const Element *>(*j);
499  if ( el ) {
500  // valid element
501  Attribute *attr;
502  attr = el->get_attribute("name");
503  if ( ! attr ) {
504  throw InterfaceGeneratorInvalidContentException("no name for enum item");
505  }
506  item_name = attr->get_value();
507 
508  Attribute *val_attr;
509  val_attr = el->get_attribute("value");
510  if ( val_attr ) {
511  item_value = val_attr->get_value();
512  }
513 
514  } else {
515  throw InterfaceGeneratorInvalidContentException("enum item is not an element");
516  }
517 
518  comment_set = (*j)->find("text()");
519  if ( comment_set.size() == 0) {
520  throw InterfaceGeneratorInvalidContentException("enum item without comment");
521  }
522  const TextNode *comment_node = dynamic_cast<const TextNode *>(comment_set[0]);
523  if ( comment_node ) {
524  if (item_value != "") {
525  enum_constant.add_item(item_name, comment_node->get_content(),
527  } else {
528  enum_constant.add_item(item_name, comment_node->get_content());
529  }
530  } else {
531  throw InterfaceGeneratorInvalidContentException("enum comment not a text node");
532  }
533  }
534 
535  enum_constants.push_back(enum_constant);
536  }
537  vector<InterfaceEnumConstant>::iterator i;
538  for (i = enum_constants.begin(); i != enum_constants.end(); ++i) {
539  vector<InterfaceEnumConstant>::iterator j;
540  for (j = i + 1; j != enum_constants.end(); ++j) {
541  if ( i->get_name() == j->get_name() ) {
542  throw InterfaceGeneratorAmbiguousNameException((*i).get_name().c_str(), "enum constant");
543  }
544  }
545  }
546  }
547 
548  /*
549  * data
550  *
551  */
552  set = root->find("/interface/data");
553  if ( set.size() > 1 ) {
554  throw InterfaceGeneratorInvalidContentException("more than one data block");
555  } else if ( set.size() == 0 ) {
556  throw InterfaceGeneratorInvalidContentException("no data block");
557  }
558 
559  data_fields = getFields(set[0]);
560  if ( data_fields.size() == 0 ) {
561  throw InterfaceGeneratorInvalidContentException("data block contains no field");
562  }
563 
564  pseudo_maps = getPseudoMaps(set[0], data_fields);
565 
566  NodeSet comment_set = root->find("/interface/data/comment/text()");
567  if ( comment_set.size() == 0) {
568  throw InterfaceGeneratorInvalidContentException("data block without comment");
569  }
570  const TextNode *comment_node = dynamic_cast<const TextNode *>(comment_set[0]);
571  if ( comment_node ) {
572  data_comment = comment_node->get_content();
573  } else {
574  throw InterfaceGeneratorInvalidContentException("data block comment not a text node");
575  }
576 
577  /*
578  * Messages
579  *
580  */
581  set = root->find("/interface/message");
582  for (NodeSet::iterator i = set.begin(); i != set.end(); ++i) {
583  std::string msg_name;
584  std::string msg_comment;
585 
586  el = dynamic_cast<const Element *>(*i);
587  if ( el ) {
588  Attribute *attr;
589  attr = el->get_attribute("name");
590  if ( ! attr ) {
591  throw InterfaceGeneratorInvalidContentException("no name for message");
592  }
593  msg_name = attr->get_value();
594  } else {
595  throw InterfaceGeneratorInvalidContentException("message is not an element");
596  }
597 
598  comment_set = (*i)->find("text()");
599  if ( comment_set.size() == 0) {
600  throw InterfaceGeneratorInvalidContentException("message without comment");
601  }
602  comment_node = dynamic_cast<const TextNode *>(comment_set[0]);
603  if ( comment_node ) {
604  msg_comment = comment_node->get_content();
605  } else {
606  throw InterfaceGeneratorInvalidContentException("message comment not a text node");
607  }
608 
609 
610  vector<InterfaceField> msg_fields = getFields(*i);
611 
612  NodeSet ref_nodes = (*i)->find("ref/text()");
613  for (NodeSet::iterator r = ref_nodes.begin(); r != ref_nodes.end(); ++r) {
614  const TextNode *text_node = dynamic_cast<const TextNode *>(*r);
615  if ( text_node ) {
616  // find field in data fields
617  bool found = false;
618  for (vector<InterfaceField>::iterator j = data_fields.begin(); j != data_fields.end(); ++j) {
619  if ( (*j).getName() == text_node->get_content() ) {
620  // field found
621  msg_fields.push_back(*j);
622  found = true;
623  break;
624  }
625  }
626  if (! found) {
627  throw InterfaceGeneratorInvalidContentException("reference to non-existing data field");
628  }
629  } else {
630  throw InterfaceGeneratorInvalidContentException("message ref not a text node");
631  }
632  }
633  for (vector<InterfaceField>::iterator k = msg_fields.begin(); k != msg_fields.end(); ++k) {
634  for (vector<InterfaceField>::iterator j = k + 1; j != msg_fields.end(); ++j) {
635  if ( (*k).getName() == (*j).getName() ) {
636  throw InterfaceGeneratorAmbiguousNameException((*k).getName().c_str(), "message field");
637  }
638  }
639  }
640 
641  InterfaceMessage msg(msg_name, msg_comment);
642  msg.setFields(msg_fields);
643 
644  messages.push_back(msg);
645  }
646 
647 }
648 
649 
650 /** Get interface name.
651  * Only valid after parse().
652  * @return interface name.
653  */
654 std::string
656 {
657  return name;
658 }
659 
660 
661 /** Get interface author.
662  * Only valid after parse().
663  * @return interface author.
664  */
665 std::string
667 {
668  return author;
669 }
670 
671 
672 /** Get interface copyright year.
673  * Only valid after parse().
674  * @return interface copyright year
675  */
676 std::string
678 {
679  return year;
680 }
681 
682 
683 /** Get interface creation date as string
684  * Only valid after parse().
685  * @return interface creation date
686  */
687 std::string
689 {
690  return creation_date;
691 }
692 
693 
694 /** Get constants.
695  * Only valid after parse().
696  * @return constants.
697  */
698 std::vector<InterfaceConstant>
700 {
701  return constants;
702 }
703 
704 
705 /** Get enum constants.
706  * Only valid after parse().
707  * @return enum constants.
708  */
709 std::vector<InterfaceEnumConstant>
711 {
712  return enum_constants;
713 }
714 
715 
716 /** Get data fields.
717  * Only valid after parse().
718  * @return data fields.
719  */
720 std::vector<InterfaceField>
722 {
723  return data_fields;
724 }
725 
726 
727 /** Get data pseudo maps.
728  * Only valid after parse().
729  * @return pseudo maps
730  */
731 std::vector<InterfacePseudoMap>
733 {
734  return pseudo_maps;
735 }
736 
737 
738 /** Get data comment.
739  * Only valid after parse().
740  * @return data comment.
741  */
742 std::string
744 {
745  return data_comment;
746 }
747 
748 
749 /** Get messages.
750  * Only valid after parse().
751  * @return messages.
752  */
753 std::vector<InterfaceMessage>
755 {
756  return messages;
757 }
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
std::string getName() const
Get name of field.
Definition: field.cpp:53
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
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:732
std::vector< InterfaceField > getFields(xmlpp::Node *node)
Get parsed fields.
Definition: parser.cpp:72
void valid()
Assert validity.
Definition: field.cpp:348
~InterfaceParser()
Destructor.
Definition: parser.cpp:60
std::string getInterfaceAuthor()
Get interface author.
Definition: parser.cpp:666
std::string getDataComment()
Get data comment.
Definition: parser.cpp:743
Base class for exceptions in Fawkes.
Definition: exception.h:36
Definition: parser.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:242
std::vector< InterfaceMessage > getMessages()
Get messages.
Definition: parser.cpp:754
std::vector< InterfaceField > getDataFields()
Get data fields.
Definition: parser.cpp:721
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:688
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:655
Thrown if document was invalid.
Definition: exceptions.h:32
std::vector< InterfaceEnumConstant > getEnumConstants()
Get enum constants.
Definition: parser.cpp:710
void valid()
Assert validity.
Definition: pseudomap.cpp:104
std::string getInterfaceYear()
Get interface copyright year.
Definition: parser.cpp:677
void add_item(std::string name, std::string comment)
Add an item without custom value.
std::vector< InterfaceConstant > getConstants()
Get constants.
Definition: parser.cpp:699
void setAttribute(const std::string &attr_name, const std::string &attr_value)
Set attribute.
Definition: field.cpp:320
Thrown if illegal type is supplied.
Definition: exceptions.h:73