Main Content

clibgen.EnumDefinition Class

Namespace: clibgen

Definition for MATLAB enumeration corresponding to C++ enumeration

Description

The clibgen.EnumDefinition class contains the MATLAB® definition for an enumeration defined in the C++ header.

The clibgen.EnumDefinition class is a handle class.

Creation

MATLAB constructs an EnumDefinition object when MATLAB calls addEnumeration on a clibgen.LibraryDefinition object.

Properties

expand all

Help text for the end user describing the enumeration, specified as a string or a character vector. The default text is:

MATLABName    Representation of C++ enumeration CPPName.
The publisher can modify the value of the Description property in the library definition file.

Example: clib.cppSample.COLOR Representation of C++ enumeration COLOR.

Attributes:

GetAccess
public
SetAccess
public

Help text from C++ header file for the end user describing details about the enumeration, specified as a string or a character vector. If the C++ comment does not contain detailed information, then DetailedDescription does not appear in the definition file.

The publisher can modify the value of the DetailedDescription property in the library definition file. If DetailedDescription is not empty, then the MATLAB doc command displays this sentence before displaying the value of DetailedDescription.

This content is from the external library documentation.

Attributes:

GetAccess
public
SetAccess
public

Library defining the enumeration, specified as a clibgen.LibraryDefinition object.

Example: myFonts

Attributes:

GetAccess
public
SetAccess
private

C++ enumeration name, specified as a string or a character vector. MATLAB creates CPPName from the enum class name in the header file.

Example: COLOR

Attributes:

GetAccess
public
SetAccess
private

MATLAB type for enumeration values, specified as int32.

Attributes:

GetAccess
public
SetAccess
private

Indicate if enumeration definition is complete, specified as true or false.

Attributes:

GetAccess
public
SetAccess
private

C++ enumeration name in MATLAB, specified as a string or a character vector.

Example: clib.MySpace.COLOR

Attributes:

GetAccess
public
SetAccess
private

Enumerants, specified as a struct of enumerant values and optional C++ comments from the header file describing details about the enumerant. MATLAB creates Entries from the enum class definition in the header file.

Attributes:

GetAccess
public
SetAccess
private

Tips

  • 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.

Version History

Introduced in R2019a