OMNeT++ NEDXML  6.0.3
msgcompiler.h
Go to the documentation of this file.
1 //==========================================================================
2 // MSGCOMPILER.H - part of
3 //
4 // OMNeT++/OMNEST
5 // Discrete System Simulation in C++
6 //
7 //==========================================================================
8 
9 /*--------------------------------------------------------------*
10  Copyright (C) 2002-2017 Andras Varga
11  Copyright (C) 2006-2017 OpenSim Ltd.
12 
13  This file is distributed WITHOUT ANY WARRANTY. See the file
14  `license' for details on this and other legal matters.
15 *--------------------------------------------------------------*/
16 
17 #ifndef __OMNETPP_NEDXML_MSGCOMPILER_H
18 #define __OMNETPP_NEDXML_MSGCOMPILER_H
19 
20 #include <iostream>
21 #include <sstream>
22 #include <string>
23 #include <vector>
24 #include <map>
25 #include <set>
26 
27 #include "errorstore.h"
28 #include "msgelements.h"
29 #include "msgtypetable.h"
30 #include "msganalyzer.h"
31 #include "msgcodegenerator.h"
32 #include "msgcompileroptions.h"
33 
34 namespace omnetpp {
35 namespace nedxml {
36 
45 {
46  public:
47  typedef std::set<std::string> StringSet;
48  typedef std::vector<std::string> StringVector;
55 
56  protected:
61 
62  bool used = false;
66 
67  private:
68  static constexpr const char* ATT_NAME = "name";
69  static const char *BUILTIN_DEFINITIONS;
70 
71  protected:
72  void importBuiltinDefinitions();
73  void processBuiltinImport(const char *txt, const char *fname);
74 
75  void processImport(ImportElement *importElem, const std::string& currentDir);
76  std::string resolveImport(const std::string& importName, const std::string& currentDir);
77  void collectTypes(MsgFileElement *fileElement, bool isImport);
78  void generateCode(MsgFileElement *fileElement);
79  std::string prefixWithNamespace(const std::string& name, const std::string& namespaceName);
80  void validateNamespaceName(const std::string& namespaceName, ASTNode *element);
81 
82  public:
86  MsgCompiler(const MsgCompilerOptions& options, ErrorStore *errors);
87 
92 
97  void generate(MsgFileElement *fileElement, const char *hFile, const char *ccFile, StringSet& outImportedFiles);
98 
102  void printPropertiesLatexDocu(std::ostream& out);
103 
107  static const char *getBuiltinDefinitions() {return BUILTIN_DEFINITIONS;}
108 };
109 
110 } // namespace nedxml
111 } // namespace omnetpp
112 
113 
114 #endif
115 
116 
omnetpp::nedxml::MsgCompilerOptions
Options for MsgCompiler.
Definition: msgcompileroptions.h:32
omnetpp::nedxml::MsgTypeTable::EnumInfo
Definition: msgtypetable.h:232
omnetpp::nedxml::MsgCompiler::Properties
MsgTypeTable::Properties Properties
Definition: msgcompiler.h:50
omnetpp::nedxml::MsgTypeTable::Properties
Definition: msgtypetable.h:64
msgcodegenerator.h
omnetpp::nedxml::MsgTypeTable::ClassInfo
Definition: msgtypetable.h:153
omnetpp::nedxml::MsgCompiler::codegen
MsgCodeGenerator codegen
Definition: msgcompiler.h:60
omnetpp::nedxml::MsgCompiler::importsSeen
StringSet importsSeen
Definition: msgcompiler.h:64
omnetpp::nedxml::MsgCodeGenerator
Code generator part of the message compiler.
Definition: msgcodegenerator.h:40
omnetpp::nedxml::MsgCompiler::getBuiltinDefinitions
static const char * getBuiltinDefinitions()
Definition: msgcompiler.h:107
NEDXML_API
#define NEDXML_API
Definition: nedxmldefs.h:31
omnetpp::nedxml::MsgCompiler::Property
MsgTypeTable::Property Property
Definition: msgcompiler.h:49
omnetpp::nedxml::MsgCompiler::EnumInfo
MsgTypeTable::EnumInfo EnumInfo
Definition: msgcompiler.h:54
omnetpp
Definition: astbuilder.h:25
omnetpp::nedxml::MsgTypeTable::EnumItem
Definition: msgtypetable.h:223
omnetpp::nedxml::MsgCompiler::~MsgCompiler
~MsgCompiler()
Definition: msgcompiler.h:91
omnetpp::nedxml::MsgTypeTable
Definition: msgtypetable.h:39
omnetpp::nedxml::MsgCompiler::importedFiles
StringSet importedFiles
Definition: msgcompiler.h:65
omnetpp::nedxml::MsgCompiler::ClassInfo
MsgTypeTable::ClassInfo ClassInfo
Definition: msgcompiler.h:52
omnetpp::nedxml::MsgTypeTable::Property
Definition: msgtypetable.h:44
omnetpp::nedxml::MsgCompiler::FieldInfo
MsgTypeTable::FieldInfo FieldInfo
Definition: msgcompiler.h:51
omnetpp::nedxml::MsgCompiler::errors
ErrorStore * errors
Definition: msgcompiler.h:63
msgcompileroptions.h
omnetpp::nedxml::MsgCompiler::StringSet
std::set< std::string > StringSet
Definition: msgcompiler.h:47
omnetpp::nedxml::ASTNode
Definition: astnode.h:87
omnetpp::nedxml::MsgCompiler::EnumItem
MsgTypeTable::EnumItem EnumItem
Definition: msgcompiler.h:53
errorstore.h
omnetpp::nedxml::MsgCompiler::typeTable
MsgTypeTable typeTable
Definition: msgcompiler.h:58
omnetpp::nedxml::MsgCompiler::opts
MsgCompilerOptions opts
Definition: msgcompiler.h:57
omnetpp::nedxml::MsgAnalyzer
Part of the message compiler. Produces ClassInfo/EnumInfo objects from the ASTNode tree....
Definition: msganalyzer.h:41
omnetpp::nedxml::MsgCompiler::analyzer
MsgAnalyzer analyzer
Definition: msgcompiler.h:59
msganalyzer.h
omnetpp::nedxml::MsgCompiler::StringVector
std::vector< std::string > StringVector
Definition: msgcompiler.h:48
omnetpp::nedxml::ErrorStore
Definition: errorstore.h:37
omnetpp::nedxml::MsgCompiler
Generates C++ code from a MSG file object tree.
Definition: msgcompiler.h:44
omnetpp::nedxml::MsgTypeTable::FieldInfo
Definition: msgtypetable.h:76
msgtypetable.h