主要内容

findProperty

R2026b

Find property in C++ class

Since R2026b

    Description

    propDef = findProperty(classDef,CPPName) finds a property in the specified class that matches the specified name and returns a clibgen.api.PropertyDefinition object for the matching property. If the function does not find a match, it returns an empty PropertyDefinition object.

    example

    Examples

    collapse all

    Find the centerX property and assign it to a MATLAB variable.

    Configure the interface for a library defined by shapelib.hpp and create an interface definition object.

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

    Display information about the properties of the Shape class.

    clsDef = idef.findClass("geometry::Shape");
    clsDef.Properties
    ans = 
      1×4 PropertyDefinition array with properties:
    
        CPPName
        CPPType
        MATLABType
        Size
        Status
        Included
    
      Display as table
    

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

           CPPName         CPPType               MATLABType               Status      Included
        ______________    __________    ____________________________    __________    ________
    
        "vertexBuffer"    "double *"    "clib.array.shapelib.Double"    Incomplete     false  
        "vertexCount"     "int"         "int32"                         Complete       true   
        "centerX"         "double"      "double"                        Complete       true   
        "centerY"         "double"      "double"                        Complete       true   
    

    Create a variable for the centerX property.

    propDef = clsDef.findProperty("centerX")
    propDef = 
      PropertyDefinition with properties:
    
           CPPName: "centerX"
           CPPType: "double"
        MATLABType: "double"
              Size: 1
            Status: Complete
          Included: true
    
      Show all properties
    

    Input Arguments

    collapse all

    Class definition, specified as a clibgen.api.ClassDefinition object.

    C++ property name, specified as a string scalar.

    Output Arguments

    collapse all

    Property definition, returned as a clibgen.api.PropertyDefinition object.

    Version History

    Introduced in R2026b