Package: clibgen
Definition for MATLAB enumeration corresponding to C++ enumeration
The clibgen.EnumDefinition
class contains the MATLAB® definition for an enumeration defined in the C++ header.
The clibgen.EnumDefinition
class is a handle
class.
MATLAB constructs an EnumDefinition
object when MATLAB calls addEnumeration
on a clibgen.LibraryDefinition
object.
You might need to create an enumerated value in MATLAB, but the name of that value might not be a valid MATLAB name. For example, the enumerant name might begin with an underscore. To derive a value from this name at run time, use this MATLAB syntax, where enumMember
is a string scalar or character vector that, when evaluated, returns an instance of an enumeration.
clib.libName.enumName.(enumMember)
For example, suppose that you have interface clib.enums.keywords
with these
properties:
EnumDefinition with properties: Description: "clib.enums.keywords Representation of C++ enumeration" DefiningLibrary: [1×1 clibgen.LibraryDefinition] CPPName: "keywords" MATLABType: "int32" Valid: 1 MATLABName: "clib.enums.keywords" Entries: ["_for" "_while" "_class" "_enums" "_template" "_typename"]
To assign entry _class
to a variable, type:
var = clib.enums.keywords.('_class');
This syntax is valid for names less than the maximum identifier length namelengthmax
.
To read the underlying numeric value for a C++ enumeration object created in
MATLAB, call underlyingValue
.