00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __NED2GENERATOR_H
00018 #define __NED2GENERATOR_H
00019
00020 #include <iostream>
00021 #include "nedelements.h"
00022 #include "nederror.h"
00023
00024 NAMESPACE_BEGIN
00025
00026
00032 NEDXML_API void generateNED2(std::ostream& out, NEDElement *node, NEDErrorStore *e);
00033
00040 class NEDXML_API NED2Generator
00041 {
00042 protected:
00043 int indentsize;
00044 std::ostream *outp;
00045 NEDErrorStore *errors;
00046
00047 public:
00051 NED2Generator(NEDErrorStore *errors);
00052
00056 ~NED2Generator();
00057
00061 void setIndentSize(int indentsize);
00062
00067 void generate(std::ostream& out, NEDElement *node, const char *indent);
00068
00072 std::string generate(NEDElement *node, const char *indent);
00073
00074 protected:
00077 const char *increaseIndent(const char *indent);
00078 const char *decreaseIndent(const char *indent);
00080
00082 void generateNedItem(NEDElement *node, const char *indent, bool islast, const char *arg=NULL);;
00083
00085 void generateChildren(NEDElement *node, const char *indent, const char *arg=NULL);
00086
00088 void generateChildrenWithType(NEDElement *node, int tagcode, const char *indent, const char *arg=0);
00089
00091 void generateChildrenWithTypes(NEDElement *node, int tagcodes[], const char *indent, const char *arg=0);
00092
00095 void printInheritance(NEDElement *node, const char *indent);
00096 bool hasExpression(NEDElement *node, const char *attr);
00097 void printExpression(NEDElement *node, const char *attr, const char *indent);
00098 void printOptVector(NEDElement *node, const char *attr, const char *indent);
00099 void doMsgClassOrStructBody(NEDElement *msgclassorstruct, const char *indent);
00101
00104 std::string concatInnerComments(NEDElement *node);
00105 std::string getBannerComment(NEDElement *node, const char *indent);
00106 std::string getRightComment(NEDElement *node);
00107 std::string getInlineRightComment(NEDElement *node);
00108 std::string getTrailingComment(NEDElement *node);
00110
00113 void doFiles(FilesElement *node, const char *indent, bool islast, const char *);
00114 void doNedFile(NedFileElement *node, const char *indent, bool islast, const char *);
00115 void doPackage(PackageElement *node, const char *indent, bool islast, const char *);
00116 void doImport(ImportElement *node, const char *indent, bool islast, const char *);
00117 void doPropertyDecl(PropertyDeclElement *node, const char *indent, bool islast, const char *);
00118 void doExtends(ExtendsElement *node, const char *indent, bool islast, const char *);
00119 void doInterfaceName(InterfaceNameElement *node, const char *indent, bool islast, const char *);
00120 void doSimpleModule(SimpleModuleElement *node, const char *indent, bool islast, const char *);
00121 void doModuleInterface(ModuleInterfaceElement *node, const char *indent, bool islast, const char *);
00122 void doCompoundModule(CompoundModuleElement *node, const char *indent, bool islast, const char *);
00123 void doChannelInterface(ChannelInterfaceElement *node, const char *indent, bool islast, const char *);
00124 void doChannel(ChannelElement *node, const char *indent, bool islast, const char *);
00125 void doParameters(ParametersElement *node, const char *indent, bool islast, const char *);
00126 void doParam(ParamElement *node, const char *indent, bool islast, const char *);
00127 void doProperty(PropertyElement *node, const char *indent, bool islast, const char *);
00128 void doPropertyKey(PropertyKeyElement *node, const char *indent, bool islast, const char *);
00129 void doGates(GatesElement *node, const char *indent, bool islast, const char *);
00130 void doGate(GateElement *node, const char *indent, bool islast, const char *);
00131 void doTypes(TypesElement *node, const char *indent, bool islast, const char *);
00132 void doSubmodules(SubmodulesElement *node, const char *indent, bool islast, const char *);
00133 void doSubmodule(SubmoduleElement *node, const char *indent, bool islast, const char *);
00134 void doConnections(ConnectionsElement *node, const char *indent, bool islast, const char *);
00135 void doConnection(ConnectionElement *node, const char *indent, bool islast, const char *);
00136 void doConnectionGroup(ConnectionGroupElement *node, const char *indent, bool islast, const char *);
00137 void doLoop(LoopElement *node, const char *indent, bool islast, const char *);
00138 void doCondition(ConditionElement *node, const char *indent, bool islast, const char *);
00139 void printConnectionGate(NEDElement *conn, const char *modname, const char *modindexattr,
00140 const char *gatename, const char *gateindexattr, bool isplusplus,
00141 int gatesubg, const char *indent);
00142
00143
00144 void doExpression(ExpressionElement *node, const char *indent, bool islast, const char *);
00145 int getOperatorPrecedence(const char *op, int args);
00146 bool isOperatorLeftAssoc(const char *op);
00147 void doOperator(OperatorElement *node, const char *indent, bool islast, const char *);
00148 void doFunction(FunctionElement *node, const char *indent, bool islast, const char *);
00149 void doIdent(IdentElement *node, const char *indent, bool islast, const char *);
00150 void doLiteral(LiteralElement *node, const char *indent, bool islast, const char *);
00151
00152
00153 void doMsgFile(MsgFileElement *node, const char *indent, bool islast, const char *);
00154 void doNamespace(NamespaceElement *node, const char *indent, bool islast, const char *);
00155 void doCplusplus(CplusplusElement *node, const char *indent, bool islast, const char *);
00156 void doStructDecl(StructDeclElement *node, const char *indent, bool islast, const char *);
00157 void doClassDecl(ClassDeclElement *node, const char *indent, bool islast, const char *);
00158 void doMessageDecl(MessageDeclElement *node, const char *indent, bool islast, const char *);
00159 void doPacketDecl(PacketDeclElement *node, const char *indent, bool islast, const char *);
00160 void doEnumDecl(EnumDeclElement *node, const char *indent, bool islast, const char *);
00161 void doEnum(EnumElement *node, const char *indent, bool islast, const char *);
00162 void doEnumFields(EnumFieldsElement *node, const char *indent, bool islast, const char *);
00163 void doEnumField(EnumFieldElement *node, const char *indent, bool islast, const char *);
00164 void doMessage(MessageElement *node, const char *indent, bool islast, const char *);
00165 void doPacket(PacketElement *node, const char *indent, bool islast, const char *);
00166 void doClass(ClassElement *node, const char *indent, bool islast, const char *);
00167 void doStruct(StructElement *node, const char *indent, bool islast, const char *);
00168 void doField(FieldElement *node, const char *indent, bool islast, const char *);
00169 void doComment(CommentElement *node, const char *indent, bool islast, const char *);
00171 };
00172
00173 NAMESPACE_END
00174
00175
00176 #endif
00177
00178