Previous Table of Contents Next


18.2.9 Mapping for the any Type


   The CORBA any type permits the specification of values that can express any OMG IDL data type. There is no direct or simple mapping of this type into COM, thus we map it to the following interface definition:

   // Microsoft IDLtypedef [v1_enum] enum CORBAAnyDataTagEnum {

   anySimpleValTag,anyAnyValTag,anySeqValTag,anyStructValTag,anyUnionValTag

   } CORBAAnyDataTag;

   typedef union CORBAAnyDataUnion switch(CORBAAnyDataTag whichOne){case anyAnyValTag:

   ICORBA_Any *anyVal;case anySeqValTag:case anyStructValTag:

   struct {[string, unique] char * repositoryId;unsigned long cbMaxSize;unsigned long cbLengthUsed;[size_is(cbMaxSize), length_is(cbLengthUsed),

   unique]

   union CORBAAnyDataUnion *pVal;} multiVal;case anyUnionValTag:

   struct {[string, unique] char * repositoryId;long disc;union CORBAAnyDataUnion *value;

   } unionVal;case anyObjectValTag:

   struct {[string, unique] char * repositoryId;VARIANT val;

   } objectVal;case anySimpleValTag: // All other typesVARIANT simpleVal;} CORBAAnyData;

   .... uuid(74105F50-3C68-11cf-9588-AA0004004A09) ]

   interface ICORBA_Any: IUnknown{HRESULT _get_value([out] VARIANT * val );HRESULT _put_value([in] VARIANT val );HRESULT _get_CORBAAnyData([out] CORBAAnyData* val);HRESULT _put_CORBAAnyData([in] CORBAAnyData val );HRESULT _get_typeCode([out] ICORBA_TypeCode ** tc);}

   In most cases, a COM client can use the _get_value() or _put_value() method to set and get the value of a CORBA any. However, the data types supported by a VARIANT are too restrictive to support all values representable in an any, such as structs and unions. In cases where the data types can be represented in a VARIANT, they will be; in other cases, they will optionally be returned as an IStream pointer in the VARIANT. An implementation may choose not to represent these types as an IStream, in which case an SCODE value of E_DATA_CONVERSION is returned when the VARIANT is requested.