Exemple #1
0
CORBA::Boolean
CORBA::ValueBase::_tao_write_repository_id (TAO_OutputCDR &strm,
                                            ACE_CString& id)
{
#ifdef TAO_HAS_VALUETYPE_OUT_INDIRECTION

  VERIFY_MAP (TAO_OutputCDR, repo_id_map, Repo_Id_Map);
  char* pos = 0;
  if (strm.get_repo_id_map ()->get()->find (id, pos) == 0)
  {
    if (!strm.write_long (TAO_OBV_GIOP_Flags::Indirection_tag))
      {
        return false;
      }
    CORBA::Long offset= -strm.offset (pos);
    if (TAO_debug_level)
      {
        TAOLIB_DEBUG ((LM_DEBUG,
          ACE_TEXT ("TAO (%P|%t) - %N:%l ValueBase::_tao_write_repository_id,  id %C indirection %d\n"),
          id.c_str(), offset));
      }
    if (!strm.write_long (offset))
      {
        return false;
      }
  }
  else
  {
    if (strm.align_write_ptr (ACE_CDR::LONG_SIZE) != 0)
      {
        throw CORBA::INTERNAL ();
      }
    if (strm.get_repo_id_map ()->get ()->bind (id, strm.current()->wr_ptr ()) != 0)
      {
        throw CORBA::INTERNAL ();
      }
    if (TAO_debug_level)
      {
        TAOLIB_DEBUG ((LM_DEBUG,
          ACE_TEXT ("TAO (%P|%t) - %N:%l ValueBase::_tao_write_repository_id, bound %C - %x\n"),
          id.c_str (), strm.current()->wr_ptr ()));
      }
    if (! strm.write_string (id.c_str ()))
      {
        return false;
      }
  }
#else
  if (! strm.write_string (id.c_str ()))
    {
      return 0;
    }
#endif

  return 1;
}
Exemple #2
0
CORBA::Boolean
TAO_ChunkInfo::reserve_chunk_size(TAO_OutputCDR &strm)
{
  // This is called in the start_chunk().
  // Reserve the chunk size the first time the start_chunk () is called
  // if there are several start_chunk () called continuously without
  // calling end_chunk (). This could happen in the _tao_marshal_state()
  // in the most derived valuetype.

  if (this->chunk_size_pos_ == 0)
    {
      // Align the wr_ptr before we reserve the space for chunk size.
      strm.align_write_ptr (ACE_CDR::LONG_SIZE);
      // Remember begin of the chunk (at chunk size position) that is needed
      // when we write back actual chunk size to the stream.
      this->chunk_size_pos_ = strm.current ()->wr_ptr ();

      // Insert four bytes here as a place-holder, we need to go back
      // later and write the actual size.
      if (! strm.write_long (0))
        {
          return 0;
        }

      // Remember length before writing chunk data. This is used to calculate
      // the actual size of the chunk.
      this->length_to_chunk_octets_pos_ = strm.total_length ();
    }

  return 1;
}
Exemple #3
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;
  }
}