[omniORB] RE: array in Any

Maks Verver m.verver at student.utwente.nl
Sat Jun 19 14:54:50 BST 2004


Hi Francois,

You wrote:
> I am trying to put an octet array in an Any.
> I have been told it is possible, but I don't see
> any public method in Any class to do that.

Obviously the insertion operator isn't a member of the Any class, as it
couldn't possibly include a version for every type a user may want to
insert. Insertion operators are generated for your custom types from your
IDL files. For C++ arrays there is an additional complexity, since array
operands decay to pointer to their element type (which means arrays with the
same type of element are indistinguishable, even if they have different
length or a different type name in the IDL file), so you must use the
_forany helper class to insert the array.

Assuming you have defined an array type called array_type, your code should
look like this:

---->8------------
array_type array;
// (initialize array)

CORBA::Any any;
any <<= array_type_forany(array);
------------>8----

Remember to use the -Wba option for the IDL compiler when generating the C++
code; if you omit it, the code necessary for working with any's is not
included.

Kind regards,
Maks Verver.




More information about the omniORB-list mailing list