Main Content

Code Template API Summary

Code Template API Functions summarizes the code template API. See the source code in matlabroot/rtw/c/tlc/mw/codetemplatelib.tlc for detailed information on the arguments, return values, and operation of these calls.

Code Template API Functions

Function

Description

LibClearFileSectionContents

Clears a file section with custom values before writing file to disk.

LibGetNumSourceFiles

Returns the number of created source files (.c or .cpp and .h).

LibGetSourceFileTag

Returns <filename>_h and <filename>_c for header and source files, respectively, where filename is the name of the model file.

LibCreateSourceFile

Creates a new C or C++ file and returns its reference. If the file already exists, simply returns its reference.

LibGetFileRecordName

Returns a model file name (including the path) without the extension.

LibGetSourceFileFromIdx

Returns a model file reference based on its index. This is useful for a common operation on all files, such as to set the leading file banner of all files.

LibSetSourceFileSection

Adds to the contents of a specified section within a specified file (see also Custom File Processing (CFP) Template Structure).

LibIndentSourceFile

Indents a file (from within the TLC environment).

LibCallModelInitialize

Returns code for calling the model's model_initialize function (valid for ERT only).

LibCallModelStep

Returns code for calling the model's model_step function (valid for ERT only).

LibCallModelTerminate

Returns code for calling the model's model_terminate function (valid for ERT only).

LibCallSetEventForThisBaseStep

Returns code for calling the model's set events function (valid for ERT only).

LibWriteModelData

Returns data for the model (valid for ERT only).

LibSetRTModelErrorStatus

Returns the code to set the model error status.

LibGetRTModelErrorStatus

Returns the code to get the model error status.

LibIsSingleRateModel

Returns true if model is single rate and false otherwise.

LibGetModelName

Returns name of the model (without an extension).

LibGetMdlSrcBaseName

Returns the name of model's main source file (for example, model.c or .cpp).

LibGetMdlPubHdrBaseName

Returns the name of model's public header file (for example, model.h).

LibGetMdlPrvHdrBaseName

Returns the name of the model's private header file (for example, model_private.h).

LibIsSingleTasking

Returns true if the model is configured for single-tasking execution.

LibWriteModelInput

Returns the code to write to a particular root input (that is, a model inport block). (valid for ERT only).

LibWriteModelOutput

Returns the code to write to a particular root output (that is, a model outport block). (valid for ERT only).

LibWriteModelInputs

Returns the code to write to root inputs (that is, all model inport blocks). (valid for ERT only)

LibWriteModelOutputs

Returns the code to write to root outputs (that is, all model outport blocks). (valid for ERT only).

LibNumDiscreteSampleTimes

Returns the number of discrete sample times in the model.

LibSetSourceFileCodeTemplate

Set the code template to be used for generating a specified source file.

LibSetSourceFileOutputDirectory

Set the folder into which a specified source file is to be generated.

LibAddSourceFileCustomSection

Add a custom section to a source file. The custom section must be associated with one of the built-in (required) sections: Includes, Defines, Types, Enums, Definitions, Declarations, or Functions.

LibSetSourceFileCustomSection

Adds to the contents of a specified custom section within a specified file. The custom section must have been previously created with LibAddSourceFileCustomSection.