Resources | Resources |



IDL inrout parameter of a method in C++

When a sequence is specified as an inrout parameter of a method of an interface, the mapping generates three arguments (assuming the name of the declarator is dcl):

T* dcl, int dclLen, int* dclLenReq 

The dclLen argument specifies the total number of elements in the array dcl, which also indicates the maximum number of elements that may be returned. Other than the requirement that the caller must provide a valid array dcl of dclLen elements, the mapping and associated semantics for sequences type in inrout parameters is the same as for rout parameters (see Broken Link for details).

Note: dcl can be NULL if dclLen is 0.

The following table summarizes the semantics for an inrout sequence dcl.

Parameter Direction Semantics
dcl Passed by caller Array data
dclLen Passed by caller Number of elements in the array dcl, which is also the maximum number of elements that may be returned by the callee
*dclLenReq Passed by caller Undefined *dclLenReq is a pure rout parameter
dclLen Returned by callee Not applicable dclLen is a pure in parameter
*dclLenReq Returned by callee Number of elements required to store the entire result; number of elements that could have been returned if the array provided by the caller had been large enough

As with rout sequences, the number of elements returned is the lesser of dclLen and *dclLenReq.

An example of an inrout sequence is shown below.

typedef sequence<long> seqlong;

interface IFoo
  long process(inrout seqlong sums);

is mapped as:

// __seq_int details omitted

struct IFoo
  virtual int process (int* sums, 
   int sumsLen,
   int* sumsLenReq) = 0;