Coding Style Configuration (DATAFLOW Code)
This Reference Article has been written for Version 2.1 of the DATAFLOW Software. For Previous Releases use the version selection in the navigation bar at the top of this page.
This Tab is part of Build Configuration Page in the Project Settings dialog.
Tab Description
The Coding Style Page in the Build Configuration is used to configure the generate code so that it fits a variety of different coding styles. These settings are language independent, but not all may be applicable to a certain target language.
See the C++ Code Generation article for an overview on code generation.
Tab Actions
In addition, a reset button is provided. This will reset all style configuration to the default settings if clicked.
This button sets all coding style configuration settings to the default value. |
Tab Groups
The page shows the following groups in Advanced mode:
- Whitespaces
- Indent Levels (A)
- Padding (A)
For each group, if an option is only shown in advanced mode, it will be marked with (A).
Whitespaces Group
The used white spaces and line breaks can be defined for the generated code:
Brace Style |
This field defines the brace style for all generated code. Available options are:
|
Indent with Tabs |
When this field is checked, all generated indents will use tabs instead of spaces. |
Number of Indents |
This field defines the number of spaces (or tabs) used for a single indent. |
Line Endings |
This field defines the line ending format (UNIX or Windows) used for all generated code files. |
Newline after Constructor Initializer |
Adds a newline after the constructor initializer and befor the opening brace for C++ source code files with a class constructor. |
Brace style
Defines when line breaks are inserted into the generated code in relation to braces.
KR Brace StyleIn KR Brace style, all opening braces are placed on the same line.
|
Allman Brace StyleIn Allman Brace style, all opening braces are placed on a new line.
|
IMT Brace StyleIn IMT Brace style, all opening braces are placed on the same line.
|
Indents
Defines if indention is performed with tabs or spaces. It is also possible to adjust the number of tabs or spaces used for a single indent.
Indent with tabsExample with 2 tabs per indent: |
Indent with spacesExample with 4 spaces per indent: |
Line Endings
The line endings can be configured to use windows or unit style line endings. Generated code files will always end with a newline to avoid issues with command line based tools. Windows Line EndingsFor Windows line endings, an CR followed by an LF character is used: |
Unix Line EndingsFor Unix line endings, an LF character is used: |
Indent Levels Group (A)
The number of indents (see white spaces for the configuration of a singe indent) can be defined for various elements of the generated code:
Namespace Contents (A) |
The indent level indicates how many indent levels are added for a certain code section. Each indent level is equal to the number of white spaces configured above. |
Class Contents (A) |
The indent level indicates how many indent levels are added for a certain code section. Each indent level is equal to the number of white spaces configured above. |
Other Block Contents (A) |
The indent level indicates how many indent levels are added for a certain code section. Each indent level is equal to the number of white spaces configured above. |
Braces (A) |
The indent level indicates how many indent levels are added for a certain code section. Each indent level is equal to the number of white spaces configured above. |
Access Specifiers (A) |
The indent level indicates how many indent levels are added for a certain code section. Each indent level is equal to the number of white spaces configured above. |
Case Labels (A) |
The indent level indicates how many indent levels are added for a certain code section. Each indent level is equal to the number of white spaces configured above. |
Case Contents (A) |
The indent level indicates how many indent levels are added for a certain code section. Each indent level is equal to the number of white spaces configured above. |
Initializer Lists (A) |
The indent level indicates how many indent levels are added for a certain code section. Each indent level is equal to the number of white spaces configured above. |
Namespace Content IndentIndents namespace contents by the given number of levels in relation to the parent block. Example for C++ with indent of 2 spaces: // level 0
|
Class Content IndentIndents class contents by the given number of levels in relation to the parent block. Example for C++ with indent of 2 spaces: // level 0
|
Other Block IndentIndents blocks contents that are neither a class or namspace (e.g. function, if, else, ...) by the given number of levels in relation to the parent block. Example for C++ with indent of 2 spaces: // level 0
|
Brace IndentIndents braces by the given number of levels in relation to the parent block. Example with indent of 2 spaces and allman style: // level 0
|
Access Specifier IndentIndents c++ access specifiers in classes by the given number of levels in relation to the class contents. Example with indent of 2 spaces: // level 0
|
Case Label IndentIndents case labels in switch case blocks by the given number of levels in relation to the switch contents. Example with indent of 2 spaces: // level 0
|
Case Content IndentIndents case contents in switch case blocks by the given number of levels in relation to the switch contents. Example with indent of 2 spaces: // level 0
|
Padding Group (A)
The placement of white spaces before and after certain symbols in the generated code can be configured as well.
Braces (A) |
Defines the padding for the given code symbol. Padding adds spaces before and/or after the symbol. For lists, adding a space before, in between and after arguments can also be enabled. The code generator will merge multiple spaces into one, e.g. when there is a space after an open parentheses and one before the first argument. |
Brackets (A) |
Defines the padding for the given code symbol. Padding adds spaces before and/or after the symbol. For lists, adding a space before, in between and after arguments can also be enabled. |
Parentheses (A) |
Defines the padding for the given code symbol. Padding adds spaces before and/or after the symbol. For lists, adding a space before, in between and after arguments can also be enabled. |
Angle Brackets (A) |
Defines the padding for the given code symbol. Padding adds spaces before and/or after the symbol. For lists, adding a space before, in between and after arguments can also be enabled. |
Initializers (A) |
Defines the padding for the given code symbol. Padding adds spaces before and/or after the symbol. For lists, adding a space before, in between and after arguments can also be enabled. |
Operators (A) |
Defines the padding for the given code symbol. Padding adds spaces before and/or after the symbol. |
Keywords (A) |
Defines the padding for the given code symbol. Padding adds spaces before and/or after the symbol. |
Align Enumerators (A) |
Adds additional spaces to align all enumeration values on the same column. |
Align Identifiers (A) |
Adds additional spaces to align all identifier values on the same column. |
The code generator will not generate multiple spaces in a row (except for indentations, see above). If two required padding spaces intersect, they are merged to a single space. The generator will also avoid trailing white-spaces (white-spaces at the end of a line followed by a newline) and white-spaces before a semicolon.
Brace PaddingAdds spaces before and after braces: if(a){c();}; // no brace padding Before argument and after argument have no effect. C++ Initializers use the specific style below and ignore this style.
|
Bracket PaddingAdd spaces before and after brackets: int a[2]; // no bracket padding When a bracket contains coma seperated arguments, spaces are added before and after the coma: int a[2,3,4]; // no bracket padding
|
Parenthese PaddingAdd spaces before and after parentheses: void a(int a){ // no parenthese padding When a parenthese contains coma seperated arguments, spaces are added before and after the coma: void a(int a,bool b,float c){ // no parenthese padding
|
Initializer PaddingAdd spaces before and after braces in C++ initializer: int a={1}; // no initializer padding When a parentheses contains coma separated argument, spaces are added before and after the coma: int a[]={1,2,3}; // no initializer padding
|
Operator PaddingAdd spaces before and after operators: int a=b+c; // no operator padding
|
Keyword PaddingAdd spaces before and after keywords: }else if(a){ // no keyword padding |
Required Module: DATAFLOW Code
This Article has been written based on V1.6.1 of the DATAFLOW Designer software.
Latest update 2021-10-15 by WAA.
Comments
0 comments
Please sign in to leave a comment.