OMNeT++ NEDXML  6.0.3
NedGenerator Class Reference

#include <nedgenerator.h>

Description

Generates NED code from a NED AST.

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

Public Member Functions

 NedGenerator ()
 
 ~NedGenerator ()
 
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 generateNedItem (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)
 
Utilities
void printInheritance (ASTNode *node, const char *indent)
 
bool hasExpression (ASTNode *node, const char *attr)
 
void printExpression (ASTNode *node, const char *attr, const char *indent)
 
void printOptVector (ASTNode *node, const char *attr, const char *indent)
 
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 NED code from the given element
void doFiles (FilesElement *node, const char *indent, bool islast, const char *)
 
void doNedFile (NedFileElement *node, const char *indent, bool islast, const char *)
 
void doPackage (PackageElement *node, const char *indent, bool islast, const char *)
 
void doImport (ImportElement *node, const char *indent, bool islast, const char *)
 
void doPropertyDecl (PropertyDeclElement *node, const char *indent, bool islast, const char *)
 
void doExtends (ExtendsElement *node, const char *indent, bool islast, const char *)
 
void doInterfaceName (InterfaceNameElement *node, const char *indent, bool islast, const char *)
 
void doSimpleModule (SimpleModuleElement *node, const char *indent, bool islast, const char *)
 
void doModuleInterface (ModuleInterfaceElement *node, const char *indent, bool islast, const char *)
 
void doCompoundModule (CompoundModuleElement *node, const char *indent, bool islast, const char *)
 
void doChannelInterface (ChannelInterfaceElement *node, const char *indent, bool islast, const char *)
 
void doChannel (ChannelElement *node, const char *indent, bool islast, const char *)
 
void doParameters (ParametersElement *node, const char *indent, bool islast, const char *)
 
void doParam (ParamElement *node, const char *indent, bool islast, const char *)
 
void doProperty (PropertyElement *node, const char *indent, bool islast, const char *)
 
void doPropertyKey (PropertyKeyElement *node, const char *indent, bool islast, const char *)
 
void doGates (GatesElement *node, const char *indent, bool islast, const char *)
 
void doGate (GateElement *node, const char *indent, bool islast, const char *)
 
void doTypes (TypesElement *node, const char *indent, bool islast, const char *)
 
void doSubmodules (SubmodulesElement *node, const char *indent, bool islast, const char *)
 
void doSubmodule (SubmoduleElement *node, const char *indent, bool islast, const char *)
 
void doConnections (ConnectionsElement *node, const char *indent, bool islast, const char *)
 
void doConnection (ConnectionElement *node, const char *indent, bool islast, const char *)
 
void doConnectionGroup (ConnectionGroupElement *node, const char *indent, bool islast, const char *)
 
void doLoop (LoopElement *node, const char *indent, bool islast, const char *)
 
void doCondition (ConditionElement *node, const char *indent, bool islast, const char *)
 
void printConnectionGate (ASTNode *conn, const char *modname, const char *modindexattr, const char *gatename, const char *gateindexattr, bool isplusplus, int gatesubg, const char *indent)
 
