Zsolt SZALAI
2007-07-16 21:23:26 UTC
Hi!
I'm using omniorb 4.0.x. It always throws TypeMismatch exception(at
codeline marked with *) when i would like to insert data into an enum.
IDL:
module a {
enum swtype {
INT,
STR
};
union sw switch(swtype){
case INT: long intv;
case STR: string strv;
};
};
code:
CORBA::Object_var dafo;
dafo=orb->resolve_initial_references("DynAnyFactory");
DynamicAny::DynAnyFactory_var daf;
daf=DynamicAny::DynAnyFactory::_narrow(dafo);
DynamicAny::DynAny_var dv = daf->create_dyn_any_from_type_code(_tc_sw());
DynamicAny::DynAny_ptr disc =
daf->create_dyn_any_from_type_code(_tc_swtype());
DynamicAny::DynUnion_ptr dUnion = DynamicAny::DynUnion::_narrow(dv);
DynamicAny::DynEnum_ptr edisc = DynamicAny::DynEnum::_narrow(disc);
disc = dUnion->get_discriminator();
if (selected == 0) {
edisc->set_as_ulong(0); //swtype
DynamicAny::DynAny_ptr dm = dUnion->member();
dm->insert_long(5);
}
if (selected == 1) {
edisc->set_as_ulong(1); //swtype
DynamicAny::DynAny_ptr dm = dUnion->member();
* dm->insert_string("FOOBAR");
}
return(dUnion->to_any());
There is no problem, when selected == 0, so the problem is how to tell
that the STR case is valid, and would like to insert a string?
thx,
I'm using omniorb 4.0.x. It always throws TypeMismatch exception(at
codeline marked with *) when i would like to insert data into an enum.
IDL:
module a {
enum swtype {
INT,
STR
};
union sw switch(swtype){
case INT: long intv;
case STR: string strv;
};
};
code:
CORBA::Object_var dafo;
dafo=orb->resolve_initial_references("DynAnyFactory");
DynamicAny::DynAnyFactory_var daf;
daf=DynamicAny::DynAnyFactory::_narrow(dafo);
DynamicAny::DynAny_var dv = daf->create_dyn_any_from_type_code(_tc_sw());
DynamicAny::DynAny_ptr disc =
daf->create_dyn_any_from_type_code(_tc_swtype());
DynamicAny::DynUnion_ptr dUnion = DynamicAny::DynUnion::_narrow(dv);
DynamicAny::DynEnum_ptr edisc = DynamicAny::DynEnum::_narrow(disc);
disc = dUnion->get_discriminator();
if (selected == 0) {
edisc->set_as_ulong(0); //swtype
DynamicAny::DynAny_ptr dm = dUnion->member();
dm->insert_long(5);
}
if (selected == 1) {
edisc->set_as_ulong(1); //swtype
DynamicAny::DynAny_ptr dm = dUnion->member();
* dm->insert_string("FOOBAR");
}
return(dUnion->to_any());
There is no problem, when selected == 0, so the problem is how to tell
that the STR case is valid, and would like to insert a string?
thx,
--
Zsolt
Zsolt