예제 #1
0
CORBA::Boolean
CORBA::ValueBase::_tao_write_special_value (TAO_OutputCDR &strm,
                                            const CORBA::ValueBase *value)
{
  // If the 'value' is null then write the null value to the stream.
  if (value == 0)
  {
    return strm.write_long (TAO_OBV_GIOP_Flags::Null_tag);
  }
  else
  {
#ifdef TAO_HAS_VALUETYPE_OUT_INDIRECTION
    // value indirection

    VERIFY_MAP (TAO_OutputCDR, value_map, Value_Map);
    char* pos = 0;
    if (strm.get_value_map ()->get()->find (
      reinterpret_cast<void*>(const_cast <CORBA::ValueBase *> (value)), pos) == 0)
    {
      if (TAO_debug_level)
        {
          TAOLIB_DEBUG ((LM_DEBUG,
            ACE_TEXT ("(%P|%t)ValueBase::_tao_write_special_value, found value %x=%x\n"),
            value, pos));
        }

      if (!strm.write_long (TAO_OBV_GIOP_Flags::Indirection_tag))
        {
          return false;
        }

      CORBA::Long const offset= -strm.offset (pos);
      if (TAO_debug_level)
        {
          TAOLIB_DEBUG ((LM_DEBUG,
            ACE_TEXT ("TAO (%P|%t) - %N:%l ValueBase::_tao_write_special_value, indirection %d=%x\n"),
            offset, (void *)(strm.current()->wr_ptr () + offset) ));
        }

      return strm.write_long (offset);
    }
    else {
      if (strm.align_write_ptr (ACE_CDR::LONG_SIZE) != 0)
        {
          throw CORBA::INTERNAL ();
        }
      if (strm.get_value_map ()->get()->bind (
        reinterpret_cast<void*>(const_cast <CORBA::ValueBase *> (value)),
        strm.current()->wr_ptr() ) != 0)
        {
          throw CORBA::INTERNAL ();
        }
      else if (TAO_debug_level)
        {
          TAOLIB_DEBUG ((LM_DEBUG,
            ACE_TEXT ("TAO (%P|%t) - %N:%l ValueBase::_tao_marshal, bound value %x=%x\n"),
            value, strm.current()->wr_ptr()));
        }

      return false;
    }
#endif

    return false;
  }
}