主要内容

clibgen.api.ClassDefinition

R2026b

MATLAB definition for C++ class or struct

Since R2026b

    Description

    A clibgen.api.ClassDefinition object represents the MATLAB® definition of a C++ class or struct. You can create a ClassDefinition object by using the findClass function. You can also create objects using the Classes and IncompleteClasses properties of an InterfaceDefinition object.

    Creation

    classDef = idef.Classes creates class definition objects from the Classes property of a clibgen.api.InterfaceDefinition object.

    classDef = idef.IncompleteClasses also creates class definition objects from the IncompleteClasses property.

    Properties

    expand all

    This property is read-only.

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

    MATLAB name for the C++ class, specified as a string scalar.

    This property is read-only.

    MATLAB definition of the class constructors, represented as a clibgen.api.ConstructorDefinition array.

    This property is read-only.

    MATLAB definition of the class methods, represented as a clibgen.api.MethodDefinition array.

    This property is read-only.

    MATLAB definition of the class properties, represented as a clibgen.api.PropertyDefinition array.

    This property is read-only.

    Constructors with input arguments that require additional definition, represented as a clibgen.api.ConstructorDefinition array.

    This property is read-only.

    Methods with input or output arguments that require additional definition, represented as a clibgen.api.MethodDefinition array.

    This property is read-only.

    Properties that require additional definition, represented as a clibgen.api.PropertyDefinition array.

    This property is read-only.

    Whether the class has a member that requires additional definition, represented as true or false.

    This property is read-only.

    Whether the class has a fully defined constructor to construct the class in MATLAB, represented as true or false.

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

    Doxygen @brief comments that describe the class for the end user, specified as a string scalar. If the header file does not contain @brief comments, the text for Description is:

    MATLABName    Representation of C++ class CPPName.

    Use the Description property to modify the description in the ClassDefinition object.

    Doxygen @details comments from the header file, specified as a string scalar. If the C++ file does not contain a comment about the class, 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.

    Object Functions

    findConstructorFind constructor in C++ class
    findMethodFind method in C++ class
    findPropertyFind property in C++ class

    Examples

    collapse all

    Configure the interface for a library defined by sensorlib.hpp and display information about its classes.

    icfg = clibgen.api.InterfaceConfiguration("sensorlib",HeaderFiles="sensorlib.hpp",IncludePath=pwd);
    idef = clibgen.api.InterfaceDefinition(icfg);
    idef.Classes
    
    ans = 
    
      1×5 ClassDefinition array with properties:
    
        CPPName
        MATLABName
        HasIncompleteMembers
        IsConstructibleInMATLAB
        Included
    
      Display as table

    If there are multiple classes, click the Display as table link to see the information.

               CPPName                       MATLABName                 HasIncompleteMembers    IsConstructibleInMATLAB    Included
        _____________________    ___________________________________    ____________________    _______________________    ________
    
        "sensor::Channel"        "clib.sensorlib.sensor.Channel"               true                      true               true   
        "sensor::Sensor"         "clib.sensorlib.sensor.Sensor"                true                      true               true   
        "sensor::Calibration"    "clib.sensorlib.sensor.Calibration"           false                     true               true   
        "sensor::Reading"        "clib.sensorlib.sensor.Reading"               false                     true               true   
        "sensor::DataLogger"     "clib.sensorlib.sensor.DataLogger"            true                      true               true   
    

    Version History

    Introduced in R2026b