This example shows a library definition file created from a C++ header file.
This example header file contains C++ language constructs that need further definition from a publisher to create a MATLAB interface to the library. The class constructors and functions are C++ signatures only. There is no implementation and they are not used in any examples.
Use the corresponding definecppUseCases.mlx
file to learn how to add the functionality to the MATLAB interface.
edit(fullfile(matlabroot,"extern","examples","cpp_interface","cppUseCases.hpp"))
definecppUseCases.mlx
The definecppUseCases.mlx
library definition file is created from the cppUseCases.hpp
header file using the clibgen.generateLibraryDefinition
function. After generating the library definition file, replace <SHAPE>
, <DIRECTION>
, and <MLTYPE>
text with appropriate values so that MATLAB can create equivalent function signatures. For details about providing the information for all constructors and functions in this library, see Define MATLAB Interface for C++ Library.
edit definecppUseCases.mlx
For example, assume that the input to function addClassByPtr
is a pointer to class ns::MyClass2
. Search for this text:
double addClassByPtr(ns::MyClass2 const * myc2)
Argument myc2
is not defined for MATLAB. See this statement, which contains <SHAPE>
:
defineArgument(addClassByPtrDefinition, "myc2", "clib.cppUseCases.ns.MyClass2", "input", <SHAPE>);
To define the argument, replace <SHAPE>
with 1:
defineArgument(addClassByPtrDefinition,
"myc2"
,
"clib.cppUseCases.ns.MyClass2"
,
"input"
, 1);
Uncomment the seven lines defining the function and save the MLX file.
To find the other undefined functions, search for:
%validate