| Command |
Description |
Syntax |
| CALL |
"CALL" command is widely used to
avoid duplications in template. It
actually inserts referencing template at point of execution. Call can
be parametrized. |
Syntax1
%call<macro>Syntax2
<call>macro[<,>param1<,>param2<,>...]<endcall>where
macro - name of macro
fileparam1 - will replace variable <1> in called template, etc. Example
Main templateClass T%.name%
<for>y
attributes<begin><call>attr.mac<,> F<,>: <,>;<cr><end>Generated result Class TBankAccount
FNumber: string;
FUser: string;
FBalance: float; |
| DECODE |
"DECODE" command generates
output code based on comparison of 1st
parameter with set of alternative values. Generator compares 1st
parameter to each value one by one. If expr is equal to a value,
generator returns the corresponding result. If no match is found,
generator returns default, or, if default is omitted, returns nothing. Command syntax has two forms |
Syntax1
%decode<value:variant1:result1:variant2:result2:...:variantN:resultN:default
result>Syntax2
<decode>value<,>variant1<=>result1<,>variant2<=>result2<,>...<,>variantN<=>resultN<,>default
result<enddecode>Example
To generate correct string
conversion function use the following code
(note - generator constant <\> is used for template formating
purpose only)<decode>%.type%<,><\>
string<=>%.name%<,><\> integer<=>IntToStr(%.name%)<,><\> float<=>FltToStr(%.name%)<,><\> /*ERROR - unsupported type %.type%*/<\> <enddecode> |
| GET |
"GET" command returns single text tocken from input text delimited by specified separator. |
Syntax
<get>text<,>index<,>separator<endget>returns index token of the text string delimited by separator Example
? |
| FOR |
"FOR" is the most useful
generator command. It is widely used to browse
hierarchical structure of class model. |
Syntax
<for>variable iterator[@objname]^{boolean_expression}^divider^wrap<begin>body<endfor>
To show list of classes in a UML package use the following code <for>x classes<begin>Class %.name% <endfor> |
| IF |
Command of conditional generation "IF". | Command syntax -
element = boolean_element|simple filter boolean_element = p1 operation p2 p1, p2 - parameters operation - compare operation, can be "=", "~", "<", ">" (ignore double quote) simple_filter - can contain the next elements, always starts with "+" or "-"
|
| NVAL |
"NVAL" command allowes you to use named values. MapTool uses named values to store mapping information. |
Syntax
<nval>...<endnval>
|
| Variable
name |
Applicability |
| %.name% |
|
| %.name1% | associations |
| %.uname% |
packages and classes |
| %.version% |
packages and classes |
| %.phase% |
packages and classes |
| %.parent% |
classes |
| %.stereotype% |
classes |
| %.attrCount% | classes |
| %.allAttrCount% | classes |
| %.type% | attributes and associations |
| %.type1% | associations |
| %.iskey% | attributes |
| %.ref% |
attributes |
| %.reftarget% |
attributes |
| %.map0% | classes, attributes |
| %.mapval0% | attributes |
| %.maptype0% |
attributes |
| %.load0%, %.add0%,
%.del0% |
roles |
| %.map1% |
classes, attributes |
| %.typecode% | attributes and roles |
| %.return% | methods |
| %.const% |
parameters |
| %.dir% |
parameters |
| %.amap0% | associations (not supported yet) |
| %.index% |
can be used only inside of <FOR> body |
| %ver% |
version of generator |
| %time% | time of generation |
| %\% | "Line continuation". At the end of the line removes following "caridge return"; in any other place is ignored. |
| %cr%
|
caridge return |
| %p% | % character |
| %g%
|
> character |
| %l% | < character |
| %ct% | ^ character |
| %col% | : character |