Re:Corba: type Any and user defined types..
Hi. You can't direct use next syntax CORBA::Any a <<= "my struct" becouse
operator <<= "my type" is not defined. You must convert your type in
sequence<octet> (or use valuetype in IDL and send your type by value, only
VB4.0) and then write or read value to or from Any.
Example
// Count of elments
//
DWORD cElements = sizeof("My struct");
// Allocate the memory to hold the sequence
CORBA::ULong value_len = cElements + sizeof(CORBA::ULong);
char *value = new char[value_len];
void *ptr = value;
// Copy the element count
*(CORBA::ULong *)ptr = cElements;
((CORBA::ULong *)ptr)++;
// Copy the data
memcpy(ptr, "My struct", cElements);
// Create an any with the value
CORBA_TypeCode_var etc = new CORBA_TypeCode(CORBA::tk_octet, 0);
CORBA_TypeCode_var tc = CORBA::ORB::create_sequence_tc(0, etc);
CORBA_MarshalInBuffer ibuf(value, value_len);
any.read_value(ibuf, tc);
delete[] value;
Quote
> Hi all.
> I have a problem with the any type and user defined types. I do not find
the
> opertors <<= and >>= for the user defined types.
> Here a simple example:
> in IDL:
> struct userDefinedTest
> {
> string a;
> string b;
> };
> In my Code:
> CORBA::Any a;
> userDefinedTest test;
> a <<= test;
> produces the error
> E2094 'operator<<=' not implemented in type 'CORBA_Any' for arguments of
type
> 'userDefinedTest'
> What have I to do so that the IDL compiler generates the stubs for
overloading
> user defined types?
> Thank you,
> Carsten Wolters
> --
> Carsten Wolters
> V i r t u a l P h o t o n i c s, Inc.
> http://www.VirtualPhotonics.com
> mailto:C.Wolt...@VirtualPhotonics.com
> Phone: +49-30-398058-54
> Fax: +49-30-39805858