Code Templates
Use code generation templates to add custom code banners, rearrange data and functions, and insert additional code segments and documentation into generated code files.
Topics
- Customize Code Organization and Format
Custom file processing (CFP) tools allow you to customize the organization and formatting of generated code.
- Code Generation Template (CGT) Files
Code Generation Template (CGT) files define the top-level organization and formatting of generated source code and header files.
- Custom File Processing (CFP) Templates
A custom file processing (CFP) template imposes a simple structure on the code generation process.
- Specify Templates For Code Generation
Create CGT files and CFP templates to use custom file processing features.
- Generate Custom File and Function Banners
Using code generation template (CGT) files, you can specify custom file banners and function banners for the generated code files.
- Change the Organization of a Generated File
Use data and code templates to change the organization of generated files.
- Customize Generated File Names
Customize generated file names by using file naming rules.
- Generate Source and Header Files with a Custom File Processing (CFP) Template
This example shows you the process of generating a simple source (
.c
or.cpp
) and header (.h
) file using the example CFP template. - Comparison of a Template and Its Generated File
You can use a template to define what code the code generator adds to the generated file, control the location of code in the file, and optionally insert comments in the generated file.
- Code Template API Summary
The code template API includes functions to obtain the names of the standard model files and other model-related information.
- Template Symbols and Rules
This topic describes template symbols and rules for using them.