Public Member Functions

TAO_Marshal_Sequence Class Reference

TAO_Marshal_Sequence. More...

#include <Marshal.h>

Inheritance diagram for TAO_Marshal_Sequence:
Inheritance graph
[legend]
Collaboration diagram for TAO_Marshal_Sequence:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 TAO_Marshal_Sequence (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

Detailed Description

TAO_Marshal_Sequence.

marshal a sequence

Definition at line 290 of file Marshal.h.


Constructor & Destructor Documentation

TAO_Marshal_Sequence::TAO_Marshal_Sequence ( void   ) 

Definition at line 53 of file Marshal.inl.

{
}


Member Function Documentation

TAO::traverse_status TAO_Marshal_Sequence::append ( CORBA::TypeCode_ptr  tc,
TAO_InputCDR src,
TAO_OutputCDR dest 
) [virtual]

append operation

Implements TAO_Marshal_Object.

Definition at line 628 of file append.cpp.

{
  // Size of element.
  CORBA::ULong bounds;

  // First unmarshal the sequence length ... we trust it to be right
  // here, on the "be gracious in what you accept" principle.  We
  // don't generate illegal sequences (i.e. length > bounds).

  CORBA::Boolean continue_append =
    (CORBA::Boolean) (src->read_ulong (bounds)
                      ? dest->write_ulong (bounds)
                      : 0);

  if (!continue_append)
    {
      ACE_DEBUG ((
          LM_DEBUG,
          ACE_TEXT ("TAO_Marshal_Sequence::append detected error\n")
        ));
      throw ::CORBA::MARSHAL ();
    }

  if (bounds == 0)
    {
      return TAO::TRAVERSE_CONTINUE;
    }

  if (continue_append)
    {
      // Get element typecode.
      CORBA::TypeCode_var tc2 =
        tc->content_type ();

      TAO::traverse_status retval =
        TAO::TRAVERSE_CONTINUE;

      CORBA::TCKind kind = tc2->kind ();

      switch (kind)
        {
        case CORBA::tk_octet:
          {
            char* buf;
            if (dest->adjust (ACE_CDR::OCTET_SIZE * bounds,
                              ACE_CDR::OCTET_ALIGN, buf) == 0)
              {
                if (src->read_octet_array ((ACE_CDR::Octet*)buf, bounds) == 0)
                  retval = TAO::TRAVERSE_STOP;
              }
          }
          break;
        case CORBA::tk_boolean:
          {
            char* buf;
            if (dest->adjust (ACE_CDR::OCTET_SIZE * bounds,
                              ACE_CDR::OCTET_ALIGN, buf) == 0)
              {
                if (src->read_boolean_array ((ACE_CDR::Boolean*)buf, bounds) == 0)
                  retval = TAO::TRAVERSE_STOP;
              }
          }
          break;
        case CORBA::tk_char:
          {
            char* buf;
            if (dest->adjust (ACE_CDR::OCTET_SIZE * bounds,
                              ACE_CDR::OCTET_ALIGN, buf) == 0)
              {
                if (src->read_char_array ((ACE_CDR::Char*)buf, bounds) == 0)
                  retval = TAO::TRAVERSE_STOP;
              }
          }
          break;
        case CORBA::tk_short:
          {
            char* buf;
            if (dest->adjust (ACE_CDR::SHORT_SIZE * bounds,
                              ACE_CDR::SHORT_ALIGN, buf) == 0)
              {
                if (src->read_short_array ((ACE_CDR::Short*)buf, bounds) == 0)
                  retval = TAO::TRAVERSE_STOP;
              }
          }
          break;
        case CORBA::tk_ushort:
          {
            char* buf;
            if (dest->adjust (ACE_CDR::SHORT_SIZE * bounds,
                              ACE_CDR::SHORT_ALIGN, buf) == 0)
              {
                if (src->read_ushort_array ((ACE_CDR::UShort*)buf, bounds) == 0)
                  retval = TAO::TRAVERSE_STOP;
              }
          }
          break;
        case CORBA::tk_wchar:
          {
            char* buf;
            if (dest->adjust (ACE_CDR::SHORT_SIZE * bounds,
                              ACE_CDR::SHORT_ALIGN, buf) == 0)
              {
                if (src->read_wchar_array ((ACE_CDR::WChar*)buf, bounds) == 0)
                  retval = TAO::TRAVERSE_STOP;
              }
          }
          break;
        case CORBA::tk_long:
          {
            char* buf;
            if (dest->adjust (ACE_CDR::LONG_SIZE * bounds,
                              ACE_CDR::LONG_ALIGN, buf) == 0)
              {
                if (src->read_long_array ((ACE_CDR::Long*)buf, bounds) == 0)
                  retval = TAO::TRAVERSE_STOP;
              }
          }
          break;
        case CORBA::tk_ulong:
          {
            char* buf;
            if (dest->adjust (ACE_CDR::LONG_SIZE * bounds,
                              ACE_CDR::LONG_ALIGN, buf) == 0)
              {
                if (src->read_ulong_array ((ACE_CDR::ULong*)buf, bounds) == 0)
                  retval = TAO::TRAVERSE_STOP;
              }
          }
          break;
        case CORBA::tk_float:
          {
            char* buf;
            if (dest->adjust (ACE_CDR::LONG_SIZE * bounds,
                              ACE_CDR::LONG_ALIGN, buf) == 0)
              {
                if (src->read_float_array ((ACE_CDR::Float*)buf, bounds) == 0)
                  retval = TAO::TRAVERSE_STOP;
              }
          }
          break;
        case CORBA::tk_double:
          {
            char* buf;
            if (dest->adjust (ACE_CDR::LONGLONG_SIZE * bounds,
                              ACE_CDR::LONGLONG_ALIGN, buf) == 0)
              {
                if (src->read_double_array ((ACE_CDR::Double*)buf, bounds) == 0)
                  retval = TAO::TRAVERSE_STOP;
              }
          }
          break;
        case CORBA::tk_longlong:
          {
            char* buf;
            if (dest->adjust (ACE_CDR::LONGLONG_SIZE * bounds,
                              ACE_CDR::LONGLONG_ALIGN, buf) == 0)
              {
                if (src->read_longlong_array ((ACE_CDR::LongLong*)buf, bounds) == 0)
                  retval = TAO::TRAVERSE_STOP;
              }
          }
          break;
        case CORBA::tk_ulonglong:
          {
            char* buf;
            if (dest->adjust (ACE_CDR::LONGLONG_SIZE * bounds,
                              ACE_CDR::LONGLONG_ALIGN, buf) == 0)
              {
                if (src->read_ulonglong_array ((ACE_CDR::ULongLong*)buf, bounds) == 0)
                  retval = TAO::TRAVERSE_STOP;
              }
          }
          break;
        case CORBA::tk_longdouble:
          {
            char* buf;
            if (dest->adjust (ACE_CDR::LONGDOUBLE_SIZE * bounds,
                              ACE_CDR::LONGDOUBLE_ALIGN, buf) == 0)
              {
                if (src->read_longdouble_array ((ACE_CDR::LongDouble*)buf, bounds) == 0)
                  retval = TAO::TRAVERSE_STOP;
              }
          }
          break;

        default:
          while (bounds-- && retval == TAO::TRAVERSE_CONTINUE)
            {
              retval = TAO_Marshal_Object::perform_append (tc2.in (),
                                                           src,
                                                           dest
                                                           );
            }
          break;
        }// end of switch

      if (retval == TAO::TRAVERSE_CONTINUE)
        return TAO::TRAVERSE_CONTINUE;
    }
  // error exit
  if (TAO_debug_level > 0)
    ACE_DEBUG ((
        LM_DEBUG,
        ACE_TEXT ("marshaling TAO_Marshal_Sequence::append detected error\n")
      ));

  throw ::CORBA::MARSHAL ();
}

TAO::traverse_status TAO_Marshal_Sequence::skip ( CORBA::TypeCode_ptr  tc,
TAO_InputCDR context 
) [virtual]

skip operation

Implements TAO_Marshal_Object.

Definition at line 578 of file skip.cpp.

{
  // Size of element.
  CORBA::ULong bounds;

  // First unmarshal the sequence length ... we trust it to be right
  // here, on the "be gracious in what you accept" principle.  We
  // don't generate illegal sequences (i.e. length > bounds).

  CORBA::Boolean continue_skipping =
    stream->read_ulong (bounds);

  if (!continue_skipping)
    {
      ACE_DEBUG ((LM_DEBUG,
                  ACE_TEXT ("TAO_Marshal_Sequence::skip detected error\n")));
      throw ::CORBA::MARSHAL ();
    }

  // No point decoding an empty sequence.
  if (bounds == 0)
    return TAO::TRAVERSE_CONTINUE;

  // Get element typecode.
  CORBA::TypeCode_var tc2 =
    tc->content_type ();

  // For CORBA basic types, the skip can be optimized
  CORBA::TCKind const kind = tc2->kind ();

  char *dummy = 0;
  switch (kind)
    {
    case CORBA::tk_octet:
    case CORBA::tk_boolean:
    case CORBA::tk_char:
      {
        stream->adjust (0, ACE_CDR::OCTET_ALIGN, dummy);
        continue_skipping =
          stream->skip_bytes (ACE_CDR::OCTET_SIZE * bounds);
      }
      break;
    case CORBA::tk_short:
    case CORBA::tk_ushort:
    case CORBA::tk_wchar:
      {
        stream->adjust (0, ACE_CDR::SHORT_ALIGN, dummy);
        continue_skipping =
          stream->skip_bytes (ACE_CDR::SHORT_SIZE * bounds);
      }
      break;
    case CORBA::tk_long:
    case CORBA::tk_ulong:
    case CORBA::tk_float:
      {
        stream->adjust (0, ACE_CDR::LONG_ALIGN, dummy);
        continue_skipping =
          stream->skip_bytes (ACE_CDR::LONG_SIZE * bounds);
      }
      break;
    case CORBA::tk_double:
    case CORBA::tk_longlong:
    case CORBA::tk_ulonglong:
      {
        stream->adjust (0, ACE_CDR::LONGLONG_ALIGN, dummy);
        continue_skipping =
          stream->skip_bytes (ACE_CDR::LONGLONG_SIZE * bounds);
      }
      break;
    case CORBA::tk_longdouble:
      {
        stream->adjust (0, ACE_CDR::LONGDOUBLE_ALIGN, dummy);
        continue_skipping =
          stream->skip_bytes (ACE_CDR::LONGDOUBLE_SIZE * bounds);
      }
      break;

    default:
      while (bounds-- && continue_skipping)
        {
          continue_skipping =
            TAO_Marshal_Object::perform_skip (tc2.in (), stream);
        }
      break;
    }// end of switch

  if (continue_skipping)
    return TAO::TRAVERSE_CONTINUE;

  // error exit
  if (TAO_debug_level > 0)
    ACE_DEBUG ((LM_DEBUG,
                ACE_TEXT ("TAO_Marshal_Sequence::skip detected error\n")));

  throw ::CORBA::MARSHAL ();
}


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines