Contenido principal

findFunction

R2026b

Find function in C++ library

Since R2026b

    Description

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

    example

    fcnDef = findFunction(idef,CPPName,CPPInputTypeNames=typeNames) finds a function that matches both the specified name and input type list. This syntax is useful for finding overloaded functions.

    Examples

    collapse all

    When Doxygen comments exist in the library source code, MATLAB includes them in the interface.

    Configure an interface for a library defined by mathops_rms.hpp and add more information to the description.

    headerFile = "mathops_rms.hpp";
    icfg = clibgen.api.InterfaceConfiguration("mathops",HeaderFiles=headerFile);
    idef = clibgen.api.InterfaceDefinition(icfg);

    Use findFunction to locate the function computeRMS.

    fcnDef = findFunction(idef,"computeRMS");

    Display the existing description.

    fcnDef.Description
    fcnDef.DetailedDescription
    ans = "clib.mathops.computeRMS Representation of C++ function computeRMS."
    ans = ""
    

    Because no Doxygen comments are present in the function, the interface displays the default MATLAB description.

    Add details to the description, then click Show all properties to view the updated description.

    fcnDef.DetailedDescription = "Calculate root mean square, or RMS";
    fcnDef
                   CPPName: "computeRMS"
                 MATLABName: "clib.mathops.computeRMS"
                 Overloaded: false
               CPPSignature: "double computeRMS(double * data,int len)"
            MATLABSignature: <Define incomplete inputs to see the MATLAB signature.>
                  CPPInputs: [1×2 clibgen.api.InputArgumentDefinition]
                  CPPOutput: [1×1 clibgen.api.OutputArgumentDefinition]
                     Status: Incomplete
                   Included: false
                Description: "clib.mathops.computeRMS Representation of C++ function computeRMS."
        DetailedDescription: "Calculate root mean square, or RMS"

    Input Arguments

    collapse all

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

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

    Fully qualified C++ input type names, specified as a string vector. Use this argument to disambiguate overloaded functions.

    Output Arguments

    collapse all

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

    Version History

    Introduced in R2026b