ACE_InputCDR Class Reference

A CDR stream for reading, i.e. for demarshalling. More...

#include <CDR_Stream.h>

Collaboration diagram for ACE_InputCDR:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 ACE_InputCDR (const char *buf, size_t bufsiz, int byte_order=ACE_CDR_BYTE_ORDER, ACE_CDR::Octet major_version=ACE_CDR_GIOP_MAJOR_VERSION, ACE_CDR::Octet minor_version=ACE_CDR_GIOP_MINOR_VERSION)
 ACE_InputCDR (size_t bufsiz, int byte_order=ACE_CDR_BYTE_ORDER, ACE_CDR::Octet major_version=ACE_CDR_GIOP_MAJOR_VERSION, ACE_CDR::Octet minor_version=ACE_CDR_GIOP_MINOR_VERSION)
 ACE_InputCDR (const ACE_Message_Block *data, int byte_order=ACE_CDR_BYTE_ORDER, ACE_CDR::Octet major_version=ACE_CDR_GIOP_MAJOR_VERSION, ACE_CDR::Octet minor_version=ACE_CDR_GIOP_MINOR_VERSION, ACE_Lock *lock=0)
 Create an input stream from an ACE_Message_Block.

 ACE_InputCDR (ACE_Data_Block *data, ACE_Message_Block::Message_Flags flag=0, int byte_order=ACE_CDR_BYTE_ORDER, ACE_CDR::Octet major_version=ACE_CDR_GIOP_MAJOR_VERSION, ACE_CDR::Octet minor_version=ACE_CDR_GIOP_MINOR_VERSION)
 ACE_InputCDR (ACE_Data_Block *data, ACE_Message_Block::Message_Flags flag, size_t read_pointer_position, size_t write_pointer_position, int byte_order=ACE_CDR_BYTE_ORDER, ACE_CDR::Octet major_version=ACE_CDR_GIOP_MAJOR_VERSION, ACE_CDR::Octet minor_version=ACE_CDR_GIOP_MINOR_VERSION)
 ACE_InputCDR (const ACE_InputCDR &rhs)
ACE_InputCDRoperator= (const ACE_InputCDR &rhs)
 ACE_InputCDR (const ACE_InputCDR &rhs, size_t size, ACE_CDR::Long offset)
 ACE_InputCDR (const ACE_InputCDR &rhs, size_t size)
 ACE_InputCDR (const ACE_OutputCDR &rhs, ACE_Allocator *buffer_allocator=0, ACE_Allocator *data_block_allocator=0, ACE_Allocator *message_block_allocator=0)
 Create an input CDR from an output CDR.

 ACE_InputCDR (Transfer_Contents rhs)
 Transfer the contents from to a new CDR.

 ~ACE_InputCDR (void)
 Destructor.

ACE_CDR::Boolean skip_wstring (void)
ACE_CDR::Boolean skip_string (void)
ACE_CDR::Boolean skip_bytes (size_t n)
 Skip n bytes in the CDR stream.

bool good_bit (void) const
 returns false if a problem has been detected.

const ACE_Message_Blockstart (void) const
int grow (size_t newsize)
void reset_byte_order (int byte_order)
void reset (const ACE_Message_Block *data, int byte_order)
ACE_Message_Blocksteal_contents (void)
 Steal the contents from the current CDR.

void steal_from (ACE_InputCDR &cdr)
void exchange_data_blocks (ACE_InputCDR &cdr)
ACE_Data_Blockclone_from (ACE_InputCDR &cdr)
void reset_contents (void)
char * rd_ptr (void)
 Returns the current position for the rd_ptr.

char * wr_ptr (void)
 Returns the current position for the wr_ptr.

size_t length (void) const
 Return how many bytes are left in the stream.

int align_read_ptr (size_t alignment)
bool do_byte_swap (void) const
int byte_order (void) const
ACE_Char_Codeset_Translatorchar_translator (void) const
 Access the codeset translators. They can be nil!

ACE_WChar_Codeset_Translatorwchar_translator (void) const
void char_translator (ACE_Char_Codeset_Translator *)
 Set the codeset translators.

void wchar_translator (ACE_WChar_Codeset_Translator *)
int adjust (size_t size, char *&buf)
int adjust (size_t size, size_t align, char *&buf)
void set_version (ACE_CDR::Octet major, ACE_CDR::Octet minor)
 Set the underlying GIOP version..

void get_version (ACE_CDR::Octet &major, ACE_CDR::Octet &minor)
 Set the underlying GIOP version..

Read basic IDL types
ACE_CDR::Boolean read_boolean (ACE_CDR::Boolean &x)
ACE_CDR::Boolean read_char (ACE_CDR::Char &x)
ACE_CDR::Boolean read_wchar (ACE_CDR::WChar &x)
ACE_CDR::Boolean read_octet (ACE_CDR::Octet &x)
ACE_CDR::Boolean read_short (ACE_CDR::Short &x)
ACE_CDR::Boolean read_ushort (ACE_CDR::UShort &x)
ACE_CDR::Boolean read_long (ACE_CDR::Long &x)
ACE_CDR::Boolean read_ulong (ACE_CDR::ULong &x)
ACE_CDR::Boolean read_longlong (ACE_CDR::LongLong &x)
ACE_CDR::Boolean read_ulonglong (ACE_CDR::ULongLong &x)
ACE_CDR::Boolean read_float (ACE_CDR::Float &x)
ACE_CDR::Boolean read_double (ACE_CDR::Double &x)
ACE_CDR::Boolean read_longdouble (ACE_CDR::LongDouble &x)
ACE_CDR::Boolean read_string (ACE_CDR::Char *&x)
ACE_CDR::Boolean read_string (ACE_CString &x)
ACE_CDR::Boolean read_wstring (ACE_CDR::WChar *&x)
Read basic IDL types arrays
ACE_CDR::Boolean read_boolean_array (ACE_CDR::Boolean *x, ACE_CDR::ULong length)
ACE_CDR::Boolean read_char_array (ACE_CDR::Char *x, ACE_CDR::ULong length)
ACE_CDR::Boolean read_wchar_array (ACE_CDR::WChar *x, ACE_CDR::ULong length)
ACE_CDR::Boolean read_octet_array (ACE_CDR::Octet *x, ACE_CDR::ULong length)
ACE_CDR::Boolean read_short_array (ACE_CDR::Short *x, ACE_CDR::ULong length)
ACE_CDR::Boolean read_ushort_array (ACE_CDR::UShort *x, ACE_CDR::ULong length)
ACE_CDR::Boolean read_long_array (ACE_CDR::Long *x, ACE_CDR::ULong length)
ACE_CDR::Boolean read_ulong_array (ACE_CDR::ULong *x, ACE_CDR::ULong length)
ACE_CDR::Boolean read_longlong_array (ACE_CDR::LongLong *x, ACE_CDR::ULong length)
ACE_CDR::Boolean read_ulonglong_array (ACE_CDR::ULongLong *x, ACE_CDR::ULong length)
ACE_CDR::Boolean read_float_array (ACE_CDR::Float *x, ACE_CDR::ULong length)
ACE_CDR::Boolean read_double_array (ACE_CDR::Double *x, ACE_CDR::ULong length)
ACE_CDR::Boolean read_longdouble_array (ACE_CDR::LongDouble *x, ACE_CDR::ULong length)
Skip elements
ACE_CDR::Boolean skip_boolean (void)
ACE_CDR::Boolean skip_char (void)
ACE_CDR::Boolean skip_wchar (void)
ACE_CDR::Boolean skip_octet (void)
ACE_CDR::Boolean skip_short (void)
ACE_CDR::Boolean skip_ushort (void)
ACE_CDR::Boolean skip_long (void)
ACE_CDR::Boolean skip_ulong (void)
ACE_CDR::Boolean skip_longlong (void)
ACE_CDR::Boolean skip_ulonglong (void)
ACE_CDR::Boolean skip_float (void)
ACE_CDR::Boolean skip_double (void)
ACE_CDR::Boolean skip_longdouble (void)

Protected Attributes

ACE_Message_Block start_
bool do_byte_swap_
bool good_bit_
 set to false when an error occurs.

ACE_CDR::Octet major_version_
 The GIOP versions for this stream.

ACE_CDR::Octet minor_version_
ACE_Char_Codeset_Translatorchar_translator_
 If not nil, invoke for translation of character and string data.

ACE_WChar_Codeset_Translatorwchar_translator_

Private Member Functions

ACE_CDR::Boolean read_1 (ACE_CDR::Octet *x)
ACE_CDR::Boolean read_2 (ACE_CDR::UShort *x)
ACE_CDR::Boolean read_4 (ACE_CDR::ULong *x)
ACE_CDR::Boolean read_8 (ACE_CDR::ULongLong *x)
ACE_CDR::Boolean read_16 (ACE_CDR::LongDouble *x)
ACE_CDR::Boolean read_array (void *x, size_t size, size_t align, ACE_CDR::ULong length)
ACE_CDR::Boolean read_wchar_array_i (ACE_CDR::WChar *x, ACE_CDR::ULong length)
void rd_ptr (size_t offset)
 Move the rd_ptr ahead by bytes.

char * end (void)
 Points to the continuation field of the current message block.


Friends

class ACE_Char_Codeset_Translator
class ACE_WChar_Codeset_Translator

Detailed Description

A CDR stream for reading, i.e. for demarshalling.

This class is based on the the CORBA spec for Java (98-02-29), java class omg.org.CORBA.portable.InputStream. It diverts in a few ways: + Operations to retrieve basic types take parameters by reference. + Operations taking arrays don't have offsets, because in C++ it is easier to describe an array starting from x+offset. + Operations return an error status, because exceptions are not widely available in C++ (yet).

Definition at line 552 of file CDR_Stream.h.


Constructor & Destructor Documentation

ACE_InputCDR::ACE_InputCDR const char *  buf,
size_t  bufsiz,
int  byte_order = ACE_CDR_BYTE_ORDER,
ACE_CDR::Octet  major_version = ACE_CDR_GIOP_MAJOR_VERSION,
ACE_CDR::Octet  minor_version = ACE_CDR_GIOP_MINOR_VERSION
 

Create an input stream from an arbitrary buffer. The buffer must be properly aligned because this contructor will *not* work if the buffer is aligned unproperly.See ACE_ptr_align_binary() for instructions on how to align a pointer properly and use ACE_CDR::MAX_ALIGNMENT for the correct alignment.

Definition at line 759 of file CDR_Stream.cpp.

References ACE_CDR_BYTE_ORDER, ACE_CDR::Octet, and ACE_Message_Block::wr_ptr().

00764   : start_ (buf, bufsiz),
00765     do_byte_swap_ (byte_order != ACE_CDR_BYTE_ORDER),
00766     good_bit_ (true),
00767     major_version_ (major_version),
00768     minor_version_ (minor_version),
00769     char_translator_ (0),
00770     wchar_translator_ (0)
00771 {
00772   this->start_.wr_ptr (bufsiz);
00773 }

ACE_InputCDR::ACE_InputCDR size_t  bufsiz,
int  byte_order = ACE_CDR_BYTE_ORDER,
ACE_CDR::Octet  major_version = ACE_CDR_GIOP_MAJOR_VERSION,
ACE_CDR::Octet  minor_version = ACE_CDR_GIOP_MINOR_VERSION
 

Create an empty input stream. The caller is responsible for putting the right data and providing the right alignment.

Definition at line 775 of file CDR_Stream.cpp.

References ACE_CDR_BYTE_ORDER, and ACE_CDR::Octet.

