Contenido principal

clibgen.api.EnumDefinition

R2026b

MATLAB definition for C++ enumeration

Since R2026b

    Description

    A clibgen.api.EnumDefinition object represents the MATLAB® definition of a C++ enumeration.

    Creation

    enumDef = idef.Enums creates an enumeration definition object from the Enums property of a clibgen.api.InterfaceDefinition object.

    Properties

    expand all

    This property is read-only.

    Fully qualified C++ enumeration name, represented as a string scalar.

    MATLAB name of the C++ enumeration, specified as a string scalar.

    This property is read-only.

    Array of enumerations, represented as a string vector.

    Whether this construct is included in the interface, specified as a numeric or logical 1 (true) or 0 (false).

    Doxygen @brief comments for the enumeration, specified as a string scalar. The default text is:

    MATLABName    Representation of C++ enumeration CPPName.
    

    You can modify the description in the EnumDefinition object.

    Doxygen @details comments for the enumeration from the header file, specified as a string scalar. If the C++ file does not contain a comment about the enumeration, then DetailedDescription is empty and does not appear in the definition file.

    If DetailedDescription is not empty, then the MATLAB doc command displays the following sentence before displaying the value of DetailedDescription:

    This content is from the external library documentation.

    Use the DetailedDescription property to provide more information about the interface definition file.

    Examples

    collapse all

    Use clibgen.api.EnumDefinition objects to inspect, rename, and exclude C++ enumerations from a MATLAB interface.

    Configure the interface for a library defined by colorlib.hpp.

    icfg = clibgen.api.InterfaceConfiguration("colorlib",HeaderFiles="colorlib.hpp");
    idef = clibgen.api.InterfaceDefinition(icfg);

    Use the InterfaceDefinition.Enums object to list all of the enumeration definitions.

    idef.Enums
    ans = 
    
      1×3 EnumDefinition array with properties:
    
        CPPName
        MATLABName
        Included
    
      Display as table

    If there are multiple enumerations, click the Display as table link.

    idef.Enums
               CPPName                       MATLABName                Included
        _____________________    __________________________________    ________
    
        "graphics::Color"        "clib.colorlib.graphics.Color"         true   
        "graphics::LineStyle"    "clib.colorlib.LineStyle"              true   
        "graphics::BlendMode"    "clib.colorlib.graphics.BlendMode"     true   
    

    The EnumDefinition object exposes C++ and MATLAB metadata.

    enumDef = idef.findEnum("graphics::Color")
    enumDef = 
    
      EnumDefinition with properties:
    
           CPPName: "graphics::Color"
        MATLABName: "clib.colorlib.graphics.Color"
          Included: true
    
      Show all properties

    To change the MATLAB-visible name for enumDef, set MATLABName.

    enumDef = idef.findEnum("graphics::LineStyle");
    enumDef.MATLABName = "clib.colorlib.LineStyle"
    enumDef = 
    
      EnumDefinition with properties:
    
           CPPName: "graphics::LineStyle"
        MATLABName: "clib.colorlib.LineStyle"
          Included: true
    
      Show all properties
    

    To exclude the enumeration, set Included to false.

    enumDef = idef.findEnum("graphics::BlendMode");
    enumDef.Included = false;
    enumDef
    enumDef = 
    
      EnumDefinition with properties:
    
           CPPName: "graphics::BlendMode"
        MATLABName: "clib.colorlib.graphics.BlendMode"
          Included: false
    
      Show all properties

    Version History

    Introduced in R2026b