예제 #1
0
CORBA::Boolean
TAO_ChunkInfo::write_previous_chunk_size(TAO_OutputCDR &strm)
{
  if (this->chunk_size_pos_ != 0)
    {
      // Calculate the chunk size.
      CORBA::Long const chunk_size =
          static_cast<CORBA::Long> (strm.total_length () - this->length_to_chunk_octets_pos_);

      // This should not happen since this is called in end_chunk() and
      // the idl generated code always have the matched start_chunk() and
      // end_chunk() pair. There is always data written to the stream between
      // the start_chunk() and end_chunk() calls.
      if (chunk_size == 0)
        {
          return false;
        }

      // Write the actual chunk size to the reserved chunk size position
      // in the stream.
      if (!strm.replace (chunk_size, this->chunk_size_pos_))
        {
          return false;
        }

      // We finish writing the actual chunk size, now we need reset the state.
      this->chunk_size_pos_ = 0;
      this->length_to_chunk_octets_pos_ = 0;
    }

  return true;
}