00779   : start_ (bufsiz),
00780     do_byte_swap_ (byte_order != ACE_CDR_BYTE_ORDER),
00781     good_bit_ (true),
00782     major_version_ (major_version),
00783     minor_version_ (minor_version),
00784     char_translator_ (0),
00785     wchar_translator_ (0)
00786 {
00787 }

ACE_InputCDR::ACE_InputCDR const ACE_Message_Block data,
int  byte_order = ACE_CDR_BYTE_ORDER,
ACE_CDR::Octet  major_version = ACE_CDR_GIOP_MAJOR_VERSION,
ACE_CDR::Octet  minor_version = ACE_CDR_GIOP_MINOR_VERSION,
ACE_Lock lock = 0
 

Create an input stream from an ACE_Message_Block.

The alignment of the

  • data block is carried into the new ACE_InputCDR object. This constructor either increments the
  • data reference count, or copies the data (if it's a compound message block) so the caller can release the block immediately upon return.

Definition at line 789 of file CDR_Stream.cpp.

References ACE_CDR::Octet, and reset().

00794 : start_ (0, ACE_Message_Block::MB_DATA, 0, 0, 0, lock),
00795     good_bit_ (true),
00796     major_version_ (major_version),
00797     minor_version_ (minor_version),
00798     char_translator_ (0),
00799     wchar_translator_ (0)
00800 
00801 {
00802   this->reset (data, byte_order);
00803 }

ACE_InputCDR::ACE_InputCDR ACE_Data_Block data,
ACE_Message_Block::Message_Flags  flag = 0,
int  byte_order = ACE_CDR_BYTE_ORDER,
ACE_CDR::Octet  major_version = ACE_CDR_GIOP_MAJOR_VERSION,
ACE_CDR::Octet  minor_version = ACE_CDR_GIOP_MINOR_VERSION
 

Create an input stream from an ACE_Data_Block. The indicates whether the can be deleted by the CDR stream or not

Definition at line 805 of file CDR_Stream.cpp.

References ACE_CDR_BYTE_ORDER, ACE_Message_Block::Message_Flags, and ACE_CDR::Octet.

00810   : start_ (data, flag),
00811     do_byte_swap_ (byte_order != ACE_CDR_BYTE_ORDER),
00812     good_bit_ (true),
00813     major_version_ (major_version),
00814     minor_version_ (minor_version),
00815     char_translator_ (0),
00816     wchar_translator_ (0)
00817 
00818 {
00819 }

ACE_InputCDR::ACE_InputCDR ACE_Data_Block data,
ACE_Message_Block::Message_Flags  flag,
size_t  read_pointer_position,
size_t  write_pointer_position,
int  byte_order = ACE_CDR_BYTE_ORDER,
ACE_CDR::Octet  major_version = ACE_CDR_GIOP_MAJOR_VERSION,
ACE_CDR::Octet  minor_version = ACE_CDR_GIOP_MINOR_VERSION
 

Create an input stream from an ACE_Data_Block. It also sets the read and write pointers at the desired positions. This would be helpful if the applications desires to create a new CDR stream from a semi-processed datablock.

Definition at line 821 of file CDR_Stream.cpp.

References ACE_CDR_BYTE_ORDER, ACE_Message_Block::base(), ACE_Message_Block::end(), ACE_Message_Block::Message_Flags, ACE_CDR::Octet, ACE_Message_Block::rd_ptr(), and ACE_Message_Block::wr_ptr().

00828   : start_ (data, flag),
00829     do_byte_swap_ (byte_order != ACE_CDR_BYTE_ORDER),
00830     good_bit_ (true),
00831     major_version_ (major_version),
00832     minor_version_ (minor_version),
00833     char_translator_ (0),
00834     wchar_translator_ (0)
00835 
00836 {
00837   // Set the read pointer
00838   this->start_.rd_ptr (rd_pos);
00839 
00840   // Set the write pointer after doing a sanity check.
00841   char* wrpos = this->start_.base () + wr_pos;
00842 
00843   if (this->start_.end () >= wrpos)
00844     {
00845       this->start_.wr_ptr (wr_pos);
00846     }
00847 }

ACE_InputCDR::ACE_InputCDR const ACE_InputCDR rhs  ) 
 

These make a copy of the current stream state, but do not copy the internal buffer, so the same stream can be read multiple times efficiently.

Definition at line 925 of file CDR_Stream.cpp.

References ACE_ptr_align_binary(), ACE_Message_Block::base(), ACE_Message_Block::rd_ptr(), start_, and ACE_Message_Block::wr_ptr().

00926   : start_ (rhs.start_,
00927             ACE_CDR::MAX_ALIGNMENT),
00928     do_byte_swap_ (rhs.do_byte_swap_),
00929     good_bit_ (true),
00930     major_version_ (rhs.major_version_),
00931     minor_version_ (rhs.minor_version_),
00932     char_translator_ (rhs.char_translator_),
00933     wchar_translator_ (rhs.wchar_translator_)
00934 {
00935 #if !defined (ACE_LACKS_CDR_ALIGNMENT)
00936   char *buf = ACE_ptr_align_binary (rhs.start_.base (),
00937                                     ACE_CDR::MAX_ALIGNMENT);
00938 #else
00939   char *buf = rhs.start_.base ();
00940 #endif /* ACE_LACKS_CDR_ALIGNMENT */
00941 
00942   size_t rd_offset = rhs.start_.rd_ptr () - buf;
00943   size_t wr_offset = rhs.start_.wr_ptr () - buf;
00944   this->start_.rd_ptr (rd_offset);
00945   this->start_.wr_ptr (wr_offset);
00946 }

ACE_InputCDR::ACE_InputCDR const ACE_InputCDR rhs,
size_t  size,
ACE_CDR::Long  offset
 

When interpreting indirected TypeCodes it is useful to make a "copy" of the stream starting in the new position.

Definition at line 850 of file CDR_Stream.cpp.

References ACE_ptr_align_binary(), ACE_Message_Block::base(), ACE_CDR::Long, ACE_Message_Block::rd_ptr(), ACE_Message_Block::space(), start_, and ACE_Message_Block::wr_ptr().

00853   : start_ (rhs.start_,
00854             ACE_CDR::MAX_ALIGNMENT),
00855     do_byte_swap_ (rhs.do_byte_swap_),
00856     good_bit_ (true),
00857     major_version_ (rhs.major_version_),
00858     minor_version_ (rhs.minor_version_),
00859     char_translator_ (rhs.char_translator_),
00860     wchar_translator_ (rhs.wchar_translator_)
00861 
00862 {
00863 #if !defined (ACE_LACKS_CDR_ALIGNMENT)
00864   // Align the base pointer assuming that the incoming stream is also
00865   // aligned the way we are aligned
00866   char *incoming_start = ACE_ptr_align_binary (rhs.start_.base (),
00867                                                ACE_CDR::MAX_ALIGNMENT);
00868 #else
00869   char *incoming_start = rhs.start_.base ();
00870 #endif /* ACE_LACKS_CDR_ALIGNMENT */
00871 
00872   const size_t newpos =
00873     (rhs.start_.rd_ptr() - incoming_start)  + offset;
00874 
00875   if (newpos <= this->start_.space ()
00876       && newpos + size <= this->start_.space ())
00877     {
00878       this->start_.rd_ptr (newpos);
00879       this->start_.wr_ptr (newpos + size);
00880     }
00881   else
00882     this->good_bit_ = false;
00883 }

ACE_InputCDR::ACE_InputCDR const ACE_InputCDR rhs,
size_t  size
 

This creates an encapsulated stream, the first byte must be (per the spec) the byte order of the encapsulation.

Definition at line 885 of file CDR_Stream.cpp.

References ACE_CDR_BYTE_ORDER, ACE_ptr_align_binary(), ACE_Message_Block::base(), ACE_CDR::Octet, ACE_Message_Block::rd_ptr(), read_octet(), ACE_Message_Block::space(), start_, and ACE_Message_Block::wr_ptr().

00887   : start_ (rhs.start_,
00888             ACE_CDR::MAX_ALIGNMENT),
00889     do_byte_swap_ (rhs.do_byte_swap_),
00890     good_bit_ (true),
00891     major_version_ (rhs.major_version_),
00892     minor_version_ (rhs.minor_version_),
00893     char_translator_ (rhs.char_translator_),
00894     wchar_translator_ (rhs.wchar_translator_)
00895 
00896 {
00897 #if !defined (ACE_LACKS_CDR_ALIGNMENT)
00898   // Align the base pointer assuming that the incoming stream is also
00899   // aligned the way we are aligned
00900   char *incoming_start = ACE_ptr_align_binary (rhs.start_.base (),
00901                                                ACE_CDR::MAX_ALIGNMENT);
00902 #else
00903   char *incoming_start = rhs.start_.base ();
00904 #endif /* ACE_LACKS_CDR_ALIGNMENT */
00905 
00906   const size_t newpos =
00907     rhs.start_.rd_ptr() - incoming_start;
00908 
00909   if (newpos <= this->start_.space ()
00910       && newpos + size <= this->start_.space ())
00911     {
00912       // Notice that ACE_Message_Block::duplicate may leave the
00913       // wr_ptr() with a higher value than what we actually want.
00914       this->start_.rd_ptr (newpos);
00915       this->start_.wr_ptr (newpos + size);
00916 
00917       ACE_CDR::Octet byte_order = 0;
00918       (void) this->read_octet (byte_order);
00919       this->do_byte_swap_ = (byte_order != ACE_CDR_BYTE_ORDER);
00920     }
00921   else
00922     this->good_bit_ = false;
00923 }

ACE_InputCDR::ACE_InputCDR const ACE_OutputCDR rhs,
ACE_Allocator buffer_allocator = 0,
ACE_Allocator data_block_allocator = 0,
ACE_Allocator message_block_allocator = 0
 

Create an input CDR from an output CDR.

Definition at line 982 of file CDR_Stream.cpp.

References ACE_OutputCDR::begin(), ACE_Message_Block::cont(), ACE_Message_Block::copy(), ACE_OutputCDR::end(), ACE_Message_Block::length(), ACE_CDR::mb_align(), and ACE_Message_Block::rd_ptr().

00986   : start_ (rhs.total_length () + ACE_CDR::MAX_ALIGNMENT,
00987             ACE_Message_Block::MB_DATA,
00988             0,
00989             0,
00990             buffer_allocator,
00991             0,
00992             0,
00993             ACE_Time_Value::zero,
00994             ACE_Time_Value::max_time,
00995             data_block_allocator,
00996             message_block_allocator),
00997     do_byte_swap_ (rhs.do_byte_swap_),
00998     good_bit_ (true),
00999     major_version_ (rhs.major_version_),
01000     minor_version_ (rhs.minor_version_),
01001     char_translator_ (rhs.char_translator_),
01002     wchar_translator_ (rhs.wchar_translator_)
01003 {
01004   ACE_CDR::mb_align (&this->start_);
01005   for (const ACE_Message_Block *i = rhs.begin ();
01006        i != rhs.end ();
01007        i = i->cont ())
01008     this->start_.copy (i->rd_ptr (), i->length ());
01009 }

ACE_InputCDR::ACE_InputCDR Transfer_Contents  rhs  ) 
 

Transfer the contents from to a new CDR.

Definition at line 948 of file CDR_Stream.cpp.

References ACE_Data_Block::clone_nocopy(), ACE_Message_Block::data_block(), ACE_Message_Block::rd_ptr(), ACE_Message_Block::replace_data_block(), ACE_InputCDR::Transfer_Contents::rhs_, start_, and ACE_Message_Block::wr_ptr().

00949   : start_ (x.rhs_.start_.data_block ()),
00950     do_byte_swap_ (x.rhs_.do_byte_swap_),
00951     good_bit_ (true),
00952     major_version_ (x.rhs_.major_version_),
00953     minor_version_ (x.rhs_.minor_version_),
00954     char_translator_ (x.rhs_.char_translator_),
00955     wchar_translator_ (x.rhs_.wchar_translator_)
00956 {
00957 
00958   this->start_.rd_ptr (x.rhs_.start_.rd_ptr ());
00959   this->start_.wr_ptr (x.rhs_.start_.wr_ptr ());
00960 
00961   ACE_Data_Block* db = this->start_.data_block ()->clone_nocopy ();
00962   (void) x.rhs_.start_.replace_data_block (db);
00963 }

ACE_INLINE ACE_InputCDR::~ACE_InputCDR void   ) 
 

Destructor.

Definition at line 595 of file CDR_Stream.inl.

00596 {
00597 }


Member Function Documentation

ACE_INLINE int ACE_InputCDR::adjust size_t  size,
size_t  align,
char *&  buf
 

As above, but now the size and alignment requirements may be different.

Definition at line 1020 of file CDR_Stream.inl.

References ACE_ptr_align_binary(), ACE_Message_Block::rd_ptr(), rd_ptr(), and wr_ptr().

01023 {
01024 #if !defined (ACE_LACKS_CDR_ALIGNMENT)
01025   buf = ACE_ptr_align_binary (this->rd_ptr (), align);
01026 #else
01027   buf = this->rd_ptr ();
01028 #endif /* ACE_LACKS_CDR_ALIGNMENT */
01029 
01030   char * const end = buf + size;
01031   if (end <= this->wr_ptr ())
01032     {
01033       this->start_.rd_ptr (end);
01034       return 0;
01035     }
01036 
01037   this->good_bit_ = false;
01038   return -1;
01039 #if defined (ACE_LACKS_CDR_ALIGNMENT)
01040   ACE_UNUSED_ARG (align);
01041 #endif /* ACE_LACKS_CDR_ALIGNMENT */
01042 }

ACE_INLINE int ACE_InputCDR::adjust size_t  size,
char *&  buf
 

Returns (in buf) the next position in the buffer aligned to size. It advances the Message_Block rd_ptr past the data (i.e., buf + size). Sets the good_bit to false and returns a -1 on failure.

Definition at line 1045 of file CDR_Stream.inl.

Referenced by read_16(), read_2(), read_4(), read_8(), read_array(), and read_wchar_array_i().

01047 {
01048   return this->adjust (size, size, buf);
01049 }

ACE_INLINE int ACE_InputCDR::align_read_ptr size_t  alignment  ) 
 

Utility function to allow the user more flexibility. Skips up to the nearest alignment-byte boundary. Argument MUST be a power of 2.

Returns:
0 on success and -1 on failure.

Definition at line 1464 of file CDR_Stream.inl.

References ACE_ptr_align_binary(), ACE_Message_Block::rd_ptr(), rd_ptr(), and wr_ptr().

01465 {
01466 #if !defined (ACE_LACKS_CDR_ALIGNMENT)
01467   char *buf = ACE_ptr_align_binary (this->rd_ptr (),
01468                                     alignment);
01469 #else
01470   char *buf = this->rd_ptr ();
01471 #endif /* ACE_LACKS_CDR_ALIGNMENT */
01472 
01473   if (buf <= this->wr_ptr ())
01474     {
01475       this->start_.rd_ptr (buf);
01476       return 0;
01477     }
01478 
01479   this->good_bit_ = false;
01480   return -1;
01481 }

ACE_INLINE int ACE_InputCDR::byte_order void   )  const
 

If do_byte_swap() returns false, this returns ACE_CDR_BYTE_ORDER else it returns !ACE_CDR_BYTE_ORDER.

Definition at line 1458 of file CDR_Stream.inl.

References ACE_CDR_BYTE_ORDER, and do_byte_swap().

01459 {
01460   return this->do_byte_swap () ? !ACE_CDR_BYTE_ORDER : ACE_CDR_BYTE_ORDER;
01461 }

ACE_INLINE void ACE_InputCDR::char_translator ACE_Char_Codeset_Translator  ) 
 

Set the codeset translators.

Definition at line 1511 of file CDR_Stream.inl.

01512 {
01513   this->char_translator_ = ctran;
01514 }

ACE_INLINE ACE_Char_Codeset_Translator * ACE_InputCDR::char_translator void   )  const
 

Access the codeset translators. They can be nil!

Definition at line 1498 of file CDR_Stream.inl.

01499 {
01500   return this->char_translator_;
01501 }

ACE_Data_Block * ACE_InputCDR::clone_from ACE_InputCDR cdr  ) 
 

Note:
The caller is responsible for managing the memory of the returned ACE_Data_Block.

Definition at line 1667 of file CDR_Stream.cpp.

References char_translator_, ACE_Data_Block::clone_nocopy(), ACE_Message_Block::clr_self_flags(), ACE_Message_Block::data_block(), do_byte_swap_, major_version_, ACE_CDR::mb_align(), ACE_OS::memcpy(), minor_version_, ACE_Message_Block::rd_ptr(), rd_ptr(), ACE_Message_Block::replace_data_block(), ACE_Message_Block::reset(), ACE_Data_Block::size(), ACE_Message_Block::size(), start_, wchar_translator_, ACE_Message_Block::wr_ptr(), and wr_ptr().

01668 {
01669   this->do_byte_swap_ = cdr.do_byte_swap_;
01670 
01671   // Get the read & write pointer positions in the incoming CDR
01672   // streams
01673   char *rd_ptr = cdr.start_.rd_ptr ();
01674   char *wr_ptr = cdr.start_.wr_ptr ();
01675 
01676   // Now reset the incoming CDR stream
01677   cdr.start_.reset ();
01678 
01679   // As we have reset the stream, try to align the underlying message
01680   // block in the incoming stream
01681   ACE_CDR::mb_align (&cdr.start_);
01682 
01683   // Get the read & write pointer positions again
01684   char *nrd_ptr = cdr.start_.rd_ptr ();
01685   char *nwr_ptr = cdr.start_.wr_ptr ();
01686 
01687   // Actual length of the stream is..
01688   // @todo: This will look idiotic, but we dont seem to have much of a
01689   // choice. How do we calculate the length of the incoming stream?
01690   // Calling the method before calling reset () would give us the
01691   // wrong length of the stream that needs copying.  So we do the
01692   // calulation like this
01693   // (1) We get the <rd_ptr> and <wr_ptr> positions of the incoming
01694   // stream.
01695   // (2) Then we reset the <incoming> stream and then align it.
01696   // (3) We get the <rd_ptr> and <wr_ptr> positions again. (Points #1
01697   // thru #3 has been done already)
01698   // (4) The difference in the <rd_ptr> and <wr_ptr> positions gives
01699   // us the following, the actual bytes traversed by the <rd_ptr> and
01700   // <wr_ptr>.
01701   // (5) The bytes traversed by the <wr_ptr> is the actual length of
01702   // the stream.
01703 
01704   // Actual bytes traversed
01705   size_t rd_bytes = rd_ptr - nrd_ptr;
01706   size_t wr_bytes = wr_ptr - nwr_ptr;
01707 
01708   ACE_CDR::mb_align (&this->start_);
01709 
01710   ACE_Data_Block *db =
01711     this->start_.data_block ();
01712 
01713   // If the size of the data that needs to be copied are higher than
01714   // what is available, then do a reallocation.
01715   if (wr_bytes > (this->start_.size () - ACE_CDR::MAX_ALIGNMENT))
01716     {
01717       // @@NOTE: We need to probably add another method to the message
01718       // block interface to simplify this
01719       db =
01720         cdr.start_.data_block ()->clone_nocopy ();
01721 
01722       if (db == 0 || db->size ((wr_bytes) +
01723                                ACE_CDR::MAX_ALIGNMENT) == -1)
01724         return 0;
01725 
01726       // Replace our data block by using the incoming CDR stream.
01727       db = this->start_.replace_data_block (db);
01728 
01729       // Align the start_ message block.
01730       ACE_CDR::mb_align (&this->start_);
01731 
01732       // Clear the DONT_DELETE flag if it has been set
01733       this->start_.clr_self_flags (ACE_Message_Block::DONT_DELETE);
01734     }
01735 
01736   // Now do the copy
01737   (void) ACE_OS::memcpy (this->start_.wr_ptr (),
01738                          cdr.start_.rd_ptr (),
01739                          wr_bytes);
01740 
01741   // Set the read pointer position to the same point as that was in
01742   // <incoming> cdr.
01743   this->start_.rd_ptr (rd_bytes);
01744   this->start_.wr_ptr (wr_bytes);
01745 
01746   // We have changed the read & write pointers for the incoming
01747   // stream. Set them back to the positions that they were before..
01748   cdr.start_.rd_ptr (rd_bytes);
01749   cdr.start_.wr_ptr (wr_bytes);
01750 
01751   this->major_version_ = cdr.major_version_;
01752   this->minor_version_ = cdr.minor_version_;
01753 
01754   // Copy the char/wchar translators
01755   this->char_translator_ = cdr.char_translator_;
01756   this->wchar_translator_ = cdr.wchar_translator_;
01757 
01758   return db;
01759 }

ACE_INLINE bool ACE_InputCDR::do_byte_swap void   )  const
 

If true then this stream is writing in non-native byte order. This is only meaningful if ACE_ENABLE_SWAP_ON_WRITE is defined.

Definition at line 1452 of file CDR_Stream.inl.

Referenced by byte_order().

01453 {
01454   return this->do_byte_swap_;
01455 }

ACE_INLINE char * ACE_InputCDR::end void   )  [private]
 

Points to the continuation field of the current message block.

Definition at line 996 of file CDR_Stream.inl.

References ACE_Message_Block::end().

00997 {
00998   return this->start_.end ();
00999 }

void ACE_InputCDR::exchange_data_blocks ACE_InputCDR cdr  ) 
 

Note:
We now do only with the start_ message block.

Definition at line 1604 of file CDR_Stream.cpp.

References ACE_Message_Block::base(), ACE_Message_Block::clr_self_flags(), ACE_Message_Block::data_block(), do_byte_swap_, major_version_, ACE_Message_Block::Message_Flags, minor_version_, ACE_CDR::Octet, ACE_Message_Block::rd_ptr(), ACE_Message_Block::replace_data_block(), ACE_Message_Block::reset(), ACE_Message_Block::self_flags(), ACE_Message_Block::set_self_flags(), ACE_Message_Block::size(), start_, and ACE_Message_Block::wr_ptr().

