Code Generation: C++

Overview

This sample generates a basic C++ source file for each Class of an UML input model. The sample generates:

Launch configuration

 
Ruleset com.sodius.mdw.samples.cpp.CppGeneration
Rule main
Arguments a UML input model (e.g. models/product13.xmi)

Here is an example of a UML 1.3 based C++ generation launch:

Features demonstrated

Feature Example Location Reference
Calling a text template from a rule $GenerateH(class) CppGeneration.mqr template call
Including a text template from another text template [#include ClassDoc(class)] GenerateH.tgt include
Trimming to avoid blank lines ${attribute.declaration}[#trim] uml13_Class.tgs trim
Filtering a list of instances based on a criterium self.parameter.reject("kind", RETURN_LITERAL) uml13_Operation.mqs MDWList
Specifying a default value self.returnType.csharpType ? "void" uml13_Operation.mqs default value
Using protected sections to preserve user code [#protectedStartTag] uml13_Operation.mqs protected tags