Contenido principal

clibgen.api.InputArgumentDefinition

R2026b

MATLAB definition for input argument in C++ function or method

Since R2026b

    Description

    A clibgen.api.InputArgumentDefinition object represents the MATLAB® definition of an input parameter to a C++ function or method.

    Creation

    inArgs = ctor.CPPInputs creates an inputs definition object from the CPPInputs property of a clibgen.api.ConstructorDefinition object.

    inArgs = fcn.CPPInputs creates an inputs definition object from the CPPInputs property of a clibgen.api.FunctionDefinition object.

    inArgs = methDef.CPPInputs creates an inputs definition object from the CPPInputs property of a clibgen.api.MethodDefinition object.

    Properties

    expand all

    This property is read-only.

    C++ parameter name, represented as a string scalar.

    This property is read-only.

    Argument position in the function signature, represented as an integer.

    This property is read-only.

    C++ parameter type, represented as a string scalar.

    Data type for the argument in MATLAB, specified as a string scalar.

    How the input argument is used, specified as one of these values:

    • "input" — Input argument only

      If a pointer argument is used to pass data to the function, then it appears as an input argument in the MATLAB signature.

      The Direction value for C-string parameters must be "input".

    • "output" — Output argument only

      If a pointer argument is used to retrieve data from the function, then it must appear as an output argument in the MATLAB signature.

    • "inputoutput" — Input and output argument

      If a pointer argument is used to both pass and return data, then it must appear as both an input argument and an output argument.

    For more information, see Define Missing Direction Property.

    Dimensions of the array data, specified as a numeric vector, string vector, cell array, or "nullTerminated". MATLAB uses this value to determine the number of elements in the MATLAB data that can be allowed as input to a C++ pointer argument. For example:

    • If Size = 1, only inputs with one element are allowed.

    • If Size = 5, only an input vector with five elements is allowed.

    • If Size = "len", an input vector with any number of elements is allowed. MATLAB determines the actual number of elements from the inputs when calling the function and passes it to the C++ function using the "len" parameter.

    • If Size = ["m","n"], only a 2-D matrix input is allowed, but any number of elements are allowed for each dimension. MATLAB determines the actual number of elements from the inputs when calling the function and is passes them to the C++ function using the "m" and "n" parameters.

    • If Size = "nullTerminated", only a MATLAB string is allowed.

    This property is read-only.

    Whether the argument requires additional definition, represented as Complete or Incomplete.

    Doxygen @brief comments for the argument from the header file, specified as a string scalar. You can modify the description in this InputArgumentDefinition object.

    Object Functions

    defineDefine input argument in C++ library function or method

    Examples

    collapse all

    To get argument information for calling a function, use the CPPInputs and CPPOutput properties.

    The add function adds two double values and returns the result.

    double add(double value1, double value2);

    Publish an interface MathLibrary containing add.

    fcn = findFunction(def,"add")
    fcn = 
      FunctionDefinition with properties:
    
                CPPName: "add"
             MATLABName: "clib.MathLibrary.add"
             Overloaded: false
           CPPSignature: "double add(double value1,double value2)"
        MATLABSignature: RetVal = clib.MathLibrary.add(value1, value2)
              CPPInputs: [1×2 clibgen.api.InputArgumentDefinition]
              CPPOutput: [1×1 clibgen.api.OutputArgumentDefinition]
                 Status: Complete
               Included: true
    
      Show all properties
    

    There are two input arguments.

    fcn.CPPInputs
    ans = 
      1×2 InputArgumentDefinition array with properties:
    
        Name
        Position
        CPPType
        MATLABType
        Direction
        Size
        Status
    
      Display as table
    

    Click the Display as table link.

    Name      Position    CPPType     MATLABType     Status 
    ________    ________    ________    __________    ________
    
    "value1"       1        "double"     "double"     Complete
    "value2"       2        "double"     "double"     Complete
    

    There is one output argument.

    fcn.CPPOutput
    ans = 
      OutputArgumentDefinition with properties:
    
              Name: "RetVal"
           CPPType: "double"
        MATLABType: "double"
              Size: 1
            Status: Complete
    

    Each argument is fully defined:

    • C++ double maps directly to MATLAB double.

    • Each argument is scalar (Size=1).

    • Each input argument is input-only (Direction = "input").

    Display the MATLABType, Size, and Direction properties in a table.

    % Variable data for Argument
    n1 = fcn.CPPInputs(1).Name;
    n2 = fcn.CPPInputs(2).Name;
    n3 = fcn.CPPOutput.Name;
    Argument = [n1; n2; n3];
    % Variable data for MATLABType
    t1 = fcn.CPPInputs(1).MATLABType;
    t2 = fcn.CPPInputs(2).MATLABType;
    t3 = fcn.CPPOutput.MATLABType;
    MATLABType = [t1; t2; t3];
    % Variable data for Size
    s1 = fcn.CPPInputs(1).Size;
    s2 = fcn.CPPInputs(2).Size;
    s3 = fcn.CPPOutput.Size;
    Size = [s1; s2; s3];
    % Variable data for Direction
    d1 = fcn.CPPInputs(1).Direction;
    d2 = fcn.CPPInputs(2).Direction;
    d3 = "n/a";
    Direction = [d1; d2; d3];
    T = table(Argument,MATLABType,Size,Direction)
    T = 
        Argument    MATLABType    Size    Direction
        ________    __________    ____    _________
    
        "value1"     "double"      1       "input" 
        "value2"     "double"      1       "input" 
        "RetVal"     "double"      1       "n/a"   
    
    

    In MATLAB, call clib.MathLibrary.add with a two double input arguments.

    fcn.MATLABSignature
    ans = 
        "MATLAB signature for FunctionDefinition
         	Maps C++ signature:
         	double add(double value1,double value2)
         
         	to MATLAB as:
         	RetVal = clib.MathLibrary.add(value1, value2)
         		Input Arguments
         			value1  double
         			value2  double
         		Output Arguments
         			RetVal  double
         "
    

    Version History

    Introduced in R2026b