01605 {
01606   // Exchange byte orders
01607   int byte_order = cdr.do_byte_swap_;
01608   cdr.do_byte_swap_ = this->do_byte_swap_;
01609   this->do_byte_swap_ = byte_order;
01610 
01611   // Get the destination read and write pointers
01612   size_t drd_pos =
01613     cdr.start_.rd_ptr () - cdr.start_.base ();
01614   size_t dwr_pos =
01615     cdr.start_.wr_ptr () - cdr.start_.base ();
01616 
01617   // Get the source read & write pointers
01618   size_t srd_pos =
01619     this->start_.rd_ptr () - this->start_.base ();
01620   size_t swr_pos =
01621     this->start_.wr_ptr () - this->start_.base ();
01622 
01623   // Exchange data_blocks. Dont release any of the data blocks.
01624   ACE_Data_Block *dnb =
01625     this->start_.replace_data_block (cdr.start_.data_block ());
01626   cdr.start_.replace_data_block (dnb);
01627 
01628   // Exchange the flags information..
01629   ACE_Message_Block::Message_Flags df = cdr.start_.self_flags ();
01630   ACE_Message_Block::Message_Flags sf = this->start_.self_flags ();
01631 
01632   cdr.start_.clr_self_flags (df);
01633   this->start_.clr_self_flags (sf);
01634 
01635   cdr.start_.set_self_flags (sf);
01636   this->start_.set_self_flags (df);
01637 
01638   // Reset the <cdr> pointers to zero before it is set again.
01639   cdr.start_.reset ();
01640   this->start_.reset ();
01641 
01642   // Set the read and write pointers.
01643   if (cdr.start_.size () >= srd_pos)
01644     cdr.start_.rd_ptr (srd_pos);
01645 
01646   if (cdr.start_.size () >= swr_pos)
01647     cdr.start_.wr_ptr (swr_pos);
01648 
01649   if (this->start_.size () >= drd_pos)
01650     this->start_.rd_ptr (drd_pos);
01651 
01652   if (this->start_.size () >= dwr_pos)
01653     this->start_.wr_ptr (dwr_pos);
01654 
01655   ACE_CDR::Octet dmajor = cdr.major_version_;
01656   ACE_CDR::Octet dminor = cdr.minor_version_;
01657 
01658   // Exchange the GIOP version info
01659   cdr.major_version_ = this->major_version_;
01660   cdr.minor_version_ = this->minor_version_;
01661 
01662   this->major_version_ = dmajor;
01663   this->minor_version_ = dminor;
01664 }

ACE_INLINE void ACE_InputCDR::get_version ACE_CDR::Octet major,
ACE_CDR::Octet minor
 

Set the underlying GIOP version..

Definition at line 1491 of file CDR_Stream.inl.

References ACE_CDR::Octet.

01492 {
01493   major = this->major_version_;
01494   minor = this->minor_version_;
01495 }

ACE_INLINE bool ACE_InputCDR::good_bit void   )  const
 

returns false if a problem has been detected.

Definition at line 1058 of file CDR_Stream.inl.

Referenced by operator>>().

01059 {
01060   return this->good_bit_;
01061 }

int ACE_InputCDR::grow size_t  newsize  ) 
 

Grow the internal buffer, reset rd_ptr to the first byte in the new buffer that is properly aligned, and set wr_ptr to rd_ptr + newsize

Definition at line 1569 of file CDR_Stream.cpp.

References ACE_CDR::grow(), ACE_CDR::mb_align(), and ACE_Message_Block::wr_ptr().

01570 {
01571   if (ACE_CDR::grow (&this->start_, newsize) == -1)
01572     return -1;
01573 
01574   ACE_CDR::mb_align (&this->start_);
01575   this->start_.wr_ptr (newsize);
01576   return 0;
01577 }

ACE_INLINE size_t ACE_InputCDR::length void   )  const
 

Return how many bytes are left in the stream.

Definition at line 689 of file CDR_Stream.inl.

References ACE_Message_Block::length().

Referenced by read_boolean_array(), read_char_array(), read_double_array(), read_float_array(), read_long_array(), read_longdouble_array(), read_longlong_array(), read_octet_array(), read_short_array(), read_string(), read_ulong_array(), read_ulonglong_array(), read_ushort_array(), read_wchar_array(), and read_wstring().

00690 {
00691   return this->start_.length ();
00692 }

ACE_InputCDR & ACE_InputCDR::operator= const ACE_InputCDR rhs  ) 
 

Definition at line 966 of file CDR_Stream.cpp.

References char_translator_, ACE_Message_Block::data_block(), do_byte_swap_, ACE_Data_Block::duplicate(), major_version_, minor_version_, ACE_Message_Block::rd_ptr(), start_, and ACE_Message_Block::wr_ptr().

00967 {
00968   if (this != &rhs)
00969     {
00970       this->start_.data_block (rhs.start_.data_block ()->duplicate ());
00971       this->start_.rd_ptr (rhs.start_.rd_ptr ());
00972       this->start_.wr_ptr (rhs.start_.wr_ptr ());
00973       this->do_byte_swap_ = rhs.do_byte_swap_;
00974       this->good_bit_ = true;
00975       this->char_translator_ = rhs.char_translator_;
00976       this->major_version_ = rhs.major_version_;
00977       this->minor_version_ = rhs.minor_version_;
00978     }
00979   return *this;
00980 }

ACE_INLINE void ACE_InputCDR::rd_ptr size_t  offset  )  [private]
 

Move the rd_ptr ahead by bytes.

Definition at line 1002 of file CDR_Stream.inl.

References ACE_Message_Block::rd_ptr().

01003 {
01004   this->start_.rd_ptr (offset);
01005 }

ACE_INLINE char * ACE_InputCDR::rd_ptr void   ) 
 

Returns the current position for the rd_ptr.

Definition at line 1008 of file CDR_Stream.inl.

References ACE_Message_Block::rd_ptr().

Referenced by adjust(), align_read_ptr(), clone_from(), read_1(), skip_bytes(), and skip_string().

01009 {
01010   return this->start_.rd_ptr ();
01011 }

ACE_CDR::Boolean ACE_InputCDR::read_1 ACE_CDR::Octet x  )  [private]
 

Definition at line 1393 of file CDR_Stream.cpp.

References ACE_CDR::Octet, ACE_Message_Block::rd_ptr(), rd_ptr(), and wr_ptr().

Referenced by ACE_WChar_Codeset_Translator::read_1(), ACE_Char_Codeset_Translator::read_1(), read_char(), read_octet(), read_wchar(), skip_octet(), and skip_wchar().

01394 {
01395   if (this->rd_ptr () < this->wr_ptr ())
01396     {
01397       *x = *reinterpret_cast<ACE_CDR::Octet*> (this->rd_ptr ());
01398       this->start_.rd_ptr (1);
01399       return true;
01400     }
01401 
01402   this->good_bit_ = false;
01403   return false;
01404 }

ACE_CDR::Boolean ACE_InputCDR::read_16 ACE_CDR::LongDouble x  )  [private]
 

Definition at line 1498 of file CDR_Stream.cpp.

References adjust(), and ACE_CDR::swap_16().

Referenced by read_longdouble(), and skip_longdouble().

01499 {
01500   char *buf = 0;
01501   if (this->adjust (ACE_CDR::LONGDOUBLE_SIZE,
01502                     ACE_CDR::LONGDOUBLE_ALIGN,
01503                     buf) == 0)
01504     {
01505 #if !defined (ACE_DISABLE_SWAP_ON_READ)
01506       if (!this->do_byte_swap_)
01507         *x = *reinterpret_cast<ACE_CDR::LongDouble *> (buf);
01508       else
01509         ACE_CDR::swap_16 (buf, reinterpret_cast<char*> (x));
01510 #else
01511       *x = *reinterpret_cast<ACE_CDR::LongDouble*> (buf);
01512 #endif /* ACE_DISABLE_SWAP_ON_READ */
01513       return true;
01514     }
01515 
01516   this->good_bit_ = false;
01517   return false;
01518 }

ACE_CDR::Boolean ACE_InputCDR::read_2 ACE_CDR::UShort x  )  [private]
 

Definition at line 1407 of file CDR_Stream.cpp.

References adjust(), ACE_CDR::swap_2(), and ACE_CDR::UShort.

Referenced by ACE_WChar_Codeset_Translator::read_2(), read_short(), read_ushort(), read_wchar(), skip_ushort(), and skip_wchar().

01408 {
01409   char *buf = 0;
01410   if (this->adjust (ACE_CDR::SHORT_SIZE, buf) == 0)
01411     {
01412 #if !defined (ACE_DISABLE_SWAP_ON_READ)
01413       if (!this->do_byte_swap_)
01414         *x = *reinterpret_cast<ACE_CDR::UShort*> (buf);
01415       else
01416         ACE_CDR::swap_2 (buf, reinterpret_cast<char*> (x));
01417 #else
01418       *x = *reinterpret_cast<ACE_CDR::UShort*> (buf);
01419 #endif /* ACE_DISABLE_SWAP_ON_READ */
01420       return true;
01421     }
01422   this->good_bit_ = false;
01423   return false;
01424 }

ACE_CDR::Boolean ACE_InputCDR::read_4 ACE_CDR::ULong x  )  [private]
 

Definition at line 1427 of file CDR_Stream.cpp.

References adjust(), ACE_CDR::swap_4(), and ACE_CDR::ULong.

Referenced by ACE_WChar_Codeset_Translator::read_4(), read_float(), read_long(), read_ulong(), read_wchar(), skip_ulong(), and skip_wchar().

01428 {
01429   char *buf = 0;
01430   if (this->adjust (ACE_CDR::LONG_SIZE, buf) == 0)
01431     {
01432 #if !defined (ACE_DISABLE_SWAP_ON_READ)
01433       if (!this->do_byte_swap_)
01434         *x = *reinterpret_cast<ACE_CDR::ULong*> (buf);
01435       else
01436         ACE_CDR::swap_4 (buf, reinterpret_cast<char*> (x));
01437 #else
01438       *x = *reinterpret_cast<ACE_CDR::ULong*> (buf);
01439 #endif /* ACE_DISABLE_SWAP_ON_READ */
01440       return true;
01441     }
01442   this->good_bit_ = false;
01443   return false;
01444 }

ACE_CDR::Boolean ACE_InputCDR::read_8 ACE_CDR::ULongLong x  )  [private]
 

Definition at line 1447 of file CDR_Stream.cpp.

References adjust(), ACE_CDR::swap_8(), and ACE_CDR::ULongLong.

Referenced by read_double(), read_longlong(), read_ulonglong(), and skip_ulonglong().

01448 {
01449   char *buf = 0;
01450 
01451   if (this->adjust (ACE_CDR::LONGLONG_SIZE, buf) == 0)
01452     {
01453 #if !defined (ACE_DISABLE_SWAP_ON_READ)
01454 #  if defined (__arm__)
01455       if (!this->do_byte_swap_)
01456         {
01457           // Convert from Intel format (12345678 => 56781234)
01458           const char *orig = buf;
01459           char *target = reinterpret_cast<char *> (x);
01460           register ACE_UINT32 x =
01461             *reinterpret_cast<const ACE_UINT32 *> (orig);
01462           register ACE_UINT32 y =
01463             *reinterpret_cast<const ACE_UINT32 *> (orig + 4);
01464           *reinterpret_cast<ACE_UINT32 *> (target) = y;
01465           *reinterpret_cast<ACE_UINT32 *> (target + 4) = x;
01466         }
01467       else
01468         {
01469           // Convert from Sparc format (12345678 => 43218765)
01470           const char *orig = buf;
01471           char *target = reinterpret_cast<char *> (x);
01472           register ACE_UINT32 x =
01473             *reinterpret_cast<const ACE_UINT32 *> (orig);
01474           register ACE_UINT32 y =
01475             *reinterpret_cast<const ACE_UINT32 *> (orig + 4);
01476           x = (x << 24) | ((x & 0xff00) << 8) | ((x & 0xff0000) >> 8) | (x >> 24);
01477           y = (y << 24) | ((y & 0xff00) << 8) | ((y & 0xff0000) >> 8) | (y >> 24);
01478           *reinterpret_cast<ACE_UINT32 *> (target) = x;
01479           *reinterpret_cast<ACE_UINT32 *> (target + 4) = y;
01480         }
01481 #  else
01482       if (!this->do_byte_swap_)
01483         *x = *reinterpret_cast<ACE_CDR::ULongLong *> (buf);
01484       else
01485         ACE_CDR::swap_8 (buf, reinterpret_cast<char *> (x));
01486 #  endif /* !__arm__ */
01487 #else
01488       *x = *reinterpret_cast<ACE_CDR::ULongLong *> (buf);
01489 #endif /* ACE_DISABLE_SWAP_ON_READ */
01490       return true;
01491     }
01492 
01493   this->good_bit_ = false;
01494   return false;
01495 }

ACE_CDR::Boolean ACE_InputCDR::read_array void *  x,
size_t  size,
size_t  align,
ACE_CDR::ULong  length
[private]
 

Read an array of length elements, each of size bytes and the start aligned at a multiple of . The elements are assumed to be packed with the right alignment restrictions. It is mostly designed for buffers of the basic types.

This operation uses ; as explained above it is expected that using assignment is faster that for one element, but for several elements should be more efficient, it could be interesting to find the break even point and optimize for that case, but that would be too platform dependent.

Definition at line 1283 of file CDR_Stream.cpp.

References adjust(), ACE_OS::memcpy(), ACE_CDR::swap_16_array(), ACE_CDR::swap_2_array(), ACE_CDR::swap_4_array(), ACE_CDR::swap_8_array(), and ACE_CDR::ULong.

Referenced by ACE_WChar_Codeset_Translator::read_array(), ACE_Char_Codeset_Translator::read_array(), read_char_array(), read_double_array(), read_float_array(), read_long_array(), read_longdouble_array(), read_longlong_array(), read_octet_array(), read_short_array(), read_ulong_array(), read_ulonglong_array(), read_ushort_array(), read_wchar(), and read_wchar_array().

01287 {
01288   if (length == 0)
01289     return true;
01290   char* buf = 0;
01291 
01292   if (this->adjust (size * length, align, buf) == 0)
01293     {
01294 #if defined (ACE_DISABLE_SWAP_ON_READ)
01295       ACE_OS::memcpy (x, buf, size*length);
01296 #else
01297       if (!this->do_byte_swap_ || size == 1)
01298         ACE_OS::memcpy (x, buf, size*length);
01299       else
01300         {
01301           char *target = reinterpret_cast<char*> (x);
01302           switch (size)
01303             {
01304             case 2:
01305               ACE_CDR::swap_2_array (buf, target, length);
01306               break;
01307             case 4:
01308               ACE_CDR::swap_4_array (buf, target, length);
01309               break;
01310             case 8:
01311               ACE_CDR::swap_8_array (buf, target, length);
01312               break;
01313             case 16:
01314               ACE_CDR::swap_16_array (buf, target, length);
01315               break;
01316             default:
01317               // TODO: print something?
01318               this->good_bit_ = false;
01319               return false;
01320             }
01321         }
01322 #endif /* ACE_DISABLE_SWAP_ON_READ */
01323       return this->good_bit_;
01324     }
01325   return false;
01326 }

ACE_INLINE ACE_CDR::Boolean ACE_InputCDR::read_boolean ACE_CDR::Boolean x  ) 
 

Return false on failure and true on success.

Definition at line 606 of file CDR_Stream.inl.

References ACE_CDR::Boolean, ACE_CDR::Octet, and read_octet().

Referenced by ACE_OutputCDR::append_boolean(), operator>>(), and read_boolean_array().

00607 {
00608   ACE_CDR::Octet tmp = 0;
00609   (void) this->read_octet (tmp);
00610   x = tmp ? true : false;
00611   return (ACE_CDR::Boolean) this->good_bit_;
00612 }

ACE_CDR::Boolean ACE_InputCDR::read_boolean_array ACE_CDR::Boolean x,
ACE_CDR::ULong  length
 

The buffer x must be large enough to contain length elements. Return false on failure and true on success.

Definition at line 1370 of file CDR_Stream.cpp.

References ACE_CDR::Boolean, length(), read_boolean(), and ACE_CDR::ULong.

01372 {
01373   // Make sure the length of the array isn't greater than the length of
01374   // the stream.
01375   if (length > this->length ())
01376     {
01377       this->good_bit_ = false;
01378       return false;
01379     }
01380 
01381   // It is hard to optimize this, the spec requires that on the wire
01382   // booleans be represented as a byte with value 0 or 1, but in
01383   // memory it is possible (though very unlikely) that a boolean has
01384   // a non-zero value (different from 1).
01385   // We resort to a simple loop.
01386   for (ACE_CDR::ULong i = 0; i != length && this->good_bit_; ++i)
01387     (void) this->read_boolean (x[i]);
01388 
01389   return this->good_bit_;
01390 }

ACE_INLINE ACE_CDR::Boolean ACE_InputCDR::read_char ACE_CDR::Char x  ) 
 

Return false on failure and true on success.

Definition at line 615 of file CDR_Stream.inl.

References ACE_CDR::Char, read_1(), and ACE_Char_Codeset_Translator::read_char().

Referenced by ACE_OutputCDR::append_char(), and operator>>().

00616 {
00617   if (this->char_translator_ == 0)
00618     {
00619       void *temp = &x;
00620       return this->read_1 (reinterpret_cast<ACE_CDR::Octet*> (temp));
00621     }
00622   return this->char_translator_->read_char (*this, x);
00623 }

ACE_INLINE ACE_CDR::Boolean ACE_InputCDR::read_char_array ACE_CDR::Char x,
ACE_CDR::ULong  length
 

The buffer x must be large enough to contain length elements. Return false on failure and true on success.

Definition at line 695 of file CDR_Stream.inl.

References ACE_CDR::Char, length(), read_array(), ACE_Char_Codeset_Translator::read_char_array(), and ACE_CDR::ULong.

Referenced by operator>>(), and read_string().

00697 {
00698   // Make sure the length of the array isn't greater than the length of
00699   // the stream.
00700   if (length > this->length ())
00701     {
00702       this->good_bit_ = false;
00703       return false;
00704     }
00705 
00706   if (this->char_translator_ == 0)
00707     return this->read_array (x,
00708                              ACE_CDR::OCTET_SIZE,
00709                              ACE_CDR::OCTET_ALIGN,
00710                              length);
00711   return this->char_translator_->read_char_array (*this, x, length);
00712 }

ACE_INLINE ACE_CDR::Boolean ACE_InputCDR::read_double ACE_CDR::Double x  ) 
 

Return false on failure and true on success.

Definition at line 676 of file CDR_Stream.inl.

References read_8().

Referenced by ACE_OutputCDR::append_double(), and operator>>().

00677 {
00678   void *temp = &x;
00679   return this->read_8 (reinterpret_cast<ACE_CDR::ULongLong*> (temp));
00680 }

ACE_INLINE ACE_CDR::Boolean ACE_InputCDR::read_double_array ACE_CDR::Double x,
ACE_CDR::ULong  length
 

The buffer x must be large enough to contain length elements. Return false on failure and true on success.

Definition at line 884 of file CDR_Stream.inl.

References length(), read_array(), and ACE_CDR::ULong.

00886 {
00887   // Make sure the length of the array isn't greater than the length of
00888   // the stream.
00889   if (length * ACE_CDR::LONGLONG_SIZE > this->length ())
00890     {
00891       this->good_bit_ = false;
00892       return false;
00893     }
00894 
00895   return this->read_array (x,
00896                            ACE_CDR::LONGLONG_SIZE,
00897                            ACE_CDR::LONGLONG_ALIGN,
00898                            length);
00899 }

ACE_INLINE ACE_CDR::Boolean ACE_InputCDR::read_float ACE_CDR::Float x  ) 
 

Return false on failure and true on success.

Definition at line 669 of file CDR_Stream.inl.

References read_4().

Referenced by ACE_OutputCDR::append_float(), and operator>>().

00670 {
00671   void *temp = &x;
00672   return this->read_4 (reinterpret_cast<ACE_CDR::ULong*> (temp));
00673 }

ACE_INLINE ACE_CDR::Boolean ACE_InputCDR::read_float_array ACE_CDR::Float x,
ACE_CDR::ULong  length
 

The buffer x must be large enough to contain length elements. Return false on failure and true on success.

Definition at line 865 of file CDR_Stream.inl.

References length(), read_array(), and ACE_CDR::ULong.

00867 {
00868   // Make sure the length of the array isn't greater than the length of
00869   // the stream.
00870   if (length * ACE_CDR::LONG_SIZE > this->length ())
00871     {
00872       this->good_bit_ = false;
00873       return false;
00874     }
00875 
00876   return this->read_array (x,
00877                            ACE_CDR::LONG_SIZE,
00878                            ACE_CDR::LONG_ALIGN,
00879                            length);
00880 }

ACE_INLINE ACE_CDR::Boolean ACE_InputCDR::read_long ACE_CDR::Long x  ) 
 

Return false on failure and true on success.

Definition at line 641 of file CDR_Stream.inl.

References ACE_CDR::Long, and read_4().

Referenced by ACE_OutputCDR::append_long(), and operator>>().

00642 {
00643   void *temp = &x;
00644   return this->read_4 (reinterpret_cast<ACE_CDR::ULong*> (temp));
00645 }

ACE_INLINE ACE_CDR::Boolean ACE_InputCDR::read_long_array ACE_CDR::Long x,
ACE_CDR::ULong  length
 

The buffer x must be large enough to contain length elements. Return false on failure and true on success.

Definition at line 793 of file CDR_Stream.inl.

References length(), ACE_CDR::Long, read_array(), and ACE_CDR::ULong.

00795 {
00796   // Make sure the length of the array isn't greater than the length of
00797   // the stream.
00798   if (length * ACE_CDR::LONG_SIZE > this->length ())
00799     {
00800       this->good_bit_ = false;
00801       return false;
00802     }
00803 
00804   return this->read_array (x,
00805                            ACE_CDR::LONG_SIZE,
00806                            ACE_CDR::LONG_ALIGN,
00807                            length);
00808 }

ACE_INLINE ACE_CDR::Boolean ACE_InputCDR::read_longdouble ACE_CDR::LongDouble x  ) 
 

Return false on failure and true on success.

Definition at line 683 of file CDR_Stream.inl.

References read_16().

Referenced by ACE_OutputCDR::append_longdouble(), and operator>>().

00684 {
00685   return this->read_16 (&x);
00686 }

ACE_INLINE ACE_CDR::Boolean ACE_InputCDR::read_longdouble_array ACE_CDR::LongDouble x,
ACE_CDR::ULong  length
 

The buffer x must be large enough to contain length elements. Return false on failure and true on success.

Definition at line 902 of file CDR_Stream.inl.

References length(), read_array(), and ACE_CDR::ULong.

00904 {
00905   // Make sure the length of the array isn't greater than the length of
00906   // the stream.
00907   if (length * ACE_CDR::LONGDOUBLE_SIZE > this->length ())
00908     {
00909       this->good_bit_ = false;
00910       return false;
00911     }
00912   return this->read_array (x,
00913                            ACE_CDR::LONGDOUBLE_SIZE,
00914                            ACE_CDR::LONGDOUBLE_ALIGN,
00915                            length);
00916 }

ACE_INLINE ACE_CDR::Boolean ACE_InputCDR::read_longlong ACE_CDR::LongLong x  ) 
 

Return false on failure and true on success.

Definition at line 656 of file CDR_Stream.inl.

References ACE_CDR::LongLong, and read_8().

Referenced by ACE_OutputCDR::append_longlong(), and operator>>().

00657 {
00658   void *temp = &x;
00659   return this->read_8 (reinterpret_cast<ACE_CDR::ULongLong*> (temp));
00660 }

ACE_INLINE ACE_CDR::Boolean ACE_InputCDR::read_longlong_array ACE_CDR::LongLong x,
ACE_CDR::ULong  length
 

The buffer x must be large enough to contain length elements. Return false on failure and true on success.

Definition at line 829 of file CDR_Stream.inl.

References length(), ACE_CDR::LongLong, read_array(), and ACE_CDR::ULong.

00831 {
00832   // Make sure the length of the array isn't greater than the length of
00833   // the stream.
00834   if (length * ACE_CDR::LONGLONG_SIZE > this->length ())
00835     {
00836       this->good_bit_ = false;
00837       return false;
00838     }
00839 
00840   return this->read_array (x,
00841                            ACE_CDR::LONGLONG_SIZE,
00842                            ACE_CDR::LONGLONG_ALIGN,
00843                            length);
00844 }

ACE_INLINE ACE_CDR::Boolean ACE_InputCDR::read_octet ACE_CDR::Octet x  ) 
 

Return false on failure and true on success.

Definition at line 600 of file CDR_Stream.inl.

References ACE_CDR::Octet, and read_1().

Referenced by ACE_InputCDR(), ACE_OutputCDR::append_octet(), operator>>(), and read_boolean().

00601 {
00602   return this->read_1 (&x);
00603 }

ACE_INLINE ACE_CDR::Boolean ACE_InputCDR::read_octet_array ACE_CDR::Octet x,
ACE_CDR::ULong  length
 

The buffer x must be large enough to contain length elements. Return false on failure and true on success.

Definition at line 739 of file CDR_Stream.inl.

References length(), ACE_CDR::Octet, read_array(), and ACE_CDR::ULong.

00741 {
00742   // Make sure the length of the array isn't greater than the length of
00743   // the stream.
00744   if (length * ACE_CDR::OCTET_SIZE > this->length ())
00745     {
00746       this->good_bit_ = false;
00747       return false;
00748     }
00749 
00750   return this->read_array (x,
00751                            ACE_CDR::OCTET_SIZE,
00752                            ACE_CDR::OCTET_ALIGN,
00753                            length);
00754 }

ACE_INLINE ACE_CDR::Boolean ACE_InputCDR::read_short ACE_CDR::Short x  ) 
 

Return false on failure and true on success.

Definition at line 627 of file CDR_Stream.inl.

References read_2(), and ACE_CDR::Short.

Referenced by ACE_OutputCDR::append_short(), and operator>>().

00628 {
00629   void *temp = &x;
00630   return this->read_2 (reinterpret_cast<ACE_CDR::UShort*> (temp));
00631 }

ACE_INLINE ACE_CDR::Boolean ACE_InputCDR::read_short_array ACE_CDR::Short x,
ACE_CDR::ULong  length
 

The buffer x must be large enough to contain length elements. Return false on failure and true on success.

Definition at line 757 of file CDR_Stream.inl.

References length(), read_array(), ACE_CDR::Short, and ACE_CDR::ULong.

00759 {
00760   // Make sure the length of the array isn't greater than the length of
00761   // the stream.
00762   if (length * ACE_CDR::SHORT_SIZE > this->length ())
00763     {
00764       this->good_bit_ = false;
00765       return false;
00766     }
00767 
00768   return this->read_array (x,
00769                            ACE_CDR::SHORT_SIZE,
00770                            ACE_CDR::SHORT_ALIGN,
00771                            length);
00772 }

ACE_CDR::Boolean ACE_InputCDR::read_string ACE_CString x  ) 
 

Return false on failure and true on success.

Definition at line 1183 of file CDR_Stream.cpp.

References ACE_CString, ACE_CDR::Char, and read_string().

01184 {
01185   ACE_CDR::Char * data = 0;
01186   if (this->read_string (data))
01187     {
01188       ACE_Auto_Basic_Array_Ptr<ACE_CDR::Char> safe_data (data);
01189       x = data;
01190       return true;
01191     }
01192 
01193   x = "";
01194   return (this->good_bit_ = false);
01195 }

ACE_CDR::Boolean ACE_InputCDR::read_string ACE_CDR::Char *&  x  ) 
 

Return false on failure and true on success.

Definition at line 1134 of file CDR_Stream.cpp.

References ACE_NEW_RETURN, ACE_CDR::Char, length(), read_char_array(), ACE_Char_Codeset_Translator::read_string(), read_ulong(), ACE_Auto_Basic_Array_Ptr< X >::release(), ACE_OS::strcpy(), and ACE_CDR::ULong.

Referenced by ACE_OutputCDR::append_string(), operator>>(), and read_string().

01135 {
01136   // @@ This is a slight violation of "Optimize for the common case",
01137   // i.e. normally the translator will be 0, but OTOH the code is
01138   // smaller and should be better for the cache ;-) ;-)
01139   if (this->char_translator_ != 0)
01140     {
01141       this->good_bit_ = this->char_translator_->read_string (*this, x);
01142       return this->good_bit_;
01143     }
01144 
01145   ACE_CDR::ULong len = 0;
01146 
01147   if (!this->read_ulong (len))
01148     return false;
01149 
01150   // A check for the length being too great is done later in the
01151   // call to read_char_array but we want to have it done before
01152   // the memory is allocated.
01153   if (len > 0 && len <= this->length())
01154     {
01155       ACE_NEW_RETURN (x,
01156                       ACE_CDR::Char[len],
01157                       0);
01158 
01159       ACE_Auto_Basic_Array_Ptr<ACE_CDR::Char> safe_data (x);
01160 
01161       if (this->read_char_array (x, len))
01162         {
01163           (void) safe_data.release ();
01164           return true;
01165         }
01166     }
01167   else if (len == 0)
01168     {
01169       // Convert any null strings to empty strings since empty
01170       // strings can cause crashes. (See bug 58.)
01171       ACE_NEW_RETURN (x,
01172                       ACE_CDR::Char[1],
01173                       0);
01174       ACE_OS::strcpy (const_cast<char *&> (x), "");
01175       return true;
01176     }
01177 
01178   x = 0;
01179   return (this->good_bit_ = false);
01180 }

ACE_INLINE ACE_CDR::Boolean ACE_InputCDR::read_ulong ACE_CDR::ULong x  ) 
 

Return false on failure and true on success.

Definition at line 649 of file CDR_Stream.inl.

References read_4(), and ACE_CDR::ULong.

Referenced by ACE_OutputCDR::append_ulong(), operator>>(), read_string(), read_wstring(), skip_string(), and skip_wstring().

00650 {
00651   return this->read_4 (&x);
00652 }

ACE_INLINE ACE_CDR::Boolean ACE_InputCDR::read_ulong_array ACE_CDR::ULong x,
ACE_CDR::ULong  length
 

The buffer x must be large enough to contain length elements. Return false on failure and true on success.

Definition at line 811 of file CDR_Stream.inl.

References length(), read_array(), and ACE_CDR::ULong.

00813 {
00814   // Make sure the length of the array isn't greater than the length of
00815   // the stream.
00816   if (length * ACE_CDR::LONG_SIZE > this->length ())
00817     {
00818       this->good_bit_ = false;
00819       return false;
00820     }
00821 
00822   return this->read_array (x,
00823                            ACE_CDR::LONG_SIZE,
00824                            ACE_CDR::LONG_ALIGN,
00825                            length);
00826 }

ACE_INLINE ACE_CDR::Boolean ACE_InputCDR::read_ulonglong ACE_CDR::ULongLong x  ) 
 

Return false on failure and true on success.

Definition at line 663 of file CDR_Stream.inl.

References read_8(), and ACE_CDR::ULongLong.

Referenced by ACE_OutputCDR::append_ulonglong(), and operator>>().

00664 {
00665   return this->read_8 (&x);
00666 }

ACE_INLINE ACE_CDR::Boolean ACE_InputCDR::read_ulonglong_array ACE_CDR::ULongLong x,
ACE_CDR::ULong  length
 

The buffer x must be large enough to contain length elements. Return false on failure and true on success.

Definition at line 847 of file CDR_Stream.inl.

References length(), read_array(), ACE_CDR::ULong, and ACE_CDR::ULongLong.

00849 {
00850   // Make sure the length of the array isn't greater than the length of
00851   // the stream.
00852   if (length * ACE_CDR::LONGLONG_SIZE > this->length ())
00853     {
00854       this->good_bit_ = false;
00855       return false;
00856     }
00857 
00858   return this->read_array (x,
00859                            ACE_CDR::LONGLONG_SIZE,
00860                            ACE_CDR::LONGLONG_ALIGN,
00861                            length);
00862 }

ACE_INLINE ACE_CDR::Boolean ACE_InputCDR::read_ushort ACE_CDR::UShort x  ) 
 

Return false on failure and true on success.

Definition at line 634 of file CDR_Stream.inl.

References read_2(), and ACE_CDR::UShort.

Referenced by ACE_OutputCDR::append_ushort(), and operator>>().

00635 {
00636   return this->read_2 (&x);
00637 }

ACE_INLINE ACE_CDR::Boolean ACE_InputCDR::read_ushort_array ACE_CDR::UShort x,
ACE_CDR::ULong  length
 

The buffer x must be large enough to contain length elements. Return false on failure and true on success.

Definition at line 775 of file CDR_Stream.inl.

References length(), read_array(), ACE_CDR::ULong, and ACE_CDR::UShort.

00777 {
00778   // Make sure the length of the array isn't greater than the length of
00779   // the stream.
00780   if (length * ACE_CDR::SHORT_SIZE > this->length ())
00781     {
00782       this->good_bit_ = false;
00783       return false;
00784     }
00785 
00786   return this->read_array (x,
00787                            ACE_CDR::SHORT_SIZE,
00788                            ACE_CDR::SHORT_ALIGN,
00789                            length);
00790 }

ACE_CDR::Boolean ACE_InputCDR::read_wchar ACE_CDR::WChar x  ) 
 

Return false on failure and true on success.

Definition at line 1035 of file CDR_Stream.cpp.

References ACE_CDR::Octet, read_1(), read_2(), read_4(), read_array(), ACE_WChar_Codeset_Translator::read_wchar(), ACE_CDR::Short, ACE_CDR::UShort, and ACE_CDR::WChar.

Referenced by ACE_OutputCDR::append_wchar(), and operator>>().

01036 {
01037   if (this->wchar_translator_ != 0)
01038     {
01039       this->good_bit_ = this->wchar_translator_->read_wchar (*this,x);
01040       return this->good_bit_;
01041     }
01042   if (ACE_OutputCDR::wchar_maxbytes_ == 0)
01043     {
01044       errno = EACCES;
01045       return (this->good_bit_ = false);
01046     }
01047 
01048   if (ACE_OutputCDR::wchar_maxbytes_ == sizeof (ACE_CDR::WChar))
01049     {
01050       if (static_cast<ACE_CDR::Short> (major_version_) == 1
01051           && static_cast<ACE_CDR::Short> (minor_version_) == 2)
01052         {
01053           ACE_CDR::Octet len;
01054 
01055           if (this->read_1 (&len))
01056             return this->read_array
01057               (reinterpret_cast<ACE_CDR::Octet*> (&x),
01058                static_cast<ACE_CDR::ULong> (len),
01059                ACE_CDR::OCTET_ALIGN,
01060                1);
01061 
01062           else
01063             return (this->good_bit_ = false);
01064         }
01065 
01066       void * const temp = &x;
01067       if (sizeof (ACE_CDR::WChar) == 2)
01068         return this->read_2 (reinterpret_cast<ACE_CDR::UShort *> (temp));
01069       else
01070         return this->read_4 (reinterpret_cast<ACE_CDR::ULong *> (temp));
01071     }
01072 
01073   if (static_cast<ACE_CDR::Short> (major_version_) == 1
01074       && static_cast<ACE_CDR::Short> (minor_version_) == 2)
01075     {
01076       ACE_CDR::Octet len;
01077 
01078       if (this->read_1 (&len))
01079         {
01080           if (len == 2)
01081             {
01082               ACE_CDR::Short sx;
01083               if (this->read_array
01084                   (reinterpret_cast<ACE_CDR::Octet*> (&sx),
01085                    static_cast<ACE_CDR::ULong> (len),
01086                    ACE_CDR::OCTET_ALIGN,
01087                    1))
01088                 {
01089                   x = static_cast<ACE_CDR::WChar> (sx);
01090                   return true;
01091                 }
01092             }
01093           else
01094             {
01095               ACE_CDR::Octet ox;
01096               if (this->read_array
01097                   (reinterpret_cast<ACE_CDR::Octet*> (&ox),
01098                    static_cast<ACE_CDR::ULong> (len),
01099                    ACE_CDR::OCTET_ALIGN,
01100                    1))
01101                 {
01102                   x = static_cast<ACE_CDR::WChar> (ox);
01103                   return true;
01104                 }
01105             }
01106         }
01107     }
01108   else
01109     {
01110       if (ACE_OutputCDR::wchar_maxbytes_ == 2)
01111         {
01112           ACE_CDR::UShort sx;
01113           if (this->read_2 (reinterpret_cast<ACE_CDR::UShort *> (&sx)))
01114             {
01115               x = static_cast<ACE_CDR::WChar> (sx);
01116               return true;
01117             }
01118         }
01119       else
01120         {
01121           ACE_CDR::Octet ox;
01122           if (this->read_1 (&ox))
01123             {
01124               x = static_cast<ACE_CDR::WChar> (ox);
01125               return true;
01126             }
01127 
01128         }
01129     }
01130   return (this->good_bit_ = false);
01131 }

ACE_INLINE ACE_CDR::Boolean ACE_InputCDR::read_wchar_array ACE_CDR::WChar x,
ACE_CDR::ULong  length
 

The buffer x must be large enough to contain length elements. Return false on failure and true on success.

Definition at line 715 of file CDR_Stream.inl.

References length(), read_array(), ACE_WChar_Codeset_Translator::read_wchar_array(), read_wchar_array_i(), ACE_CDR::ULong, and ACE_CDR::WChar.

Referenced by operator>>(), and read_wstring().

00717 {
00718   // Make sure the length of the array isn't greater than the length of
00719   // the stream.
00720   if (length * ACE_OutputCDR::wchar_maxbytes_ > this->length ())
00721     {
00722       this->good_bit_ = false;
00723       return false;
00724     }
00725 
00726   if (this->wchar_translator_ != 0)
00727     return this->wchar_translator_->read_wchar_array (*this, x, length);
00728   if (ACE_OutputCDR::wchar_maxbytes_ != sizeof (ACE_CDR::WChar))
00729     return this->read_wchar_array_i (x, length);
00730   return this->read_array (x,
00731                            sizeof (ACE_CDR::WChar),
00732                            sizeof (ACE_CDR::WChar) == 2
00733                            ? ACE_CDR::SHORT_ALIGN
00734                            : ACE_CDR::LONG_ALIGN,
00735                            length);
00736 }

ACE_CDR::Boolean ACE_InputCDR::read_wchar_array_i ACE_CDR::WChar x,
ACE_CDR::ULong  length
[private]
 

On those occasions when the native codeset for wchar is smaller than the size of a wchar_t, such as using UTF-16 with a 4-byte wchar_t, a special form of reading the array is needed. Actually, this should be a default translator.

Definition at line 1329 of file CDR_Stream.cpp.

References adjust(), ACE_CDR::swap_2(), ACE_CDR::ULong, ACE_CDR::UShort, and ACE_CDR::WChar.

Referenced by read_wchar_array().

01331 {
01332   if (length == 0)
01333     return true;
01334   char* buf = 0;
01335   size_t const align = (ACE_OutputCDR::wchar_maxbytes_ == 2) ?
01336     ACE_CDR::SHORT_ALIGN :
01337     ACE_CDR::OCTET_ALIGN;
01338 
01339   if (this->adjust (ACE_OutputCDR::wchar_maxbytes_ * length, align, buf) == 0)
01340     {
01341       if (ACE_OutputCDR::wchar_maxbytes_ == 2)
01342         {
01343           ACE_CDR::UShort *sb = reinterpret_cast<ACE_CDR::UShort *> (buf);
01344           for (size_t i = 0; i < length; ++i)
01345 #if defined (ACE_DISABLE_SWAP_ON_READ)
01346             x[i] = static_cast<ACE_CDR::WChar> (sb[i]);
01347 #else
01348             if (!this->do_byte_swap_)
01349               x[i] = static_cast<ACE_CDR::WChar> (sb[i]);
01350             else
01351               {
01352                 ACE_CDR::UShort sx;
01353                 ACE_CDR::swap_2 (&buf[i * 2], reinterpret_cast<char *> (&sx));
01354                 x[i] = static_cast<ACE_CDR::WChar> (sx);
01355               }
01356 #endif /* ACE_DISABLE_SWAP_ON_READ */
01357         }
01358       else
01359         {
01360           for (size_t i = 0; i < length; ++i)
01361             x[i] = static_cast<ACE_CDR::Octet> (buf[i]);
01362         }
01363       return this->good_bit_;
01364     }
01365   return false;
01366 }

ACE_CDR::Boolean ACE_InputCDR::read_wstring ACE_CDR::WChar *&  x  ) 
 

Return false on failure and true on success.

Definition at line 1198 of file CDR_Stream.cpp.

References ACE_auto_ptr_reset(), ACE_NEW_RETURN, length(), read_ulong(), read_wchar_array(), ACE_WChar_Codeset_Translator::read_wstring(), ACE_Auto_Basic_Array_Ptr< X >::release(), ACE_CDR::ULong, and ACE_CDR::WChar.

Referenced by ACE_OutputCDR::append_wstring(), and operator>>().

01199 {
01200   // @@ This is a slight violation of "Optimize for the common case",
01201   // i.e. normally the translator will be 0, but OTOH the code is
01202   // smaller and should be better for the cache ;-) ;-)
01203   if (this->wchar_translator_ != 0)
01204     {
01205       this->good_bit_ = this->wchar_translator_->read_wstring (*this, x);
01206       return this->good_bit_;
01207     }
01208   if (ACE_OutputCDR::wchar_maxbytes_ == 0)
01209     {
01210       errno = EACCES;
01211       return (this->good_bit_ = false);
01212     }
01213 
01214   ACE_CDR::ULong len = 0;
01215   if (!this->read_ulong (len))
01216     return false;
01217 
01218   // A check for the length being too great is done later in the
01219   // call to read_char_array but we want to have it done before
01220   // the memory is allocated.
01221   if (len > 0 && len <= this->length ())
01222     {
01223       ACE_Auto_Basic_Array_Ptr<ACE_CDR::WChar> safe_data;
01224 
01225       if (static_cast<ACE_CDR::Short> (this->major_version_) == 1
01226           && static_cast<ACE_CDR::Short> (this->minor_version_) == 2)
01227         {
01228           len /= ACE_OutputCDR::wchar_maxbytes_;
01229 
01230           //allocating one extra for the null character needed by applications
01231           ACE_NEW_RETURN (x,
01232                           ACE_CDR::WChar [len + 1],
01233                           false);
01234 
01235           ACE_auto_ptr_reset (safe_data, x);
01236 
01237           if (this->read_wchar_array (x, len))
01238             {
01239 
01240               //Null character used by applications to find the end of
01241               //the wstring
01242               //Is this okay with the GIOP 1.2 spec??
01243               x[len] = '\x00';
01244 
01245               (void) safe_data.release ();
01246 
01247               return true;
01248             }
01249         }
01250       else
01251         {
01252           ACE_NEW_RETURN (x,
01253                           ACE_CDR::WChar [len],
01254                           false);
01255 
01256           ACE_auto_ptr_reset (safe_data, x);
01257 
01258           if (this->read_wchar_array (x, len))
01259             {
01260               (void) safe_data.release ();
01261 
01262               return true;
01263             }
01264         }
01265     }
01266   else if (len == 0)
01267     {
01268       // Convert any null strings to empty strings since empty
01269       // strings can cause crashes. (See bug 58.)
01270       ACE_NEW_RETURN (x,
01271                       ACE_CDR::WChar[1],
01272                       false);
01273       x[0] = '\x00';
01274       return true;
01275     }
01276 
01277   this->good_bit_ = false;
01278   x = 0;
01279   return false;
01280 }

void ACE_InputCDR::reset const ACE_Message_Block data,
int  byte_order
 

Re-initialize the CDR stream, copying the contents of the chain of message_blocks starting from data.

Definition at line 1580 of file CDR_Stream.cpp.

References ACE_CDR::consolidate(), and reset_byte_order().

Referenced by ACE_InputCDR().

01582 {
01583   this->reset_byte_order (byte_order);
01584   ACE_CDR::consolidate (&this->start_, data);
01585 }

ACE_INLINE void ACE_InputCDR::reset_byte_order int  byte_order  ) 
 

After reading and partially parsing the contents the user can detect a change in the byte order, this method will let him/her change it.

Definition at line 1446 of file CDR_Stream.inl.

References ACE_CDR_BYTE_ORDER.

Referenced by reset().

01447 {
01448   this->do_byte_swap_ = (byte_order != ACE_CDR_BYTE_ORDER);
01449 }

void ACE_InputCDR::reset_contents void   ) 
 

Re-initialize the CDR stream, forgetting about the old contents of the stream and allocating a new buffer (from the allocators).

Definition at line 1777 of file CDR_Stream.cpp.

References ACE_Message_Block::clr_self_flags(), and ACE_Message_Block::data_block().

Referenced by steal_from().

01778 {
01779   this->start_.data_block (this->start_.data_block ()->clone_nocopy ());
01780 
01781   // Reset the flags...
01782   this->start_.clr_self_flags (ACE_Message_Block::DONT_DELETE);
01783 }

ACE_INLINE void ACE_InputCDR::set_version ACE_CDR::Octet  major,
ACE_CDR::Octet  minor
 

Set the underlying GIOP version..

Definition at line 1484 of file CDR_Stream.inl.

References ACE_CDR::Octet.

01485 {
01486   this->major_version_ = major;
01487   this->minor_version_ = minor;
01488 }

ACE_INLINE ACE_CDR::Boolean ACE_InputCDR::skip_boolean void   ) 
 

Return false on failure and true on success.

Definition at line 932 of file CDR_Stream.inl.

References skip_octet().

00933 {
00934   return this->skip_octet () && this->good_bit_;
00935 }

ACE_CDR::Boolean ACE_InputCDR::skip_bytes size_t  n  ) 
 

Skip n bytes in the CDR stream.

Returns:
false on failure and true on success.

Definition at line 1557 of file CDR_Stream.cpp.

References rd_ptr(), and wr_ptr().

Referenced by skip_wchar(), and skip_wstring().

01558 {
01559   if (this->rd_ptr () + len <= this->wr_ptr ())
01560     {
01561       this->rd_ptr (len);
01562       return true;
01563     }
01564   this->good_bit_ = false;
01565   return false;
01566 }

ACE_INLINE ACE_CDR::Boolean ACE_InputCDR::skip_char void   ) 
 

Return false on failure and true on success.

Definition at line 926 of file CDR_Stream.inl.

References skip_octet().

00927 {
00928   return this->skip_octet ();  // sizeof (Char) == sizeof (Octet)
00929 }

ACE_INLINE ACE_CDR::Boolean ACE_InputCDR::skip_double void   ) 
 

Return false on failure and true on success.

Definition at line 983 of file CDR_Stream.inl.

References skip_ulonglong().

00984 {
00985   return this->skip_ulonglong ();  // sizeof(Double) == sizeof (ULongLong)
00986 }

ACE_INLINE ACE_CDR::Boolean ACE_InputCDR::skip_float void   ) 
 

Return false on failure and true on success.

Definition at line 977 of file CDR_Stream.inl.

References skip_ulong().

00978 {
00979   return this->skip_ulong ();  // sizeof(Float) == sizeof (ULong)
00980 }

ACE_INLINE ACE_CDR::Boolean ACE_InputCDR::skip_long void   ) 
 

Return false on failure and true on success.

Definition at line 958 of file CDR_Stream.inl.

References skip_ulong().

00959 {
00960   return this->skip_ulong ();  // sizeof (Long) == sizeof (ULong)
00961 }

ACE_INLINE ACE_CDR::Boolean ACE_InputCDR::skip_longdouble void   ) 
 

Return false on failure and true on success.

Definition at line 989 of file CDR_Stream.inl.

References read_16().

00990 {
00991   ACE_CDR::LongDouble x;
00992   return this->read_16 (&x);
00993 }

ACE_INLINE ACE_CDR::Boolean ACE_InputCDR::skip_longlong void   ) 
 

Return false on failure and true on success.

Definition at line 971 of file CDR_Stream.inl.

References skip_ulonglong().

00972 {
00973   return this->skip_ulonglong ();  // sizeof (LongLong) == sizeof (ULongLong)
00974 }

ACE_INLINE ACE_CDR::Boolean ACE_InputCDR::skip_octet void   ) 
 

Return false on failure and true on success.

Definition at line 919 of file CDR_Stream.inl.

References ACE_CDR::Octet, and read_1().

Referenced by skip_boolean(), and skip_char().

00920 {
00921   ACE_CDR::Octet x;
00922   return this->read_1 (&x);
00923 }

ACE_INLINE ACE_CDR::Boolean ACE_InputCDR::skip_short void   ) 
 

Return false on failure and true on success.

Definition at line 945 of file CDR_Stream.inl.

References skip_ushort().

00946 {
00947   return this->skip_ushort ();
00948 }

ACE_CDR::Boolean ACE_InputCDR::skip_string void   ) 
 

Definition at line 1521 of file CDR_Stream.cpp.

References rd_ptr(), read_ulong(), ACE_CDR::ULong, and wr_ptr().

01522 {
01523   ACE_CDR::ULong len = 0;
01524   if (this->read_ulong (len))
01525     {
01526       if (this->rd_ptr () + len <= this->wr_ptr ())
01527         {
01528           this->rd_ptr (len);
01529           return true;
01530         }
01531       this->good_bit_ = false;
01532     }
01533   return false;
01534 }

ACE_INLINE ACE_CDR::Boolean ACE_InputCDR::skip_ulong void   ) 
 

Return false on failure and true on success.

Definition at line 951 of file CDR_Stream.inl.

References read_4(), and ACE_CDR::ULong.

Referenced by skip_float(), and skip_long().

00952 {
00953   ACE_CDR::ULong x;
00954   return this->read_4 (&x);
00955 }

ACE_INLINE ACE_CDR::Boolean ACE_InputCDR::skip_ulonglong void   ) 
 

Return false on failure and true on success.

Definition at line 964 of file CDR_Stream.inl.

References read_8(), and ACE_CDR::ULongLong.

Referenced by skip_double(), and skip_longlong().

00965 {
00966   ACE_CDR::ULongLong x;
00967   return this->read_8 (&x);
00968 }

ACE_INLINE ACE_CDR::Boolean ACE_InputCDR::skip_ushort void   ) 
 

Return false on failure and true on success.

Definition at line 938 of file CDR_Stream.inl.

References read_2(), and ACE_CDR::UShort.

Referenced by skip_short().

00939 {
00940   ACE_CDR::UShort x;
00941   return this->read_2 (&x);
00942 }

ACE_CDR::Boolean ACE_InputCDR::skip_wchar void   ) 
 

Return false on failure and true on success.

Definition at line 1012 of file CDR_Stream.cpp.

References ACE_CDR::Octet, read_1(), read_2(), read_4(), skip_bytes(), and ACE_CDR::WChar.

Referenced by skip_wstring().

01013 {
01014   if (static_cast<ACE_CDR::Short> (major_version_) == 1
01015       && static_cast<ACE_CDR::Short> (minor_version_) == 2)
01016     {
01017       ACE_CDR::Octet len;
01018       if (this->read_1 (&len))
01019         return this->skip_bytes (static_cast<size_t> (len));
01020     }
01021   else
01022     {
01023       ACE_CDR::WChar x;
01024       void * const temp = &x;
01025       if (ACE_OutputCDR::wchar_maxbytes_ == 2)
01026         return this->read_2 (reinterpret_cast<ACE_CDR::UShort *> (temp));
01027       else
01028         return this->read_4 (reinterpret_cast<ACE_CDR::ULong *> (temp));
01029     }
01030 
01031   return (this->good_bit_ = false);
01032 }

ACE_CDR::Boolean ACE_InputCDR::skip_wstring void   ) 
 

The next field must be a string, this method skips it. It is useful in parsing a TypeCode.

Returns:
false on failure and true on success.

Definition at line 1537 of file CDR_Stream.cpp.

References ACE_CDR::Boolean, read_ulong(), skip_bytes(), skip_wchar(), and ACE_CDR::ULong.

01538 {
01539   ACE_CDR::Boolean continue_skipping = true;
01540   ACE_CDR::ULong len = 0;
01541 
01542   continue_skipping = read_ulong (len);
01543 
01544   if (continue_skipping && len != 0)
01545     {
01546       if (static_cast<ACE_CDR::Short> (this->major_version_) == 1
01547             && static_cast<ACE_CDR::Short> (this->minor_version_) == 2)
01548           continue_skipping = this->skip_bytes ((size_t)len);
01549       else
01550         while (continue_skipping && len--)
01551           continue_skipping = this->skip_wchar ();
01552     }
01553   return continue_skipping;
01554 }

ACE_INLINE const ACE_Message_Block * ACE_InputCDR::start void   )  const
 

Returns:
The start of the message block chain for this CDR stream.
Note:
In the current implementation the chain has length 1, but we are planning to change that.

Definition at line 1052 of file CDR_Stream.inl.

01053 {
01054   return &this->start_;
01055 }

ACE_Message_Block * ACE_InputCDR::steal_contents void   ) 
 

Steal the contents from the current CDR.

Definition at line 1762 of file CDR_Stream.cpp.

References ACE_Data_Block::clone(), ACE_Message_Block::clone(), ACE_Message_Block::clr_self_flags(), ACE_Message_Block::data_block(), and ACE_CDR::mb_align().

01763 {
01764   ACE_Message_Block* block = this->start_.clone ();
01765   this->start_.data_block (block->data_block ()->clone ());
01766 
01767   // If at all our message had a DONT_DELETE flag set, just clear it
01768   // off.
01769   this->start_.clr_self_flags (ACE_Message_Block::DONT_DELETE);
01770 
01771   ACE_CDR::mb_align (&this->start_);
01772 
01773   return block;
01774 }

void ACE_InputCDR::steal_from ACE_InputCDR cdr  ) 
 

Steal the contents of cdr and make a shallow copy into this stream.

Definition at line 1588 of file CDR_Stream.cpp.

References ACE_Message_Block::clr_self_flags(), ACE_Message_Block::data_block(), do_byte_swap_, ACE_Data_Block::duplicate(), major_version_, minor_version_, ACE_Message_Block::rd_ptr(), reset_contents(), start_, and ACE_Message_Block::wr_ptr().

01589 {
01590   this->do_byte_swap_ = cdr.do_byte_swap_;
01591   this->start_.data_block (cdr.start_.data_block ()->duplicate ());
01592 
01593   // If the message block had a DONT_DELETE flags, just clear it off..
01594   this->start_.clr_self_flags (ACE_Message_Block::DONT_DELETE);
01595   this->start_.rd_ptr (cdr.start_.rd_ptr ());
01596 
01597   this->start_.wr_ptr (cdr.start_.wr_ptr ());
01598   this->major_version_ = cdr.major_version_;
01599   this->minor_version_ = cdr.minor_version_;
01600   cdr.reset_contents ();
01601 }

ACE_INLINE void ACE_InputCDR::wchar_translator ACE_WChar_Codeset_Translator  ) 
 

Definition at line 1517 of file CDR_Stream.inl.

01518 {
01519   this->wchar_translator_ = wctran;
01520 }

ACE_INLINE ACE_WChar_Codeset_Translator * ACE_InputCDR::wchar_translator void   )  const
 

Definition at line 1504 of file CDR_Stream.inl.

01505 {
01506   return this->wchar_translator_;
01507 }

ACE_INLINE char * ACE_InputCDR::wr_ptr void   ) 
 

Returns the current position for the wr_ptr.

Definition at line 1014 of file CDR_Stream.inl.

References ACE_Message_Block::wr_ptr().

Referenced by adjust(), align_read_ptr(), clone_from(), read_1(), skip_bytes(), and skip_string().

01015 {
01016   return this->start_.wr_ptr ();
01017 }


Friends And Related Function Documentation

friend class ACE_Char_Codeset_Translator [friend]
 

The Codeset translators need access to some private members to efficiently marshal arrays For reading from an output CDR stream.

Definition at line 557 of file CDR_Stream.h.

friend class ACE_WChar_Codeset_Translator [friend]
 

Definition at line 558 of file CDR_Stream.h.


Member Data Documentation

ACE_Char_Codeset_Translator* ACE_InputCDR::char_translator_ [protected]
 

If not nil, invoke for translation of character and string data.

Definition at line 937 of file CDR_Stream.h.

Referenced by clone_from(), and operator=().

bool ACE_InputCDR::do_byte_swap_ [protected]
 

The CDR stream byte order does not match the one on the machine, swapping is needed while reading.

Definition at line 927 of file CDR_Stream.h.

Referenced by clone_from(), exchange_data_blocks(), operator=(), and steal_from().

bool ACE_InputCDR::good_bit_ [protected]
 

set to false when an error occurs.

Definition at line 930 of file CDR_Stream.h.

ACE_CDR::Octet ACE_InputCDR::major_version_ [protected]
 

The GIOP versions for this stream.

Definition at line 933 of file CDR_Stream.h.

Referenced by clone_from(), exchange_data_blocks(), ACE_WChar_Codeset_Translator::major_version(), ACE_Char_Codeset_Translator::major_version(), operator=(), and steal_from().

ACE_CDR::Octet ACE_InputCDR::minor_version_ [protected]
 

Definition at line 934 of file CDR_Stream.h.

Referenced by clone_from(), exchange_data_blocks(), ACE_WChar_Codeset_Translator::minor_version(), ACE_Char_Codeset_Translator::minor_version(), operator=(), and steal_from().

ACE_Message_Block ACE_InputCDR::start_ [protected]
 

The start of the chain of message blocks, even though in the current version the chain always has length 1.

Definition at line 923 of file CDR_Stream.h.

Referenced by ACE_InputCDR(), clone_from(), exchange_data_blocks(), operator=(), and steal_from().

ACE_WChar_Codeset_Translator* ACE_InputCDR::wchar_translator_ [protected]
 

Definition at line 938 of file CDR_Stream.h.

Referenced by clone_from().


The documentation for this class was generated from the following files:
Generated on Sun Jan 27 12:55:12 2008 for ACE by doxygen 1.3.6