Main Content

findEnum

R2026b

Find enumeration in C++ library

Since R2026b

    Description

    enumDef = findEnum(idef,CPPName) finds an enumeration in the specified interface definition that matches a fully qualified C++ enumeration name and returns a clibgen.api.EnumDefinition object for the matching enumeration. If the function does not find a match, it returns an empty EnumDefinition object.

    example

    Examples

    collapse all

    Find enumeration sensors::DeviceStatus in an interface definition, then exclude it from the generated MATLAB interface.

    Configure the interface for a library defined by header file sensors_status.hpp and create an interface definition.

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

    Use findEnum to locate the enumeration by its fully qualified C++ name.

    enumDef = findEnum(idef,"sensors::DeviceStatus")
    enumDef = 
      EnumDefinition with properties:
    
           CPPName: "sensors::DeviceStatus"
        MATLABName: "clib.sensors.sensors.DeviceStatus"
          Included: true
    
      Show all properties
    

    Exclude the enumeration from the MATLAB interface so it is not available to users.

    enumDef.Included = false;
    enumDef
    enumDef = 
      EnumDefinition with properties:
    
           CPPName: "sensors::DeviceStatus"
        MATLABName: "clib.sensors.sensors.DeviceStatus"
          Included: false
    
      Show all properties
    

    Input Arguments

    collapse all

    Interface definition, specified as a clibgen.api.InterfaceDefinition object.

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

    Output Arguments

    collapse all

    Enumeration definition, returned as a clibgen.api.EnumDefinition object that represents the matching enumeration in idef. If the function does not find a match, it returns an empty EnumDefinition object.

    Version History

    Introduced in R2026b