OMNeT++ NEDXML  5.4.1
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

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)
 
Change indentation level
const char * increaseIndent (const char *indent)
 
const char * decreaseIndent (const char *indent)
 
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 doExpression (ExpressionElement *node, const char *indent, bool islast, const char *)
 
int getOperatorPrecedence (const char *op, int args)
 
bool isOperatorLeftAssoc (const char *op)
 
void doOperator (OperatorElement *node, const char *indent, bool islast, const char *)
 
void doFunction (FunctionElement *node, const char *indent, bool islast, const char *)
 
void doIdent (IdentElement *node, const char *indent, bool islast, const char *)
 
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
 
std::ostream * outp
 

Constructor & Destructor Documentation

Constructor.

Destructor.

Member Function Documentation

void setIndentSize ( int  indentsize)

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

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.

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

Generates NED code and returns it as a string.

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

Dispatch to various doXXX() methods according to node type

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

Invoke generateNedItem() on all children

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

Invoke generateNedItem() on all children of the given tagcode

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)

void printInheritance ( ASTNode node,
const char *  indent 
)
protected
bool hasExpression ( ASTNode node,
const char *  attr 
)
protected
void printExpression ( ASTNode node,
const char *  attr,
const char *  indent 
)
protected
void printOptVector ( ASTNode node,
const char *  attr,
const char *  indent 
)
protected
void doMsgClassOrStructBody ( ASTNode msgclassorstruct,
const char *  indent 
)
protected
std::string concatInnerComments ( ASTNode node)
protected
std::string getBannerComment ( ASTNode node,
const char *  indent 
)
protected
std::string getRightComment ( ASTNode node)
protected
std::string getInlineRightComment ( ASTNode node)
protected
std::string getTrailingComment ( ASTNode node)
protected
void doFiles ( FilesElement *  node,
const char *  indent,
bool  islast,
const char *   
)
protected
void doNedFile ( NedFileElement *  node,
const char *  indent,
bool  islast,
const char *   
)
protected
void doPackage ( PackageElement *  node,
const char *  indent,
bool  islast,
const char *   
)
protected
void doImport ( ImportElement *  node,
const char *  indent,
bool  islast,
const char *   
)
protected
void doPropertyDecl ( PropertyDeclElement *  node,
const char *  indent,
bool  islast,
const char *   
)
protected
void doExtends ( ExtendsElement *  node,
const char *  indent,
bool  islast,
const char *   
)
protected
void doInterfaceName ( InterfaceNameElement *  node,
const char *  indent,
bool  islast,
const char *   
)
protected
void doSimpleModule ( SimpleModuleElement *  node,
const char *  indent,
bool  islast,
const char *   
)
protected
void doModuleInterface ( ModuleInterfaceElement *  node,
const char *  indent,
bool  islast,
const char *   
)
protected
void doCompoundModule ( CompoundModuleElement *  node,
const char *  indent,
bool  islast,
const char *   
)
protected
void doChannelInterface ( ChannelInterfaceElement *  node,
const char *  indent,
bool  islast,
const char *   
)
protected
void doChannel ( ChannelElement *  node,
const char *  indent,
bool  islast,
const char *   
)
protected
void doParameters ( ParametersElement *  node,
const char *  indent,
bool  islast,
const char *   
)
protected
void doParam ( ParamElement *  node,
const char *  indent,
bool  islast,
const char *   
)
protected
void doProperty ( PropertyElement *  node,
const char *  indent,
bool  islast,
const char *   
)
protected
void doPropertyKey ( PropertyKeyElement *  node,
const char *  indent,
bool  islast,
const char *   
)
protected
void doGates ( GatesElement *  node,
const char *  indent,
bool  islast,
const char *   
)
protected
void doGate ( GateElement *  node,
const char *  indent,
bool  islast,
const char *   
)
protected
void doTypes ( TypesElement *  node,
const char *  indent,
bool  islast,
const char *   
)
protected
void doSubmodules ( SubmodulesElement *  node,
const char *  indent,
bool  islast,
const char *   
)
protected
void doSubmodule ( SubmoduleElement *  node,
const char *  indent,
bool  islast,
const char *   
)
protected
void doConnections ( ConnectionsElement *  node,
const char *  indent,
bool  islast,
const char *   
)
protected
void doConnection ( ConnectionElement *  node,
const char *  indent,
bool  islast,
const char *   
)
protected
void doConnectionGroup ( ConnectionGroupElement *  node,
const char *  indent,
bool  islast,
const char *   
)
protected
void doLoop ( LoopElement *  node,
const char *  indent,
bool  islast,
const char *   
)
protected
void doCondition ( ConditionElement *  node,
const char *  indent,
bool  islast,
const char *   
)
protected
void printConnectionGate ( ASTNode conn,
const char *  modname,
const char *  modindexattr,
const char *  gatename,
const char *  gateindexattr,
bool  isplusplus,
int  gatesubg,
const char *  indent 
)
protected
void doExpression ( ExpressionElement *  node,
const char *  indent,
bool  islast,
const char *   
)
protected
int getOperatorPrecedence ( const char *  op,
int  args 
)
protected
bool isOperatorLeftAssoc ( const char *  op)
protected
void doOperator ( OperatorElement *  node,
const char *  indent,
bool  islast,
const char *   
)
protected
void doFunction ( FunctionElement *  node,
const char *  indent,
bool  islast,
const char *   
)
protected
void doIdent ( IdentElement *  node,
const char *  indent,
bool  islast,
const char *   
)
protected
void doLiteral ( LiteralElement *  node,
const char *  indent,
bool  islast,
const char *   
)
protected
void doComment ( CommentElement *  node,
const char *  indent,
bool  islast,
const char *   
)
protected

Member Data Documentation

int indentSize
protected
std::ostream* outp
protected

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