← Back to ClassCreator

Creating Templates for ClassCreator

In this documentation the template creation for Car4Tegra ClassCreator will be explained.

Table of Contents

Overview

A ClassCreator template can consist of these four files:

In the following sections the XML Configuration file and the available tokens for the template files will be described in detail.

XML Configuration File

The XML configuration file contains all information about the template. The parent node ist shown below:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<template name="" headerfile="" sourcefile="" cmakefile="" classNameProperty="" sysPathVar=""> 

   <!-- Insert nodes here -->
   
</template>

Some of the attributes of the parent node are optional and could be omitted if not neccessary:

There are five different node types:

Node filepath

There has to be a filepath node for each template file used (header / source / CMake). The nodes for unused template files could be omitted.

<filepath file="header" path="\header" />
<filepath file="source" path="\source" />
<filepath file="cmake"  path="\cmake" />
<filepath file="header" path="$HEADER_PATH$$@USE_SUB_DIR$\$SUB_DIRECTORY$$USE_SUB_DIR@$" />

Node directory

The directory node allows to create directories, also if there is no file inside.

<directory path="/templates" />
<directory path="/modules/$MODULE_NAME_L$/source" />

Node property

The property nodes represent the settings for this template. From this nodes the tokens for template parsing are created (see token section below). There are three types of property nodes:

<property name="" identifier="" type="bool"       default=""           info="" group="" />
<property name="" identifier="" type="string"     default="" format="" info="" group="" />
<property name="" identifier="" type="stringlist" default="" values="" info="" group="" />

Node filepathproperty

The filepathproperty node is the same as the property node above but it is highlighted in green in the property browser of the GUI. It should be used for properties which only have an impact on filepath templates but not on the content of the template files.

<filepathproperty name="" identifier="" type="bool"       default=""           info="" group="" />
<filepathproperty name="" identifier="" type="string"     default="" format="" info="" group="" />
<filepathproperty name="" identifier="" type="stringlist" default="" values="" info="" group="" />

Node postprocessing

The postprocessing node is not tested yet!!!
The postprocessing node allows to run commands after file generation. They are selectable in the property browser of the GUI (highlighted in red).

<postprocessing name="Auto CMake" command="cmake" params="param1 param2 param3" info="Runs cmake for project after generate." />

Tokens

There are two different tokens: Text tokens (string / stringlist properties) and block tokens (bool properties):

Text Tokens

Text tokens (for string / stringlist type properties) are represented by $IDENTIFIER$ as shown below:

class $CLASS_NAME$
{
   // Constructor
   $CLASS_NAME$();
   
   // Destructor
   ~$CLASS_NAME$();
}

There is also generated automatically an $IDENTIFIER_U$ for upper case and an $IDENTIFIER_L$ for lower case for each text token.

Block Tokens

A block token (for bool type properties) starts with an $\@IDENTIFIER$ token and ends with an $IDENTIFIER\@$ token. The code between this two tokens will be removed if IDENTIFIER is FALSE.

class $CLASS_NAME$
{
   // Constructor
   $CLASS_NAME$();
      
   $@HAS_DESTRUCTOR$
   // Destructor
   ~$CLASS_NAME$();
   $HAS_DESTRUCTOR@$
}

There is also generated automatically a negated pair of tokens $\@!IDENTIFIER$ and $!IDENTIFIER\@$ (note the ! sign).

Global Tokens

Beside the tokens generated by the properties specified in the XML configuration file, there are a few other global tokens which are influenced by the user settings:

Note:
The $IFNDEF_MACRO$ / $INDT$ / $SUB_INDT$ tokens are searching for HAS_NAMESPACE / HAS_SUBNAMESPACE / NAMESPACE / SUB_NAMESPACE identifiers during parsing. To use these tokens, you have to add properties with these identifiers to your configuration XML. For the $IFNDEF_MACRO$ token, the HAS_NAMESPACE / HAS_SUBNAMESPACE identifiers are optional.