Fawkes API  Fawkes Development Version
parser.h
1 
2 /***************************************************************************
3  * parser.h - Interface config parser
4  *
5  * Created: Tue Oct 10 17:29:33 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 #ifndef _INTERFACES_GENERATOR_PARSER_H_
23 #define _INTERFACES_GENERATOR_PARSER_H_
24 
25 #include "constant.h"
26 #include "enum_constant.h"
27 #include "field.h"
28 #include "message.h"
29 #include "pseudomap.h"
30 
31 #include <string>
32 #include <vector>
33 
34 namespace xmlpp {
35 class DomParser;
36 class Node;
37 } // namespace xmlpp
38 
39 class InterfaceParser
40 {
41 public:
42  InterfaceParser(std::string config_filename);
44 
45  std::vector<InterfaceField> getFields(xmlpp::Node * node,
46  const std::set<std::string> &reserved_names);
47  std::vector<InterfacePseudoMap> getPseudoMaps(xmlpp::Node * node,
48  std::vector<InterfaceField> &fields);
49  void parse();
50 
51  void printFields(std::vector<InterfaceField> &fields);
52  void printPseudoMaps(std::vector<InterfacePseudoMap> &pseudo_maps);
53  void print();
54  void printParsed(std::vector<InterfaceConstant> & constants,
55  std::vector<InterfaceEnumConstant> &enum_constants,
56  std::vector<InterfaceField> & data_fields,
57  std::vector<InterfacePseudoMap> & pseudo_maps,
58  std::vector<InterfaceMessage> & messages);
59 
60  std::string getInterfaceName();
61  std::string getInterfaceAuthor();
62  std::string getInterfaceYear();
63  std::string getInterfaceCreationDate();
64  std::vector<InterfaceConstant> getConstants();
65  std::vector<InterfaceEnumConstant> getEnumConstants();
66  std::vector<InterfaceField> getDataFields();
67  std::vector<InterfacePseudoMap> getPseudoMaps();
68  std::string getDataComment();
69  std::vector<InterfaceMessage> getMessages();
70 
71 private:
72  xmlpp::DomParser *dom;
73  xmlpp::Node * root;
74  std::string name;
75  std::string author;
76  std::string year;
77  std::string creation_date;
78  std::string data_comment;
79 
80  std::vector<InterfaceConstant> constants;
81  std::vector<InterfaceEnumConstant> enum_constants;
82  std::vector<InterfaceField> data_fields;
83  std::vector<InterfacePseudoMap> pseudo_maps;
84  std::vector<InterfaceMessage> messages;
85 };
86 
87 #endif
InterfaceParser::getConstants
std::vector< InterfaceConstant > getConstants()
Get constants.
Definition: parser.cpp:713
InterfaceParser::getFields
std::vector< InterfaceField > getFields(xmlpp::Node *node, const std::set< std::string > &reserved_names)
Get parsed fields.
Definition: parser.cpp:71
InterfaceParser::printFields
void printFields(std::vector< InterfaceField > &fields)
Print fields.
Definition: parser.cpp:235
InterfaceParser::parse
void parse()
Parse config.
Definition: parser.cpp:335
InterfaceParser::getInterfaceAuthor
std::string getInterfaceAuthor()
Get interface author.
Definition: parser.cpp:683
InterfaceParser::getDataFields
std::vector< InterfaceField > getDataFields()
Get data fields.
Definition: parser.cpp:733
InterfaceParser::getInterfaceYear
std::string getInterfaceYear()
Get interface copyright year.
Definition: parser.cpp:693
InterfaceParser::getPseudoMaps
std::vector< InterfacePseudoMap > getPseudoMaps()
Get data pseudo maps.
Definition: parser.cpp:743
InterfaceParser::printParsed
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:292
InterfaceParser::getInterfaceName
std::string getInterfaceName()
Get interface name.
Definition: parser.cpp:673
InterfaceParser
Definition: parser.h:38
InterfaceParser::~InterfaceParser
~InterfaceParser()
Destructor.
Definition: parser.cpp:59
InterfaceParser::printPseudoMaps
void printPseudoMaps(std::vector< InterfacePseudoMap > &pseudo_maps)
Print pseudo maps.
Definition: parser.cpp:268
InterfaceParser::getDataComment
std::string getDataComment()
Get data comment.
Definition: parser.cpp:753
InterfaceParser::InterfaceParser
InterfaceParser(std::string config_filename)
Constructor.
Definition: parser.cpp:46
InterfaceParser::print
void print()
Print parsed data.
Definition: parser.cpp:328
InterfaceParser::getEnumConstants
std::vector< InterfaceEnumConstant > getEnumConstants()
Get enum constants.
Definition: parser.cpp:723
InterfaceParser::getMessages
std::vector< InterfaceMessage > getMessages()
Get messages.
Definition: parser.cpp:763
InterfaceParser::getInterfaceCreationDate
std::string getInterfaceCreationDate()
Get interface creation date as string Only valid after parse().
Definition: parser.cpp:703