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

ACE_INLINE TAO_Marshal_Sequence::TAO_Marshal_Sequence void   ) 
 

Definition at line 53 of file Marshal.inl.

00054 {
00055 }


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.

References ACE_DEBUG, ACE_TEXT, ACE_OutputCDR::adjust(), LM_DEBUG, TAO_Marshal_Object::perform_append(), ACE_InputCDR::read_boolean_array(), ACE_InputCDR::read_char_array(), ACE_InputCDR::read_double_array(), ACE_InputCDR::read_float_array(), ACE_InputCDR::read_long_array(), ACE_InputCDR::read_longdouble_array(), ACE_InputCDR::read_longlong_array(), ACE_InputCDR::read_octet_array(), ACE_InputCDR::read_short_array(), ACE_InputCDR::read_ulong(), ACE_InputCDR::read_ulong_array(), ACE_InputCDR::read_ulonglong_array(), ACE_InputCDR::read_ushort_array(), ACE_InputCDR::read_wchar_array(), TAO_debug_level, and ACE_OutputCDR::write_ulong().

00631 {
00632   // Size of element.
00633   CORBA::ULong bounds;
00634 
00635   // First unmarshal the sequence length ... we trust it to be right
00636   // here, on the "be gracious in what you accept" principle.  We
00637   // don't generate illegal sequences (i.e. length > bounds).
00638 
00639   CORBA::Boolean continue_append =
00640     (CORBA::Boolean) (src->read_ulong (bounds)
00641                       ? dest->write_ulong (bounds)
00642                       : 0);
00643 
00644   if (!continue_append)
00645     {
00646       ACE_DEBUG ((
00647           LM_DEBUG,
00648           ACE_TEXT ("TAO_Marshal_Sequence::append detected error\n")
00649         ));
00650       throw ::CORBA::MARSHAL ();
00651     }
00652 
00653   if (bounds == 0)
00654     {
00655       return TAO::TRAVERSE_CONTINUE;
00656     }
00657 
00658   if (continue_append)
00659     {
00660       // Get element typecode.
00661       CORBA::TypeCode_var tc2 =
00662         tc->content_type ();
00663 
00664       TAO::traverse_status retval =
00665         TAO::TRAVERSE_CONTINUE;
00666 
00667       CORBA::TCKind kind = tc2->kind ();
00668 
00669       switch (kind)
00670         {
00671         case CORBA::tk_octet:
00672           {
00673             char* buf;
00674             if (dest->adjust (ACE_CDR::OCTET_SIZE * bounds,
00675                               ACE_CDR::OCTET_ALIGN, buf) == 0)
00676               {
00677                 if (src->read_octet_array ((ACE_CDR::Octet*)buf, bounds) == 0)
00678                   retval = TAO::TRAVERSE_STOP;
00679               }
00680           }
00681           break;
00682         case CORBA::tk_boolean:
00683           {
00684             char* buf;
00685             if (dest->adjust (ACE_CDR::OCTET_SIZE * bounds,
00686                               ACE_CDR::OCTET_ALIGN, buf) == 0)
00687               {
00688                 if (src->read_boolean_array ((ACE_CDR::Boolean*)buf, bounds) == 0)
00689                   retval = TAO::TRAVERSE_STOP;
00690               }
00691           }
00692           break;
00693         case CORBA::tk_char:
00694           {
00695             char* buf;
00696             if (dest->adjust (ACE_CDR::OCTET_SIZE * bounds,
00697                               ACE_CDR::OCTET_ALIGN, buf) == 0)
00698               {
00699                 if (src->read_char_array ((ACE_CDR::Char*)buf, bounds) == 0)
00700                   retval = TAO::TRAVERSE_STOP;
00701               }
00702           }
00703           break;
00704         case CORBA::tk_short:
00705           {
00706             char* buf;
00707             if (dest->adjust (ACE_CDR::SHORT_SIZE * bounds,
00708                               ACE_CDR::SHORT_ALIGN, buf) == 0)
00709               {
00710                 if (src->read_short_array ((ACE_CDR::Short*)buf, bounds) == 0)
00711                   retval = TAO::TRAVERSE_STOP;
00712               }
00713           }
00714           break;
00715         case CORBA::tk_ushort:
00716           {
00717             char* buf;
00718             if (dest->adjust (ACE_CDR::SHORT_SIZE * bounds,
00719                               ACE_CDR::SHORT_ALIGN, buf) == 0)
00720               {
00721                 if (src->read_ushort_array ((ACE_CDR::UShort*)buf, bounds) == 0)
00722                   retval = TAO::TRAVERSE_STOP;
00723               }
00724           }
00725           break;
00726         case CORBA::tk_wchar:
00727           {
00728             char* buf;
00729             if (dest->adjust (ACE_CDR::SHORT_SIZE * bounds,
00730                               ACE_CDR::SHORT_ALIGN, buf) == 0)
00731               {
00732                 if (src->read_wchar_array ((ACE_CDR::WChar*)buf, bounds) == 0)
00733                   retval = TAO::TRAVERSE_STOP;
00734               }
00735           }
00736           break;
00737         case CORBA::tk_long:
00738           {
00739             char* buf;
00740             if (dest->adjust (ACE_CDR::LONG_SIZE * bounds,
00741                               ACE_CDR::LONG_ALIGN, buf) == 0)
00742               {
00743                 if (src->read_long_array ((ACE_CDR::Long*)buf, bounds) == 0)
00744                   retval = TAO::TRAVERSE_STOP;
00745               }
00746           }
00747           break;
00748         case CORBA::tk_ulong:
00749           {
00750             char* buf;
00751             if (dest->adjust (ACE_CDR::LONG_SIZE * bounds,
00752                               ACE_CDR::LONG_ALIGN, buf) == 0)
00753               {
00754                 if (src->read_ulong_array ((ACE_CDR::ULong*)buf, bounds) == 0)
00755                   retval = TAO::TRAVERSE_STOP;
00756               }
00757           }
00758           break;
00759         case CORBA::tk_float:
00760           {
00761             char* buf;
00762             if (dest->adjust (ACE_CDR::LONG_SIZE * bounds,
00763                               ACE_CDR::LONG_ALIGN, buf) == 0)
00764               {
00765                 if (src->read_float_array ((ACE_CDR::Float*)buf, bounds) == 0)
00766                   retval = TAO::TRAVERSE_STOP;
00767               }
00768           }
00769           break;
00770         case CORBA::tk_double:
00771           {
00772             char* buf;
00773             if (dest->adjust (ACE_CDR::LONGLONG_SIZE * bounds,
00774                               ACE_CDR::LONGLONG_ALIGN, buf) == 0)
00775               {
00776                 if (src->read_double_array ((ACE_CDR::Double*)buf, bounds) == 0)
00777                   retval = TAO::TRAVERSE_STOP;
00778               }
00779           }
00780           break;
00781         case CORBA::tk_longlong:
00782           {
00783             char* buf;
00784             if (dest->adjust (ACE_CDR::LONGLONG_SIZE * bounds,
00785                               ACE_CDR::LONGLONG_ALIGN, buf) == 0)
00786               {
00787                 if (src->read_longlong_array ((ACE_CDR::LongLong*)buf, bounds) == 0)
00788                   retval = TAO::TRAVERSE_STOP;
00789               }
00790           }
00791           break;
00792         case CORBA::tk_ulonglong:
00793           {
00794             char* buf;
00795             if (dest->adjust (ACE_CDR::LONGLONG_SIZE * bounds,
00796                               ACE_CDR::LONGLONG_ALIGN, buf) == 0)
00797               {
00798                 if (src->read_ulonglong_array ((ACE_CDR::ULongLong*)buf, bounds) == 0)
00799                   retval = TAO::TRAVERSE_STOP;
00800               }
00801           }
00802           break;
00803         case CORBA::tk_longdouble:
00804           {
00805             char* buf;
00806             if (dest->adjust (ACE_CDR::LONGDOUBLE_SIZE * bounds,
00807                               ACE_CDR::LONGDOUBLE_ALIGN, buf) == 0)
00808               {
00809                 if (src->read_longdouble_array ((ACE_CDR::LongDouble*)buf, bounds) == 0)
00810                   retval = TAO::TRAVERSE_STOP;
00811               }
00812           }
00813           break;
00814 
00815         default:
00816           while (bounds-- && retval == TAO::TRAVERSE_CONTINUE)
00817             {
00818               retval = TAO_Marshal_Object::perform_append (tc2.in (),
00819                                                            src,
00820                                                            dest
00821                                                            );
00822             }
00823           break;
00824         }// end of switch
00825 
00826       if (retval == TAO::TRAVERSE_CONTINUE)
00827         return TAO::TRAVERSE_CONTINUE;
00828     }
00829   // error exit
00830   if (TAO_debug_level > 0)
00831     ACE_DEBUG ((
00832         LM_DEBUG,
00833         ACE_TEXT ("marshaling TAO_Marshal_Sequence::append detected error\n")
00834       ));
00835 
00836   throw ::CORBA::MARSHAL ();
00837 }

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.

