Resources | developer.brewmp.com Resources | developer.brewmp.com

Developer

resources

IDL within a union or sequence in C++

When a string or wstring is used within a union or a sequence, it is mapped as a _cstring_t or _wstring_t. Both of these types are structures containing a pointer to a buffer, a buffer length, and a required length. This structure is the same as the structure that would be generated for a sequence<char> in the case of string, or sequence in the case of wstring. See Broken Link for details on the structure generated for each sequence.

The semantics of the additional dataLen and dataLenReq fields are the same as those for a string when it used as the member of a structure; see Broken Link for details. For example:

 typedef sequence seqstring;

union u switch(short)
{
  default:
   string s;
};

is mapped as:

// Note: this struct is only defined once, at the top of each file
struct _cstring_t
{
  char* data;
  int dataLen;
  int dataLenReq;
};

struct __seq_string
{
  _cstring_t* data;
  int dataLen;
  int dataLenReq;
};

typedef __seq_string seqstring;

struct u
{
  short int _d;
  union {
   _cstring_t s;
  } _u;
};