Resources | Resources |



IDL rout parameter of a method in C++

Assuming that the name of the declarator is dcl, the mapping is as follows:

  • string is mapped as:
    char* dcl, int dclLen, int* dclLenReq
  • wstring is mapped as:
    _wchar_t* dcl, int dclLen, int* dclLenReq

The caller must provide a valid buffer, dcl, which can hold up to dclLen characters (including the null terminator). However, when dclLen is 0, dcl may be NULL. Upon successful return, dclLenReq will indicate the number of characters, including the null terminator, which would have been required to store the entire result. If, upon successful return, dclLenReq is less than or equal to dclLen, then dcl contains the entire result; otherwise, dcl contains the truncated result (i.e., the first dclLen-1 characters plus a null terminator). On successful return, the returned string dcl will always be null terminated. As with rout sequences, the dclLenReq parameter for rout strings may be NULL.

The following is an example of a rout string.

interface IFoo
  long process(rout string name);

is mapped as:

struct IFoo
  virtual int process(char* name, 
   int nameLen,
   int* nameLenReq) = 0;

Note: For both types, the length parameters refer to the length of the buffer in characters (one-byte chars for strings, and two-byte _wchar_ts for wstrings), not the length of the string. The lengths are inclusive of a null terminator.