References ACE_DEBUG, ACE_TEXT, ACE_InputCDR::adjust(), LM_DEBUG, TAO_Marshal_Object::perform_skip(), ACE_InputCDR::read_ulong(), ACE_InputCDR::skip_bytes(), and TAO_debug_level.

00579 {
00580   // Size of element.
00581   CORBA::ULong bounds;
00582 
00583   // First unmarshal the sequence length ... we trust it to be right
00584   // here, on the "be gracious in what you accept" principle.  We
00585   // don't generate illegal sequences (i.e. length > bounds).
00586 
00587   CORBA::Boolean continue_skipping =
00588     stream->read_ulong (bounds);
00589 
00590   if (!continue_skipping)
00591     {
00592       ACE_DEBUG ((LM_DEBUG,
00593                   ACE_TEXT ("TAO_Marshal_Sequence::skip detected error\n")));
00594       throw ::CORBA::MARSHAL ();
00595     }
00596 
00597   // No point decoding an empty sequence.
00598   if (bounds == 0)
00599     return TAO::TRAVERSE_CONTINUE;
00600 
00601   // Get element typecode.
00602   CORBA::TypeCode_var tc2 =
00603     tc->content_type ();
00604 
00605   // For CORBA basic types, the skip can be optimized
00606   CORBA::TCKind const kind = tc2->kind ();
00607 
00608   char *dummy = 0;
00609   switch (kind)
00610     {
00611     case CORBA::tk_octet:
00612     case CORBA::tk_boolean:
00613     case CORBA::tk_char:
00614       {
00615         stream->adjust (0, ACE_CDR::OCTET_ALIGN, dummy);
00616         continue_skipping =
00617           stream->skip_bytes (ACE_CDR::OCTET_SIZE * bounds);
00618       }
00619       break;
00620     case CORBA::tk_short:
00621     case CORBA::tk_ushort:
00622     case CORBA::tk_wchar:
00623       {
00624         stream->adjust (0, ACE_CDR::SHORT_ALIGN, dummy);
00625         continue_skipping =
00626           stream->skip_bytes (ACE_CDR::SHORT_SIZE * bounds);
00627       }
00628       break;
00629     case CORBA::tk_long:
00630     case CORBA::tk_ulong:
00631     case CORBA::tk_float:
00632       {
00633         stream->adjust (0, ACE_CDR::LONG_ALIGN, dummy);
00634         continue_skipping =
00635           stream->skip_bytes (ACE_CDR::LONG_SIZE * bounds);
00636       }
00637       break;
00638     case CORBA::tk_double:
00639     case CORBA::tk_longlong:
00640     case CORBA::tk_ulonglong:
00641       {
00642         stream->adjust (0, ACE_CDR::LONGLONG_ALIGN, dummy);
00643         continue_skipping =
00644           stream->skip_bytes (ACE_CDR::LONGLONG_SIZE * bounds);
00645       }
00646       break;
00647     case CORBA::tk_longdouble:
00648       {
00649         stream->adjust (0, ACE_CDR::LONGDOUBLE_ALIGN, dummy);
00650         continue_skipping =
00651           stream->skip_bytes (ACE_CDR::LONGDOUBLE_SIZE * bounds);
00652       }
00653       break;
00654 
00655     default:
00656       while (bounds-- && continue_skipping)
00657         {
00658           continue_skipping =
00659             TAO_Marshal_Object::perform_skip (tc2.in (), stream);
00660         }
00661       break;
00662     }// end of switch
00663 
00664   if (continue_skipping)
00665     return TAO::TRAVERSE_CONTINUE;
00666 
00667   // error exit
00668   if (TAO_debug_level > 0)
00669     ACE_DEBUG ((LM_DEBUG,
00670                 ACE_TEXT ("TAO_Marshal_Sequence::skip detected error\n")));
00671 
00672   throw ::CORBA::MARSHAL ();
00673 }


The documentation for this class was generated from the following files:
Generated on Sun Jan 27 13:21:57 2008 for TAO_AnyTypeCode by doxygen 1.3.6