#include <Marshal.h>


Public Member Functions | |
| TAO_Marshal_Union (void) | |
| virtual TAO::traverse_status | skip (CORBA::TypeCode_ptr tc, TAO_InputCDR *context) |
| skip operation | |
| virtual TAO::traverse_status | append (CORBA::TypeCode_ptr tc, TAO_InputCDR *src, TAO_OutputCDR *dest) |
| append operation | |
marshal a union
Definition at line 246 of file Marshal.h.
| TAO_Marshal_Union::TAO_Marshal_Union | ( | void | ) |
Definition at line 43 of file Marshal.inl.
{
}
| TAO::traverse_status TAO_Marshal_Union::append | ( | CORBA::TypeCode_ptr | tc, | |
| TAO_InputCDR * | src, | |||
| TAO_OutputCDR * | dest | |||
| ) | [virtual] |
append operation
Implements TAO_Marshal_Object.
Definition at line 357 of file append.cpp.
{
CORBA::TypeCode_var discrim_tc = tc->discriminator_type ();
CORBA::ULong kind = discrim_tc->kind ();
// Save the discriminator value in a temporary variable...
CORBA::Short short_v = CORBA::Short();
CORBA::UShort ushort_v = CORBA::UShort();
CORBA::Long long_v = CORBA::Long();
CORBA::ULong ulong_v = CORBA::ULong();
CORBA::ULong enum_v = CORBA::ULong();
CORBA::Char char_v = CORBA::Char();
CORBA::WChar wchar_v = CORBA::WChar();
CORBA::Boolean boolean_v = false;
switch (kind)
{
case CORBA::tk_short:
{
if (!src->read_short (short_v)
|| !dest->write_short (short_v))
return TAO::TRAVERSE_STOP;
}
break;
case CORBA::tk_ushort:
{
if (!src->read_ushort (ushort_v)
|| !dest->write_ushort (ushort_v))
return TAO::TRAVERSE_STOP;
}
break;
case CORBA::tk_long:
{
if (!src->read_long (long_v)
|| !dest->write_long (long_v))
return TAO::TRAVERSE_STOP;
}
break;
case CORBA::tk_ulong:
{
if (!src->read_ulong (ulong_v)
|| !dest->write_ulong (ulong_v))
return TAO::TRAVERSE_STOP;
}
break;
case CORBA::tk_enum:
{
if (!src->read_ulong (enum_v)
|| !dest->write_ulong (enum_v))
return TAO::TRAVERSE_STOP;
}
break;
case CORBA::tk_char:
{
if (!src->read_char (char_v)
|| !dest->write_char (char_v))
return TAO::TRAVERSE_STOP;
}
break;
case CORBA::tk_wchar:
{
if (!src->read_wchar (wchar_v)
|| !dest->write_wchar (wchar_v))
return TAO::TRAVERSE_STOP;
}
break;
case CORBA::tk_boolean:
{
if (!src->read_boolean (boolean_v)
|| !dest->write_boolean (boolean_v))
return TAO::TRAVERSE_STOP;
}
break;
default:
return TAO::TRAVERSE_STOP;
}
const CORBA::ULong member_count =
tc->member_count ();
const CORBA::ULong null_member = ~static_cast<CORBA::ULong> (0U);
CORBA::ULong current_member = null_member;
CORBA::ULong default_member = null_member;
for (CORBA::ULong i = 0;
i < member_count && current_member == null_member;
++i)
{
CORBA::Any_var any = tc->member_label (i);
CORBA::Octet o;
if ((any >>= CORBA::Any::to_octet (o)) && o == 0)
{
CORBA::ULong default_index =
tc->default_index ();
if (i != default_index)
throw ::CORBA::BAD_TYPECODE ();
// Found the default branch, save its position and continue
// trying to find the current value...
default_member = i;
continue;
}
switch (kind)
{
case CORBA::tk_short:
{
CORBA::Short d;
if ((any >>= d) && d == short_v)
current_member = i;
}
break;
case CORBA::tk_ushort:
{
CORBA::UShort d;
if ((any >>= d) && d == ushort_v)
current_member = i;
}
break;
case CORBA::tk_long:
{
CORBA::Long d;
if ((any >>= d) && d == long_v)
current_member = i;
}
break;
case CORBA::tk_ulong:
{
CORBA::ULong d;
if ((any >>= d) && d == ulong_v)
current_member = i;
}
break;
case CORBA::tk_enum:
{
CORBA::ULong d;
TAO::Any_Impl *impl = any->impl ();
if (impl->encoded ())
{
TAO::Unknown_IDL_Type * const unk =
dynamic_cast<TAO::Unknown_IDL_Type *> (impl);
if (!unk)
throw ::CORBA::INTERNAL ();
// We don't want unk's rd_ptr to move, in case
// we are shared by another Any, so we use this
// to copy the state, not the buffer.
TAO_InputCDR for_reading (unk->_tao_get_cdr ());
for_reading.read_ulong (d);
}
else
{
TAO_OutputCDR out;
impl->marshal_value (out);
TAO_InputCDR cdr (out);
cdr.read_ulong (d);
}
if (d == enum_v)
{
current_member = i;
}
}
break;
case CORBA::tk_char:
{
CORBA::Char d;
if ((any >>= CORBA::Any::to_char (d)) && d == char_v)
current_member = i;
}
break;
case CORBA::tk_wchar:
{
CORBA::WChar d;
if ((any >>= CORBA::Any::to_wchar (d)) && d == wchar_v)
current_member = i;
}
break;
case CORBA::tk_boolean:
{
CORBA::Boolean d;
if ((any >>= CORBA::Any::to_boolean (d)) && d == boolean_v)
current_member = i;
}
break;
default:
return TAO::TRAVERSE_STOP;
}
}
if (current_member == null_member)
{
// Cannot find the current member, check if there is a
// default...
if (default_member != null_member)
{
// Good, use the default to append...
CORBA::TypeCode_var member_tc =
tc->member_type (default_member);
return TAO_Marshal_Object::perform_append (member_tc.in (),
src,
dest);
}
// If we're here, we have an implicit default case, and we
// should just return without appending anything, since no
// union member was marshaled in the first place.
return TAO::TRAVERSE_CONTINUE;
}
// If we found the member successfully then just use that one...
CORBA::TypeCode_var member_tc =
tc->member_type (current_member);
return TAO_Marshal_Object::perform_append (member_tc.in (),
src,
dest
);
}
| TAO::traverse_status TAO_Marshal_Union::skip | ( | CORBA::TypeCode_ptr | tc, | |
| TAO_InputCDR * | context | |||
| ) | [virtual] |
skip operation
Implements TAO_Marshal_Object.
Definition at line 321 of file skip.cpp.
{
CORBA::TypeCode_var discrim_tc =
tc->discriminator_type ();
CORBA::ULong const kind =
discrim_tc->kind ();
// Save the discriminator value in a temporary variable...
CORBA::Short short_v = CORBA::Short();
CORBA::UShort ushort_v = CORBA::UShort();
CORBA::Long long_v = CORBA::Long();
CORBA::ULong ulong_v = CORBA::ULong();
CORBA::ULong enum_v = CORBA::ULong();
CORBA::Char char_v = CORBA::Char();
CORBA::WChar wchar_v = CORBA::WChar();
CORBA::Boolean boolean_v = false;
switch (kind)
{
case CORBA::tk_short:
{
if (!src->read_short (short_v))
return TAO::TRAVERSE_STOP;
}
break;
case CORBA::tk_ushort:
{
if (!src->read_ushort (ushort_v))
return TAO::TRAVERSE_STOP;
}
break;
case CORBA::tk_long:
{
if (!src->read_long (long_v))
return TAO::TRAVERSE_STOP;
}
break;
case CORBA::tk_ulong:
{
if (!src->read_ulong (ulong_v))
return TAO::TRAVERSE_STOP;
}
break;
case CORBA::tk_enum:
{
if (!src->read_ulong (enum_v))
return TAO::TRAVERSE_STOP;
}
break;
case CORBA::tk_char:
{
if (!src->read_char (char_v))
return TAO::TRAVERSE_STOP;
}
break;
case CORBA::tk_wchar:
{
if (!src->read_wchar (wchar_v))
return TAO::TRAVERSE_STOP;
}
break;
case CORBA::tk_boolean:
{
if (!src->read_boolean (boolean_v))
return TAO::TRAVERSE_STOP;
}
break;
default:
return TAO::TRAVERSE_STOP;
}
const CORBA::ULong member_count =
tc->member_count ();
const CORBA::ULong null_member = ~static_cast<CORBA::ULong> (0U);
CORBA::ULong current_member = null_member;
CORBA::ULong default_member = null_member;
for (CORBA::ULong i = 0;
i < member_count && current_member == null_member;
++i)
{
CORBA::Any_var any = tc->member_label (i);
CORBA::Octet o;
if ((any >>= CORBA::Any::to_octet (o)) && o == 0)
{
CORBA::ULong default_index =
tc->default_index ();
if (i != default_index)
throw ::CORBA::BAD_TYPECODE ();
// Found the default branch, save its position and continue
// trying to find the current value...
default_member = i;
continue;
}
switch (kind)
{
case CORBA::tk_short:
{
CORBA::Short d;
if ((any >>= d) && d == short_v)
current_member = i;
}
break;
case CORBA::tk_ushort:
{
CORBA::UShort d;
if ((any >>= d) && d == ushort_v)
current_member = i;
}
break;
case CORBA::tk_long:
{
CORBA::Long d;
if ((any >>= d) && d == long_v)
current_member = i;
}
break;
case CORBA::tk_ulong:
{
CORBA::ULong d;
if ((any >>= d) && d == ulong_v)
current_member = i;
}
break;
case CORBA::tk_enum:
{
CORBA::ULong d;
TAO::Any_Impl *impl = any->impl ();
if (impl->encoded ())
{
TAO::Unknown_IDL_Type * const unk =
dynamic_cast<TAO::Unknown_IDL_Type *> (impl);
if (!unk)
throw ::CORBA::INTERNAL ();
// We don't want unk's rd_ptr to move, in case
// we are shared by another Any, so we use this
// to copy the state, not the buffer.
TAO_InputCDR for_reading (unk->_tao_get_cdr ());
for_reading.read_ulong (d);
}
else
{
TAO_OutputCDR out;
impl->marshal_value (out);
TAO_InputCDR cdr (out);
cdr.read_ulong (d);
}
if (d == enum_v)
{
current_member = i;
}
}
break;
case CORBA::tk_char:
{
CORBA::Char d;
if ((any >>= CORBA::Any::to_char (d)) && d == char_v)
current_member = i;
}
break;
case CORBA::tk_wchar:
{
CORBA::WChar d;
if ((any >>= CORBA::Any::to_wchar (d)) && d == wchar_v)
current_member = i;
}
break;
case CORBA::tk_boolean:
{
CORBA::Boolean d;
if ((any >>= CORBA::Any::to_boolean (d)) && d == boolean_v)
current_member = i;
}
break;
default:
return TAO::TRAVERSE_STOP;
}
}
if (current_member == null_member)
{
// Cannot find the current member, check if there is a
// default...
if (default_member != null_member)
{
// Good, use the default to append...
CORBA::TypeCode_var member_tc =
tc->member_type (default_member);
return TAO_Marshal_Object::perform_skip (member_tc.in (), src);
}
// If we're here, we have an implicit default case, and we
// should just return without skipping anything, since no
// union member was marshaled in the first place.
return TAO::TRAVERSE_CONTINUE;
}
// If we found the member successfully then just use that one...
CORBA::TypeCode_var member_tc =
tc->member_type (current_member);
return TAO_Marshal_Object::perform_skip (member_tc.in (), src);
}
1.7.0