clibArray - Create MATLAB clib array for C++ library functions - MATLAB (original) (raw)
Create MATLAB clib array for C++ library functions
Since R2020a
Syntax
Description
cArray = clibArray([elementTypeName](#mw%5F455e75e4-93b3-485f-a76c-0ffd7ee1faa8),[dimensions](#mw%5F14c01e7a-63ec-43ea-81cd-8a750d890952))
creates a clib array, a MATLAB® object representing a C++ object of elementTypeName
with C++ dimensions specified as [x1,...,xN]
. If the C++ object is a primitive type, then cArray
contains zero values. If the C++ object is a class-type, then MATLAB initializes cArray
using the default constructor.
A MATLAB clib array can be defined only when the corresponding C++ native array orstd::vector
is used by supported C++ constructs — function arguments, function returns, and data members.
Alternatively, if the element type is a fundamental type, a user-defined class with a default constructor, or a standard string type, call the clib.array
constructor. For example, for elementTypeName
defined inlibname
:
cArray = clib.array.libname
.elementTypeName
(dimensions
)
The memory of cArray
is owned by MATLAB. To release the memory, call clibRelease.
To convert a MATLAB array to a C++ array, call clibConvertArray.
Examples
Create MATLAB Array of C++ Objects
Suppose that you have a library libname
with a class myclass
.
Create an empty array of five myclass
objects.
myclassArray = clibArray('clib.libname.myclass',5); class(myclassArray)
ans = 'clib.array.libname.myclass'
Input Arguments
elementTypeName
— C++ type
string | character vector
C++ type, specified as a string or a character vector. For more information, see C++ to MATLAB Data Type Mapping. Supported types are:
- Floating point types described in the Floating Point Types table for
std::vector<T>
floating point types. - Integer types described in the Scalar Integer Types and Vector Integer Types tables.
- Character types described in the std::vector String Types table.
- Boolean types described in the bool Types table for
std::vector<T> bool Type
. - User-Defined Types table.
MATLAB converts the names of fundamental C++ types to upper camel case. For example, elementTypeName
for C++ type signed int
is SignedInt
.
The type is a fully qualified C++ type name. For example, if a library libname
defines a class myclass
, then elementTypeName
is clib.libname.myclass
.
Example: clib.libname.Double
Data Types: char
| string
dimensions
— Number of elements in each dimension
integer
The number of elements in each dimension of the array, specified as integers[x1,...,xN]
.
Example: [2,3]
Version History
Introduced in R2020a