OMNeT++ NEDXML  6.0.3
MsgGenerator Class Reference

#include <msggenerator.h>

Description

Generates MSG source from an AST.

Assumes that the object tree has already passed all validation stages (DTD, syntax, semantic).

Public Member Functions

 MsgGenerator ()
 
 ~MsgGenerator ()
 
void setIndentSize (int indentsize)
 
void generate (std::ostream &out, ASTNode *node, const char *indent)
 
std::string generate (ASTNode *node, const char *indent)
 

Protected Member Functions

Change indentation level
const char * increaseIndent (const char *indent)
 
const char * decreaseIndent (const char *indent)
 
void generateItem (ASTNode *node, const char *indent, bool islast, const char *arg=nullptr)
 
void generateChildren (ASTNode *node, const char *indent, const char *arg=nullptr)
 
void generateChildrenWithType (ASTNode *node, int tagcode, const char *indent, const char *arg=nullptr)
 
void generateChildrenWithTypes (ASTNode *node, int tagcodes[], const char *indent, const char *arg=nullptr)
 
void doMsgClassOrStructBody (ASTNode *msgclassorstruct, const char *indent)
 
Getters for comments
std::string concatInnerComments (ASTNode *node)
 
std::string getBannerComment (ASTNode *node, const char *indent)
 
std::string getRightComment (ASTNode *node)
 
std::string getInlineRightComment (ASTNode *node)
 
std::string getTrailingComment (ASTNode *node)
 
Generate MSG source code from the given element
void doFiles (FilesElement *node, const char *indent, bool islast, const char *)
 
void doMsgFile (MsgFileElement *node, const char *indent, bool islast, const char *)
 
void doImport (ImportElement *node, const char *indent, bool islast, const char *)
 
void doProperty (PropertyElement *node, const char *indent, bool islast, const char *sep)
 
void doPropertyKey (PropertyKeyElement *node, const char *indent, bool islast, const char *sep)
 
void doLiteral (LiteralElement *node, const char *indent, bool islast, const char *)
 
void doNamespace (NamespaceElement *node, const char *indent, bool islast, const char *)
 
void doCplusplus (CplusplusElement *node, const char *indent, bool islast, const char *)
 
void doStructDecl (StructDeclElement *node, const char *indent, bool islast, const char *)
 
void doClassDecl (ClassDeclElement *node, const char *indent, bool islast, const char *)
 
void doMessageDecl (MessageDeclElement *node, const char *indent, bool islast, const char *)
 
void doPacketDecl (PacketDeclElement *node, const char *indent, bool islast, const char *)
 
void doEnumDecl (EnumDeclElement *node, const char *indent, bool islast, const char *)
 
void doEnum (EnumElement *node, const char *indent, bool islast, const char *)
 
void doEnumField (EnumFieldElement *node, const char *indent, bool islast, const char *)
 
void doMessage (MessageElement *node, const char *indent, bool islast, const char *)
 
void doPacket (PacketElement *node, const char *indent, bool islast, const char *)
 
void doClass (ClassElement *node, const char *indent, bool islast, const char *)
 
void doStruct (StructElement *node, const char *indent, bool islast, const char *)
 
void doField (FieldElement *node, const char *indent, bool islast, const char *)
 
void doComment (CommentElement *node, const char *indent, bool islast, const char *)
 

Protected Attributes

int indentSize = 4
 
std::ostream * outp = nullptr
 

Constructor & Destructor Documentation

◆ MsgGenerator()

MsgGenerator ( )
inline

Constructor.

◆ ~MsgGenerator()

~MsgGenerator ( )
inline

Destructor.

Member Function Documentation

◆ setIndentSize()

void setIndentSize ( int  indentsize)

Sets the indent size in the generated MSG source code. Default is 4 spaces.

◆ generate() [1/2]

void generate ( std::ostream &  out,
ASTNode node,
const char *  indent 
)

Generates MSG source code. Takes an output stream where the generated code will be written, the object tree and the base indentation.

◆ generate() [2/2]

std::string generate ( ASTNode node,
const char *  indent 
)

Generates MSG source code and returns it as a string.

◆ increaseIndent()

const char* increaseIndent ( const char *  indent)
protected

◆ decreaseIndent()

const char* decreaseIndent ( const char *  indent)
protected

◆ generateItem()

void generateItem ( ASTNode node,
const char *  indent,
bool  islast,
const char *  arg = nullptr 
)
protected

