OMNeT++ NEDXML  6.0.3
msggenerator.h
Go to the documentation of this file.
1 //==========================================================================
2 // MSGGENERATOR.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_MSGGENERATOR_H
18 #define __OMNETPP_NEDXML_MSGGENERATOR_H
19 
20 #include <iostream>
21 
22 #include "errorstore.h"
23 #include "msgelements.h"
24 
25 namespace omnetpp {
26 namespace nedxml {
27 
28 
34 NEDXML_API void generateMsg(std::ostream& out, ASTNode *node);
35 
45 {
46  protected:
47  int indentSize = 4;
48  std::ostream *outp = nullptr;
49 
50  public:
55 
60 
64  void setIndentSize(int indentsize);
65 
70  void generate(std::ostream& out, ASTNode *node, const char *indent);
71 
75  std::string generate(ASTNode *node, const char *indent);
76 
77  protected:
80  const char *increaseIndent(const char *indent);
81  const char *decreaseIndent(const char *indent);
83 
85  void generateItem(ASTNode *node, const char *indent, bool islast, const char *arg=nullptr);;
86 
88  void generateChildren(ASTNode *node, const char *indent, const char *arg=nullptr);
89 
91  void generateChildrenWithType(ASTNode *node, int tagcode, const char *indent, const char *arg=nullptr);
92 
94  void generateChildrenWithTypes(ASTNode *node, int tagcodes[], const char *indent, const char *arg=nullptr);
95 
96  void doMsgClassOrStructBody(ASTNode *msgclassorstruct, const char *indent);
97 
100  std::string concatInnerComments(ASTNode *node);
101  std::string getBannerComment(ASTNode *node, const char *indent);
102  std::string getRightComment(ASTNode *node);
103  std::string getInlineRightComment(ASTNode *node);
104  std::string getTrailingComment(ASTNode *node);
106 
109  void doFiles(FilesElement *node, const char *indent, bool islast, const char *);
110  void doMsgFile(MsgFileElement *node, const char *indent, bool islast, const char *);
111  void doImport(ImportElement *node, const char *indent, bool islast, const char *);
112  void doProperty(PropertyElement *node, const char *indent, bool islast, const char *sep);
113  void doPropertyKey(PropertyKeyElement *node, const char *indent, bool islast, const char *sep);
114  void doLiteral(LiteralElement *node, const char *indent, bool islast, const char *);
115  void doNamespace(NamespaceElement *node, const char *indent, bool islast, const char *);
116  void doCplusplus(CplusplusElement *node, const char *indent, bool islast, const char *);
117  void doStructDecl(StructDeclElement *node, const char *indent, bool islast, const char *);
118  void doClassDecl(ClassDeclElement *node, const char *indent, bool islast, const char *);
119  void doMessageDecl(MessageDeclElement *node, const char *indent, bool islast, const char *);
120  void doPacketDecl(PacketDeclElement *node, const char *indent, bool islast, const char *);
121  void doEnumDecl(EnumDeclElement *node, const char *indent, bool islast, const char *);
122  void doEnum(EnumElement *node, const char *indent, bool islast, const char *);
123  void doEnumField(EnumFieldElement *node, const char *indent, bool islast, const char *);
124  void doMessage(MessageElement *node, const char *indent, bool islast, const char *);
125  void doPacket(PacketElement *node, const char *indent, bool islast, const char *);
126  void doClass(ClassElement *node, const char *indent, bool islast, const char *);
127  void doStruct(StructElement *node, const char *indent, bool islast, const char *);
128  void doField(FieldElement *node, const char *indent, bool islast, const char *);
129  void doComment(CommentElement *node, const char *indent, bool islast, const char *);
131 };
132 
133 } // namespace nedxml
134 } // namespace omnetpp
135 
136 
137 #endif
138 
139 
omnetpp::nedxml::MsgGenerator
Generates MSG source from an AST.
Definition: msggenerator.h:44
omnetpp::nedxml::MsgGenerator::~MsgGenerator
~MsgGenerator()
Definition: msggenerator.h:59
NEDXML_API
#define NEDXML_API
Definition: nedxmldefs.h:31
omnetpp
Definition: astbuilder.h:25
omnetpp::nedxml::MsgGenerator::MsgGenerator
MsgGenerator()
Definition: msggenerator.h:54
omnetpp::nedxml::ASTNode
Definition: astnode.h:87
errorstore.h
omnetpp::nedxml::generateMsg
NEDXML_API void generateMsg(std::ostream &out, ASTNode *node)
Simple front-end to MsgGenerator.