Esempio n. 1
0
bool UnionTypeCode::dump_value (TIDorb::core::cdr::CDRInputStream& input,
                                ostream& output) const
{
  CORBA::Any discriminator;
  discriminator.delegate().read_value(input, m_discriminator_type, true);

  output << "[VALUE]{union " << m_name << " discriminator: ";

  discriminator.delegate().dump(output);

  CORBA::Long index = search_member_index(discriminator);
  if (index == -1) {
    return true;	// default constructed union
  }

  if ((index < 0) || (index >= m_members->length())) {
    throw CORBA::MARSHAL();
  }

  TypeCodeImpl* tc = (TypeCodeImpl*)((CORBA::TypeCode_ptr)(*m_members)[index].type);

  if(index == m_default_used)
    output << " /default/ ";

  output << ((*m_members)[index]).name << " -> " ;

  if (!tc->dump_value(input, output))
    return false;

  output << '}';

  return true;
}
Esempio n. 2
0
CORBA::Long UnionTypeCode::search_member_index
    (const CORBA::Any& discriminator) const
{
  CORBA::ULong length = m_members->length();

  CORBA::Any* disc;

  for (CORBA::ULong i = 0; i < length; i++) {
    disc = &(((*m_members)[i]).label);
    if( discriminator.delegate() == disc->delegate())
      return i;
  }

  return m_default_used;

}
Esempio n. 3
0
void UnionTypeCode::remarshal_value
    (TIDorb::core::cdr::CDRInputStream& input,
     TIDorb::core::cdr::CDROutputStream& output) const
{
  CORBA::Any discriminator;


  discriminator.delegate().read_value(input, m_discriminator_type, true);
  discriminator.delegate().write_value(output);

  CORBA::Long index = search_member_index(discriminator);

  if (index == -1) {
    return;		// default constructed union
  }

  if ((index < 0) || (index >= m_members->length())) {
    throw CORBA::MARSHAL();
  }

  TypeCodeImpl* tc = (TypeCodeImpl*)((CORBA::TypeCode_ptr)(*m_members)[index].type);

  tc->remarshal_value(input, output);
}