Dispatch to various doXXX() methods according to node type

◆ generateChildren()

void generateChildren ( ASTNode node,
const char *  indent,
const char *  arg = nullptr 
)
protected

Invoke generateItem() on all children

◆ generateChildrenWithType()

void generateChildrenWithType ( ASTNode node,
int  tagcode,
const char *  indent,
const char *  arg = nullptr 
)
protected

Invoke generateItem() on all children of the given tagcode

◆ generateChildrenWithTypes()

void generateChildrenWithTypes ( ASTNode node,
int  tagcodes[],
const char *  indent,
const char *  arg = nullptr 
)
protected

Invoke generateItem() on children of the given tagcodes (NED_NULL-terminated array)

◆ doMsgClassOrStructBody()

void doMsgClassOrStructBody ( ASTNode msgclassorstruct,
const char *  indent 
)
protected

◆ concatInnerComments()

std::string concatInnerComments ( ASTNode node)
protected

◆ getBannerComment()

std::string getBannerComment ( ASTNode node,
const char *  indent 
)
protected

◆ getRightComment()

std::string getRightComment ( ASTNode node)
protected

◆ getInlineRightComment()

std::string getInlineRightComment ( ASTNode node)
protected

◆ getTrailingComment()

std::string getTrailingComment ( ASTNode node)
protected

◆ doFiles()

void doFiles ( FilesElement *  node,
const char *  indent,
bool  islast,
const char *   
)
protected

◆ doMsgFile()

void doMsgFile ( MsgFileElement *  node,
const char *  indent,
bool  islast,
const char *   
)
protected

◆ doImport()

void doImport ( ImportElement *  node,
const char *  indent,
bool  islast,
const char *   
)
protected

◆ doProperty()

void doProperty ( PropertyElement *  node,
const char *  indent,
bool  islast,
const char *  sep 
)
protected

◆ doPropertyKey()

void doPropertyKey ( PropertyKeyElement *  node,
const char *  indent,
bool  islast,
const char *  sep 
)
protected

◆ doLiteral()

void doLiteral ( LiteralElement *  node,
const char *  indent,
bool  islast,
const char *   
)
protected

◆ doNamespace()

void doNamespace ( NamespaceElement *  node,
const char *  indent,
bool  islast,
const char *   
)
protected

◆ doCplusplus()

void doCplusplus ( CplusplusElement *  node,
const char *  indent,
bool  islast,
const char *   
)
protected

◆ doStructDecl()

void doStructDecl ( StructDeclElement *  node,
const char *  indent,
bool  islast,
const char *   
)
protected

◆ doClassDecl()

void doClassDecl ( ClassDeclElement *  node,
const char *  indent,
bool  islast,
const char *   
)
protected

◆ doMessageDecl()

void doMessageDecl ( MessageDeclElement *  node,
const char *  indent,
bool  islast,
const char *   
)
protected

◆ doPacketDecl()

void doPacketDecl ( PacketDeclElement *  node,
const char *  indent,
bool  islast,
const char *   
)
protected

◆ doEnumDecl()

void doEnumDecl ( EnumDeclElement *  node,
const char *  indent,
bool  islast,
const char *   
)
protected

◆ doEnum()

void doEnum ( EnumElement *  node,
const char *  indent,
bool  islast,
const char *   
)
protected

◆ doEnumField()

void doEnumField ( EnumFieldElement *  node,
const char *  indent,
bool  islast,
const char *   
)
protected

◆ doMessage()

void doMessage ( MessageElement *  node,
const char *  indent,
bool  islast,
const char *   
)
protected

◆ doPacket()

void doPacket ( PacketElement *  node,
const char *  indent,
bool  islast,
const char *   
)
protected

◆ doClass()

void doClass ( ClassElement *  node,
const char *  indent,
bool  islast,
const char *   
)
protected

◆ doStruct()

void doStruct ( StructElement *  node,
const char *  indent,
bool  islast,
const char *   
)
protected

◆ doField()

void doField ( FieldElement *  node,
const char *  indent,
bool  islast,
const char *   
)
protected

◆ doComment()

void doComment ( CommentElement *  node,
const char *  indent,
bool  islast,
const char *   
)
protected

Member Data Documentation

◆ indentSize

int indentSize = 4
protected

◆ outp

std::ostream* outp = nullptr
protected

The documentation for this class was generated from the following file: