00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __NED1GENERATOR_H
00018 #define __NED1GENERATOR_H
00019
00020 #include <iostream>
00021 #include "nedelements.h"
00022 #include "nederror.h"
00023
00024 NAMESPACE_BEGIN
00025
00026
00032 NEDXML_API void generateNED1(std::ostream& out, NEDElement *node, NEDErrorStore *e);
00033
00040 class NEDXML_API NED1Generator
00041 {
00042 protected:
00043 int indentsize;
00044 std::ostream *outp;
00045 NEDErrorStore *errors;
00046
00047 public:
00051 NED1Generator(NEDErrorStore *errors);
00052
00056 ~NED1Generator();
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 std::string getDisplayStringOf(NEDElement *node, PropertyElement *&outDisplayProp);
00100 const char *getPromptTextOf(ParamElement *param);
00102
00105 std::string concatInnerComments(NEDElement *node);
00106 std::string getBannerComment(NEDElement *node, const char *indent);
00107 std::string getRightComment(NEDElement *node);
00108 std::string getInlineRightComment(NEDElement *node);
00109 std::string getTrailingComment(NEDElement *node);
00111
00114 void doNedfiles(FilesElement *node, const char *indent, bool islast, const char *);
00115 void doNedfile(NedFileElement *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 doModuleParameters(ParametersElement *node, const char *indent);
00127 void doChannelParameters(ParametersElement *node, const char *indent);
00128 void doSubstParameters(ParametersElement *node, const char *indent);
00129 void doConnectionAttributes(ParametersElement *node, const char *indent);
00130 void doParam(ParamElement *node, const char *indent, bool islast, const char *);
00131 void doModuleParam(ParamElement *node, const char *indent, bool islast, const char *);
00132 void doSubstParam(ParamElement *node, const char *indent, bool islast, const char *);
00133 void doChannelParam(ParamElement *node, const char *indent);
00134 void doProperty(PropertyElement *node, const char *indent, bool islast, const char *);
00135 void doPropertyKey(PropertyKeyElement *node, const char *indent, bool islast, const char *);
00136 void doGates(GatesElement *node, const char *indent, bool islast, const char *);
00137 void doModuleGates(GatesElement *node, const char *indent);
00138 void doSubmoduleGatesizes(GatesElement *node, const char *indent);
00139 void doGate(GateElement *node, const char *indent, bool islast, const char *);
00140 void doModuleGate(GateElement *node, const char *indent, bool islast, const char *);
00141 void doGatesize(GateElement *node, const char *indent, bool islast, const char *);
00142 void doTypes(TypesElement *node, const char *indent, bool islast, const char *);
00143 void doSubmodules(SubmodulesElement *node, const char *indent, bool islast, const char *);
00144 void doSubmodule(SubmoduleElement *node, const char *indent, bool islast, const char *);
00145 void doConnections(ConnectionsElement *node, const char *indent, bool islast, const char *);
00146 void doConnection(ConnectionElement *node, const char *indent, bool islast, const char *);
00147 void doConnectionGroup(ConnectionGroupElement *node, const char *indent, bool islast, const char *);
00148 void doLoop(LoopElement *node, const char *indent, bool islast, const char *);
00149 void doCondition(ConditionElement *node, const char *indent, bool islast, const char *);
00150 void printConnectionGate(NEDElement *conn, const char *modname, const char *modindexattr,
00151 const char *gatename, const char *gateindexattr, bool isplusplus,
00152 int gatesubg, const char *indent);
00153
00154
00155 void doExpression(ExpressionElement *node, const char *indent, bool islast, const char *);
00156 int getOperatorPrecedence(const char *op, int args);
00157 bool isOperatorLeftAssoc(const char *op);
00158 void doOperator(OperatorElement *node, const char *indent, bool islast, const char *);
00159 void doFunction(FunctionElement *node, const char *indent, bool islast, const char *);
00160 void doIdent(IdentElement *node, const char *indent, bool islast, const char *);
00161 void doLiteral(LiteralElement *node, const char *indent, bool islast, const char *);
00163 };
00164
00165 NAMESPACE_END
00166
00167
00168 #endif
00169
00170