I want to generate C++ code by xpand. I am a beginner.
How can I generate properly?
I executed workflow as the following procedure.
1.I created the sample project and modified the model.
2.I modified template(.xpt).
3.I ran as the workflow "MWE".
In the src-gen folder, there are C++ files after execution.
But these files only includes properties and getter, setter methods.
I defined "eoperation" in the model.
Can I implement the eoperation?
( and change the arguments or return?)
i don't know what this question has to do with the target language (in your case c++) at all. the problem is the same generating java, c++, lisp or even a fairy tail book.
You wrote that you defined a "eoperation" in the model, but this does not make sense to me.
it might be that you defined it in the metamodel, but this is not what you need.
have a look what a operation (i guess you want to generate methods - signatures) is: A Operation is a "Thing" that has a name, a returntype and a list of Parameters.
So you have to extend your metamodel to allow you to define = model your operations in the model.
«DEFINE javaClass FOR Entity»
«FILE name+".java"»
public class «name» {
«FOREACH operations AS o»
public «o.returnType.name» «o.name» («FOREACH o.params AS p SEPARATOR ","»«p.type.name» «p.name»«ENDFOREACH») {
return null;
}
«ENDFOREACH»
}
«ENDFILE»
«ENDDEFINE»
For the (manual) implementation of the method body there different possibilities (generation gap pattern / protected regions)
in addition to Christian: Xpand is not a ready to use generator to generate Java or C++ code. It is a generator framework for building custom generators. So you have to define the templates you need by yourself or you can modify/customize other C++ generators build with Xpand.