void doLiteral (LiteralElement *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

◆ NedGenerator()

NedGenerator ( )
inline

Constructor.

◆ ~NedGenerator()

~NedGenerator ( )
inline

Destructor.

Member Function Documentation

◆ setIndentSize()

void setIndentSize ( int  indentsize)

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

◆ generate() [1/2]

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

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

◆ generate() [2/2]

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

Generates NED code and returns it as a string.

◆ increaseIndent()

const char* increaseIndent ( const char *  indent)
protected

◆ decreaseIndent()

const char* decreaseIndent ( const char *  indent)
protected

◆ generateNedItem()

void generateNedItem ( 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 generateNedItem() on all children

◆ generateChildrenWithType()

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

Invoke generateNedItem() on all children of the given tagcode

◆ generateChildrenWithTypes()

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

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

◆ printInheritance()

void printInheritance ( ASTNode node,
const char *  indent 
)
protected

◆ hasExpression()

bool hasExpression ( ASTNode node,
const char *  attr 
)
protected

◆ printExpression()

void printExpression ( ASTNode node,
const char *  attr,
const char *  indent 
)
protected

◆ printOptVector()

void printOptVector ( ASTNode node,
const char *  attr,
const char *  indent 
)
protected

◆ 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

◆ doNedFile()

void doNedFile ( NedFileElement *  node,
const char *  indent,
bool  islast,
const char *   
)
protected

◆ doPackage()

void doPackage ( PackageElement *  node,
const char *  indent,
bool  islast,
const char *   
)
protected

◆ doImport()

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

◆ doPropertyDecl()

void doPropertyDecl ( PropertyDeclElement *  node,
const char *  indent,
bool  islast,
const char *   
)
protected

◆ doExtends()

void doExtends ( ExtendsElement *  node,
const char *  indent,
bool  islast,
const char *   
)
protected

◆ doInterfaceName()

void doInterfaceName ( InterfaceNameElement *  node,
const char *  indent,
bool  islast,
const char *   
)
protected

◆ doSimpleModule()

void doSimpleModule ( SimpleModuleElement *  node,
const char *  indent,
bool  islast,
const char *   
)
protected

◆ doModuleInterface()

void doModuleInterface ( ModuleInterfaceElement *  node,
const char *  indent,
bool  islast,
const char *   
)
protected

◆ doCompoundModule()

void doCompoundModule ( CompoundModuleElement *  node,
const char *  indent,
bool  islast,
const char *   
)
protected

◆ doChannelInterface()

void doChannelInterface ( ChannelInterfaceElement *  node,
const char *  indent,
bool  islast,
const char *   
)
protected

◆ doChannel()

void doChannel ( ChannelElement *  node,
const char *  indent,
bool  islast,
const char *   
)
protected

◆ doParameters()

void doParameters ( ParametersElement *  node,
const char *  indent,
bool  islast,
const char *   
)
protected

◆ doParam()

void doParam ( ParamElement *  node,
const char *  indent,
bool  islast,
const char *   
)
protected

◆ doProperty()

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

◆ doPropertyKey()

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

◆ doGates()

void doGates ( GatesElement *  node,
const char *  indent,
bool  islast,
const char *   
)
protected

◆ doGate()

void doGate ( GateElement *  node,
const char *  indent,
bool  islast,
const char *   
)
protected

◆ doTypes()

void doTypes ( TypesElement *  node,
const char *  indent,
bool  islast,
const char *   
)
protected

◆ doSubmodules()

void doSubmodules ( SubmodulesElement *  node,
const char *  indent,
bool  islast,
const char *   
)
protected

◆ doSubmodule()

void doSubmodule ( SubmoduleElement *  node,
const char *  indent,
bool  islast,
const char *   
)
protected

◆ doConnections()

void doConnections ( ConnectionsElement *  node,
const char *  indent,
bool  islast,
const char *   
)
protected

◆ doConnection()

void doConnection ( ConnectionElement *  node,
const char *  indent,
bool  islast,
const char *   
)
protected

◆ doConnectionGroup()

void doConnectionGroup ( ConnectionGroupElement *  node,
const char *  indent,
bool  islast,
const char *   
)
protected

◆ doLoop()

void doLoop ( LoopElement *  node,
const char *  indent,
bool  islast,
const char *   
)
protected

◆ doCondition()

void doCondition ( ConditionElement *  node,
const char *  indent,
bool  islast,
const char *   
)
protected

◆ printConnectionGate()

void printConnectionGate ( ASTNode conn,
const char *  modname,
const char *  modindexattr,
const char *  gatename,
const char *  gateindexattr,
bool  isplusplus,
int  gatesubg,
const char *  indent 
)
protected

◆ doLiteral()

void doLiteral ( LiteralElement *  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: