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 <rhs> 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..
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)
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)
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 offset 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

Classes

struct  to_boolean
struct  to_char
struct  to_octet
struct  to_string
struct  to_wchar
struct  to_wstring
struct  Transfer_Contents

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 618 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 850 of file CDR_Stream.cpp.

References ACE_NEW, start_, and ACE_Message_Block::wr_ptr().

00855   : start_ (buf, bufsiz),
00856     do_byte_swap_ (byte_order != ACE_CDR_BYTE_ORDER),
00857     good_bit_ (true),
00858     major_version_ (major_version),
00859     minor_version_ (minor_version),
00860     char_translator_ (0),
00861     wchar_translator_ (0)
00862 {
00863   this->start_.wr_ptr (bufsiz);
00864 
00865 #if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1)
00866   ACE_NEW (this->monitor_,
00867            ACE::Monitor_Control::Size_Monitor);
00868   this->monitor_->receive (bufsiz);
00869 #endif /* ACE_HAS_MONITOR_POINTS==1 */
00870 }

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 872 of file CDR_Stream.cpp.

References ACE_NEW.

00876   : start_ (bufsiz),
00877     do_byte_swap_ (byte_order != ACE_CDR_BYTE_ORDER),
00878     good_bit_ (true),
00879     major_version_ (major_version),
00880     minor_version_ (minor_version),
00881     char_translator_ (0),
00882     wchar_translator_ (0)
00883 {
00884 #if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1)
00885   ACE_NEW (this->monitor_,
00886            ACE::Monitor_Control::Size_Monitor);
00887   this->monitor_->receive (bufsiz);
00888 #endif /* ACE_HAS_MONITOR_POINTS==1 */
00889 }

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

Definition at line 891 of file CDR_Stream.cpp.

References ACE_NEW, and reset().

00896   : start_ (0, ACE_Message_Block::MB_DATA, 0, 0, 0, lock),
00897     good_bit_ (true),
00898     major_version_ (major_version),
00899     minor_version_ (minor_version),
00900     char_translator_ (0),
00901     wchar_translator_ (0)
00902 {
00903 #if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1)
00904   ACE_NEW (this->monitor_,
00905            ACE::Monitor_Control::Size_Monitor);
00906   this->monitor_->receive (this->start_.total_size ());
00907 #endif /* ACE_HAS_MONITOR_POINTS==1 */
00908 
00909   this->reset (data, byte_order);
00910 }

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 <flag> indicates whether the <data> can be deleted by the CDR stream or not

Definition at line 912 of file CDR_Stream.cpp.

References ACE_NEW, and ACE_Data_Block::size().

00917   : start_ (data, flag),
00918     do_byte_swap_ (byte_order != ACE_CDR_BYTE_ORDER),
00919     good_bit_ (true),
00920     major_version_ (major_version),
00921     minor_version_ (minor_version),
00922     char_translator_ (0),
00923     wchar_translator_ (0)
00924 {
00925 #if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1)
00926   ACE_NEW (this->monitor_,
00927            ACE::Monitor_Control::Size_Monitor);
00928   this->monitor_->receive (data->size ());
00929 #endif /* ACE_HAS_MONITOR_POINTS==1 */
00930 }

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 932 of file CDR_Stream.cpp.

References ACE_NEW, ACE_Message_Block::base(), ACE_Message_Block::rd_ptr(), ACE_Data_Block::size(), and start_.

00939   : start_ (data, flag),
00940     do_byte_swap_ (byte_order != ACE_CDR_BYTE_ORDER),
00941     good_bit_ (true),
00942     major_version_ (major_version),
00943     minor_version_ (minor_version),
00944     char_translator_ (0),
00945     wchar_translator_ (0)
00946 {
00947   // Set the read pointer
00948   this->start_.rd_ptr (rd_pos);
00949 
00950   // Set the write pointer after doing a sanity check.
00951   char* wrpos = this->start_.base () + wr_pos;
00952 
00953   if (this->start_.end () >= wrpos)
00954     {
00955       this->start_.wr_ptr (wr_pos);
00956     }
00957 
00958 #if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1)
00959   ACE_NEW (this->monitor_,
00960            ACE::Monitor_Control::Size_Monitor);
00961   this->monitor_->receive (data->size ());
00962 #endif /* ACE_HAS_MONITOR_POINTS==1 */
00963 }

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 1054 of file CDR_Stream.cpp.

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

01055   : start_ (rhs.start_,
01056             ACE_CDR::MAX_ALIGNMENT),
01057     do_byte_swap_ (rhs.do_byte_swap_),
01058     good_bit_ (true),
01059     major_version_ (rhs.major_version_),
01060     minor_version_ (rhs.minor_version_),
01061     char_translator_ (rhs.char_translator_),
01062     wchar_translator_ (rhs.wchar_translator_)
01063 {
01064 #if !defined (ACE_LACKS_CDR_ALIGNMENT)
01065   char *buf = ACE_ptr_align_binary (rhs.start_.base (),
01066                                     ACE_CDR::MAX_ALIGNMENT);
01067 #else
01068   char *buf = rhs.start_.base ();
01069 #endif /* ACE_LACKS_CDR_ALIGNMENT */
01070 
01071   size_t rd_offset = rhs.start_.rd_ptr () - buf;
01072   size_t wr_offset = rhs.start_.wr_ptr () - buf;
01073   this->start_.rd_ptr (rd_offset);
01074   this->start_.wr_ptr (wr_offset);
01075 
01076 #if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1)
01077   ACE_NEW (this->monitor_,
01078            ACE::Monitor_Control::Size_Monitor);
01079   this->monitor_->receive (this->start_.total_size ());
01080 #endif /* ACE_HAS_MONITOR_POINTS==1 */
01081 }

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 965 of file CDR_Stream.cpp.

References ACE_NEW, ACE_ptr_align_binary(), ACE_Message_Block::base(), good_bit_, ACE_CDR::MAX_ALIGNMENT, ACE_Message_Block::rd_ptr(), ACE_Message_Block::space(), start_, and ACE_Message_Block::wr_ptr().

00968   : start_ (rhs.start_,
00969             ACE_CDR::MAX_ALIGNMENT),
00970     do_byte_swap_ (rhs.do_byte_swap_),
00971     good_bit_ (true),
00972     major_version_ (rhs.major_version_),
00973     minor_version_ (rhs.minor_version_),
00974     char_translator_ (rhs.char_translator_),
00975     wchar_translator_ (rhs.wchar_translator_)
00976 {
00977 #if !defined (ACE_LACKS_CDR_ALIGNMENT)
00978   // Align the base pointer assuming that the incoming stream is also
00979   // aligned the way we are aligned
00980   char *incoming_start = ACE_ptr_align_binary (rhs.start_.base (),
00981                                                ACE_CDR::MAX_ALIGNMENT);
00982 #else
00983   char *incoming_start = rhs.start_.base ();
00984 #endif /* ACE_LACKS_CDR_ALIGNMENT */
00985 
00986   const size_t newpos =
00987     (rhs.start_.rd_ptr() - incoming_start)  + offset;
00988 
00989   if (newpos <= this->start_.space ()
00990       && newpos + size <= this->start_.space ())
00991     {
00992       this->start_.rd_ptr (newpos);
00993       this->start_.wr_ptr (newpos + size);
00994     }
00995   else
00996     {
00997       this->good_bit_ = false;
00998     }
00999 
01000 #if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1)
01001   ACE_NEW (this->monitor_,
01002            ACE::Monitor_Control::Size_Monitor);
01003   this->monitor_->receive (this->start_.total_size ());
01004 #endif /* ACE_HAS_MONITOR_POINTS==1 */
01005 }

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 1007 of file CDR_Stream.cpp.

References ACE_CDR_BYTE_ORDER, ACE_NEW, ACE_ptr_align_binary(), ACE_Message_Block::base(), byte_order(), do_byte_swap_, good_bit_, ACE_CDR::MAX_ALIGNMENT, ACE_Message_Block::rd_ptr(), ACE_Message_Block::space(), start_, and ACE_Message_Block::wr_ptr().

01009   : start_ (rhs.start_,
01010             ACE_CDR::MAX_ALIGNMENT),
01011     do_byte_swap_ (rhs.do_byte_swap_),
01012     good_bit_ (true),
01013     major_version_ (rhs.major_version_),
01014     minor_version_ (rhs.minor_version_),
01015     char_translator_ (rhs.char_translator_),
01016     wchar_translator_ (rhs.wchar_translator_)
01017 {
01018 #if !defined (ACE_LACKS_CDR_ALIGNMENT)
01019   // Align the base pointer assuming that the incoming stream is also
01020   // aligned the way we are aligned
01021   char *incoming_start = ACE_ptr_align_binary (rhs.start_.base (),
01022                                                ACE_CDR::MAX_ALIGNMENT);
01023 #else
01024   char *incoming_start = rhs.start_.base ();
01025 #endif /* ACE_LACKS_CDR_ALIGNMENT */
01026 
01027   const size_t newpos =
01028     rhs.start_.rd_ptr() - incoming_start;
01029 
01030   if (newpos <= this->start_.space ()
01031       && newpos + size <= this->start_.space ())
01032     {
01033       // Notice that ACE_Message_Block::duplicate may leave the
01034       // wr_ptr() with a higher value than what we actually want.
01035       this->start_.rd_ptr (newpos);
01036       this->start_.wr_ptr (newpos + size);
01037 
01038       ACE_CDR::Octet byte_order = 0;
01039       (void) this->read_octet (byte_order);
01040       this->do_byte_swap_ = (byte_order != ACE_CDR_BYTE_ORDER);
01041     }
01042   else
01043     {
01044       this->good_bit_ = false;
01045     }
01046 
01047 #if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1)
01048   ACE_NEW (this->monitor_,
01049            ACE::Monitor_Control::Size_Monitor);
01050   this->monitor_->receive (this->start_.total_size ());
01051 #endif /* ACE_HAS_MONITOR_POINTS==1 */
01052 }

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 1127 of file CDR_Stream.cpp.

References ACE_NEW, ACE_OutputCDR::begin(), ACE_Message_Block::cont(), ACE_OutputCDR::end(), and ACE_CDR::mb_align().

01131   : start_ (rhs.total_length () + ACE_CDR::MAX_ALIGNMENT,
01132             ACE_Message_Block::MB_DATA,
01133             0,
01134             0,
01135             buffer_allocator,
01136             0,
01137             0,
01138             ACE_Time_Value::zero,
01139             ACE_Time_Value::max_time,
01140             data_block_allocator,
01141             message_block_allocator),
01142     do_byte_swap_ (rhs.do_byte_swap_),
01143     good_bit_ (true),
01144     major_version_ (rhs.major_version_),
01145     minor_version_ (rhs.minor_version_),
01146     char_translator_ (rhs.char_translator_),
01147     wchar_translator_ (rhs.wchar_translator_)
01148 {
01149   ACE_CDR::mb_align (&this->start_);
01150   for (const ACE_Message_Block *i = rhs.begin ();
01151        i != rhs.end ();
01152        i = i->cont ())
01153     {
01154       this->start_.copy (i->rd_ptr (), i->length ());
01155     }
01156 
01157 #if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1)
01158   ACE_NEW (this->monitor_,
01159            ACE::Monitor_Control::Size_Monitor);
01160   this->monitor_->receive (this->start_.total_size ());
01161 #endif /* ACE_HAS_MONITOR_POINTS==1 */
01162 }

ACE_InputCDR::ACE_InputCDR ( Transfer_Contents  rhs  ) 

Transfer the contents from <rhs> to a new CDR.

Definition at line 1083 of file CDR_Stream.cpp.

References ACE_NEW, 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().

01084   : start_ (x.rhs_.start_.data_block ()),
01085     do_byte_swap_ (x.rhs_.do_byte_swap_),
01086     good_bit_ (true),
01087     major_version_ (x.rhs_.major_version_),
01088     minor_version_ (x.rhs_.minor_version_),
01089     char_translator_ (x.rhs_.char_translator_),
01090     wchar_translator_ (x.rhs_.wchar_translator_)
01091 {
01092   this->start_.rd_ptr (x.rhs_.start_.rd_ptr ());
01093   this->start_.wr_ptr (x.rhs_.start_.wr_ptr ());
01094 
01095   ACE_Data_Block* db = this->start_.data_block ()->clone_nocopy ();
01096   (void) x.rhs_.start_.replace_data_block (db);
01097 
01098 #if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1)
01099   ACE_NEW (this->monitor_,
01100            ACE::Monitor_Control::Size_Monitor);
01101   this->monitor_->receive (this->start_.total_size ());
01102 #endif /* ACE_HAS_MONITOR_POINTS==1 */
01103 }

ACE_INLINE ACE_InputCDR::~ACE_InputCDR ( void   ) 

Destructor.

Definition at line 609 of file CDR_Stream.inl.

00610 {
00611 #if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1)
00612   this->monitor_->remove_ref ();
00613 #endif /* ACE_HAS_MONITOR_POINTS==1 */
00614 }


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 1037 of file CDR_Stream.inl.

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

01040 {
01041 #if !defined (ACE_LACKS_CDR_ALIGNMENT)
01042   buf = ACE_ptr_align_binary (this->rd_ptr (), align);
01043 #else
01044   buf = this->rd_ptr ();
01045 #endif /* ACE_LACKS_CDR_ALIGNMENT */
01046 
01047   char * const end = buf + size;
01048   if (end <= this->wr_ptr ())
01049     {
01050       this->start_.rd_ptr (end);
01051       return 0;
01052     }
01053 
01054   this->good_bit_ = false;
01055   return -1;
01056 #if defined (ACE_LACKS_CDR_ALIGNMENT)
01057   ACE_UNUSED_ARG (align);
01058 #endif /* ACE_LACKS_CDR_ALIGNMENT */
01059 }

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 1062 of file CDR_Stream.inl.

01064 {
01065   return this->adjust (size, size, buf);
01066 }

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 1481 of file CDR_Stream.inl.

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

01482 {
01483 #if !defined (ACE_LACKS_CDR_ALIGNMENT)
01484   char *buf = ACE_ptr_align_binary (this->rd_ptr (),
01485                                     alignment);
01486 #else
01487   char *buf = this->rd_ptr ();
01488 #endif /* ACE_LACKS_CDR_ALIGNMENT */
01489 
01490   if (buf <= this->wr_ptr ())
01491     {
01492       this->start_.rd_ptr (buf);
01493       return 0;
01494     }
01495 
01496   this->good_bit_ = false;
01497   return -1;
01498 }

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 1475 of file CDR_Stream.inl.

References ACE_CDR_BYTE_ORDER, and do_byte_swap().

Referenced by ACE_InputCDR(), and exchange_data_blocks().

01476 {
01477   return this->do_byte_swap () ? !ACE_CDR_BYTE_ORDER : ACE_CDR_BYTE_ORDER;
01478 }

ACE_INLINE void ACE_InputCDR::char_translator ( ACE_Char_Codeset_Translator  ) 

Set the codeset translators.

Definition at line 1528 of file CDR_Stream.inl.

References char_translator_.

01529 {
01530   this->char_translator_ = ctran;
01531 }

ACE_INLINE ACE_Char_Codeset_Translator * ACE_InputCDR::char_translator ( void   )  const

Access the codeset translators. They can be nil!

Definition at line 1515 of file CDR_Stream.inl.

References char_translator_.

01516 {
01517   return this->char_translator_;
01518 }

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 1848 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_, ACE_Message_Block::DONT_DELETE, major_version_, ACE_CDR::MAX_ALIGNMENT, 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(), start_, wchar_translator_, ACE_Message_Block::wr_ptr(), and wr_ptr().

01849 {
01850   this->do_byte_swap_ = cdr.do_byte_swap_;
01851 
01852   // Get the read & write pointer positions in the incoming CDR
01853   // streams
01854   char *rd_ptr = cdr.start_.rd_ptr ();
01855   char *wr_ptr = cdr.start_.wr_ptr ();
01856 
01857   // Now reset the incoming CDR stream
01858   cdr.start_.reset ();
01859 
01860   // As we have reset the stream, try to align the underlying message
01861   // block in the incoming stream
01862   ACE_CDR::mb_align (&cdr.start_);
01863 
01864   // Get the read & write pointer positions again
01865   char *nrd_ptr = cdr.start_.rd_ptr ();
01866   char *nwr_ptr = cdr.start_.wr_ptr ();
01867 
01868   // Actual length of the stream is..
01869   // @todo: This will look idiotic, but we dont seem to have much of a
01870   // choice. How do we calculate the length of the incoming stream?
01871   // Calling the method before calling reset () would give us the
01872   // wrong length of the stream that needs copying.  So we do the
01873   // calulation like this
01874   // (1) We get the <rd_ptr> and <wr_ptr> positions of the incoming
01875   // stream.
01876   // (2) Then we reset the <incoming> stream and then align it.
01877   // (3) We get the <rd_ptr> and <wr_ptr> positions again. (Points #1
01878   // thru #3 has been done already)
01879   // (4) The difference in the <rd_ptr> and <wr_ptr> positions gives
01880   // us the following, the actual bytes traversed by the <rd_ptr> and
01881   // <wr_ptr>.
01882   // (5) The bytes traversed by the <wr_ptr> is the actual length of
01883   // the stream.
01884 
01885   // Actual bytes traversed
01886   size_t rd_bytes = rd_ptr - nrd_ptr;
01887   size_t wr_bytes = wr_ptr - nwr_ptr;
01888 
01889   ACE_CDR::mb_align (&this->start_);
01890 
01891   ACE_Data_Block *db =
01892     this->start_.data_block ();
01893 
01894   // If the size of the data that needs to be copied are higher than
01895   // what is available, then do a reallocation.
01896   if (wr_bytes > (this->start_.size () - ACE_CDR::MAX_ALIGNMENT))
01897     {
01898       // @@NOTE: We need to probably add another method to the message
01899       // block interface to simplify this
01900       db =
01901         cdr.start_.data_block ()->clone_nocopy ();
01902 
01903       if (db == 0 || db->size ((wr_bytes) +
01904                                ACE_CDR::MAX_ALIGNMENT) == -1)
01905         return 0;
01906 
01907       // Replace our data block by using the incoming CDR stream.
01908       db = this->start_.replace_data_block (db);
01909 
01910       // Align the start_ message block.
01911       ACE_CDR::mb_align (&this->start_);
01912 
01913       // Clear the DONT_DELETE flag if it has been set
01914       this->start_.clr_self_flags (ACE_Message_Block::DONT_DELETE);
01915     }
01916 
01917   // Now do the copy
01918   (void) ACE_OS::memcpy (this->start_.wr_ptr (),
01919                          cdr.start_.rd_ptr (),
01920                          wr_bytes);
01921 
01922   // Set the read pointer position to the same point as that was in
01923   // <incoming> cdr.
01924   this->start_.rd_ptr (rd_bytes);
01925   this->start_.wr_ptr (wr_bytes);
01926 
01927   // We have changed the read & write pointers for the incoming
01928   // stream. Set them back to the positions that they were before..
01929   cdr.start_.rd_ptr (rd_bytes);
01930   cdr.start_.wr_ptr (wr_bytes);
01931 
01932   this->major_version_ = cdr.major_version_;
01933   this->minor_version_ = cdr.minor_version_;
01934 
01935   // Copy the char/wchar translators
01936   this->char_translator_ = cdr.char_translator_;
01937   this->wchar_translator_ = cdr.wchar_translator_;
01938 
01939 #if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1)
01940   this->monitor_->receive (this->start_.total_size ());
01941 #endif /* ACE_HAS_MONITOR_POINTS==1 */
01942 
01943   return db;
01944 }

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 1469 of file CDR_Stream.inl.

References do_byte_swap_.

Referenced by byte_order().

01470 {
01471   return this->do_byte_swap_;
01472 }

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

Points to the continuation field of the current message block.

Definition at line 1013 of file CDR_Stream.inl.

References ACE_Message_Block::end(), and start_.

Referenced by adjust().

01014 {
01015   return this->start_.end ();
01016 }

void ACE_InputCDR::exchange_data_blocks ( ACE_InputCDR cdr  ) 

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

Definition at line 1773 of file CDR_Stream.cpp.

References ACE_Message_Block::base(), byte_order(), ACE_Message_Block::clr_self_flags(), ACE_Message_Block::data_block(), do_byte_swap_, major_version_, minor_version_, 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().

01774 {
01775   // Exchange byte orders
01776   int const byte_order = cdr.do_byte_swap_;
01777   cdr.do_byte_swap_ = this->do_byte_swap_;
01778   this->do_byte_swap_ = byte_order;
01779 
01780   // Get the destination read and write pointers
01781   size_t const drd_pos =
01782     cdr.start_.rd_ptr () - cdr.start_.base ();
01783   size_t const dwr_pos =
01784     cdr.start_.wr_ptr () - cdr.start_.base ();
01785 
01786   // Get the source read & write pointers
01787   size_t const srd_pos =
01788     this->start_.rd_ptr () - this->start_.base ();
01789   size_t const swr_pos =
01790     this->start_.wr_ptr () - this->start_.base ();
01791 
01792   // Exchange data_blocks. Dont release any of the data blocks.
01793   ACE_Data_Block *dnb =
01794     this->start_.replace_data_block (cdr.start_.data_block ());
01795   cdr.start_.replace_data_block (dnb);
01796 
01797   // Exchange the flags information..
01798   ACE_Message_Block::Message_Flags df = cdr.start_.self_flags ();
01799   ACE_Message_Block::Message_Flags sf = this->start_.self_flags ();
01800 
01801   cdr.start_.clr_self_flags (df);
01802   this->start_.clr_self_flags (sf);
01803 
01804   cdr.start_.set_self_flags (sf);
01805   this->start_.set_self_flags (df);
01806 
01807   // Reset the <cdr> pointers to zero before it is set again.
01808   cdr.start_.reset ();
01809   this->start_.reset ();
01810 
01811   // Set the read and write pointers.
01812   if (cdr.start_.size () >= srd_pos)
01813     {
01814       cdr.start_.rd_ptr (srd_pos);
01815     }
01816 
01817   if (cdr.start_.size () >= swr_pos)
01818     {
01819       cdr.start_.wr_ptr (swr_pos);
01820     }
01821 
01822   if (this->start_.size () >= drd_pos)
01823     {
01824       this->start_.rd_ptr (drd_pos);
01825     }
01826 
01827   if (this->start_.size () >= dwr_pos)
01828     {
01829       this->start_.wr_ptr (dwr_pos);
01830     }
01831 
01832   ACE_CDR::Octet const dmajor = cdr.major_version_;
01833   ACE_CDR::Octet const dminor = cdr.minor_version_;
01834 
01835   // Exchange the GIOP version info
01836   cdr.major_version_ = this->major_version_;
01837   cdr.minor_version_ = this->minor_version_;
01838 
01839   this->major_version_ = dmajor;
01840   this->minor_version_ = dminor;
01841 
01842 #if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1)
01843   this->monitor_->receive (this->start_.total_size ());
01844 #endif /* ACE_HAS_MONITOR_POINTS==1 */
01845 }

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

Set the underlying GIOP version..

Definition at line 1508 of file CDR_Stream.inl.

References major_version_, and minor_version_.

01509 {
01510   major = this->major_version_;
01511   minor = this->minor_version_;
01512 }

ACE_INLINE bool ACE_InputCDR::good_bit ( void   )  const

returns false if a problem has been detected.

Definition at line 1075 of file CDR_Stream.inl.

References good_bit_.

Referenced by operator>>().

01076 {
01077   return this->good_bit_;
01078 }

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 1722 of file CDR_Stream.cpp.

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

01723 {
01724   if (ACE_CDR::grow (&this->start_, newsize) == -1)
01725     return -1;
01726 
01727   ACE_CDR::mb_align (&this->start_);
01728   this->start_.wr_ptr (newsize);
01729 
01730 #if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1)
01731   if (newsize > this->start_.total_size ())
01732     {
01733       this->monitor_->receive (newsize);
01734     }
01735 #endif /* ACE_HAS_MONITOR_POINTS==1 */
01736 
01737   return 0;
01738 }

ACE_INLINE size_t ACE_InputCDR::length ( void   )  const

Return how many bytes are left in the stream.

Definition at line 706 of file CDR_Stream.inl.

References ACE_Message_Block::length(), and start_.

Referenced by read_string(), and read_wstring().

00707 {
00708   return this->start_.length ();
00709 }

ACE_InputCDR & ACE_InputCDR::operator= ( const ACE_InputCDR rhs  ) 

Definition at line 1106 of file CDR_Stream.cpp.

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

01107 {
01108   if (this != &rhs)
01109     {
01110       this->start_.data_block (rhs.start_.data_block ()->duplicate ());
01111       this->start_.rd_ptr (rhs.start_.rd_ptr ());
01112       this->start_.wr_ptr (rhs.start_.wr_ptr ());
01113       this->do_byte_swap_ = rhs.do_byte_swap_;
01114       this->good_bit_ = true;
01115       this->char_translator_ = rhs.char_translator_;
01116       this->major_version_ = rhs.major_version_;
01117       this->minor_version_ = rhs.minor_version_;
01118     }
01119 
01120 #if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1)
01121   this->monitor_->receive (this->start_.total_size ());
01122 #endif /* ACE_HAS_MONITOR_POINTS==1 */
01123 
01124   return *this;
01125 }

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

Move the rd_ptr ahead by offset bytes.

Definition at line 1019 of file CDR_Stream.inl.

References ACE_Message_Block::rd_ptr(), and start_.

01020 {
01021   this->start_.rd_ptr (offset);
01022 }

ACE_INLINE char * ACE_InputCDR::rd_ptr ( void   ) 

Returns the current position for the rd_ptr.

Definition at line 1025 of file CDR_Stream.inl.

References ACE_Message_Block::rd_ptr(), and start_.

Referenced by adjust(), align_read_ptr(), and clone_from().

01026 {
01027   return this->start_.rd_ptr ();
01028 }

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

Definition at line 1546 of file CDR_Stream.cpp.

References good_bit_, ACE_Message_Block::rd_ptr(), start_, and wr_ptr().

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

01547 {
01548   if (this->rd_ptr () < this->wr_ptr ())
01549     {
01550       *x = *reinterpret_cast<ACE_CDR::Octet*> (this->rd_ptr ());
01551       this->start_.rd_ptr (1);
01552       return true;
01553     }
01554 
01555   this->good_bit_ = false;
01556   return false;
01557 }

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

Definition at line 1651 of file CDR_Stream.cpp.

References good_bit_, ACE_CDR::LONGDOUBLE_ALIGN, ACE_CDR::LONGDOUBLE_SIZE, and ACE_CDR::swap_16().

Referenced by read_longdouble(), and skip_longdouble().

01652 {
01653   char *buf = 0;
01654   if (this->adjust (ACE_CDR::LONGDOUBLE_SIZE,
01655                     ACE_CDR::LONGDOUBLE_ALIGN,
01656                     buf) == 0)
01657     {
01658 #if !defined (ACE_DISABLE_SWAP_ON_READ)
01659       if (!this->do_byte_swap_)
01660         *x = *reinterpret_cast<ACE_CDR::LongDouble *> (buf);
01661       else
01662         ACE_CDR::swap_16 (buf, reinterpret_cast<char*> (x));
01663 #else
01664       *x = *reinterpret_cast<ACE_CDR::LongDouble*> (buf);
01665 #endif /* ACE_DISABLE_SWAP_ON_READ */
01666       return true;
01667     }
01668 
01669   this->good_bit_ = false;
01670   return false;
01671 }

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

Definition at line 1560 of file CDR_Stream.cpp.

References good_bit_, ACE_CDR::SHORT_SIZE, and ACE_CDR::swap_2().

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

01561 {
01562   char *buf = 0;
01563   if (this->adjust (ACE_CDR::SHORT_SIZE, buf) == 0)
01564     {
01565 #if !defined (ACE_DISABLE_SWAP_ON_READ)
01566       if (!this->do_byte_swap_)
01567         *x = *reinterpret_cast<ACE_CDR::UShort*> (buf);
01568       else
01569         ACE_CDR::swap_2 (buf, reinterpret_cast<char*> (x));
01570 #else
01571       *x = *reinterpret_cast<ACE_CDR::UShort*> (buf);
01572 #endif /* ACE_DISABLE_SWAP_ON_READ */
01573       return true;
01574     }
01575   this->good_bit_ = false;
01576   return false;
01577 }

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

Definition at line 1580 of file CDR_Stream.cpp.

References good_bit_, ACE_CDR::LONG_SIZE, and ACE_CDR::swap_4().

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

01581 {
01582   char *buf = 0;
01583   if (this->adjust (ACE_CDR::LONG_SIZE, buf) == 0)
01584     {
01585 #if !defined (ACE_DISABLE_SWAP_ON_READ)
01586       if (!this->do_byte_swap_)
01587         *x = *reinterpret_cast<ACE_CDR::ULong*> (buf);
01588       else
01589         ACE_CDR::swap_4 (buf, reinterpret_cast<char*> (x));
01590 #else
01591       *x = *reinterpret_cast<ACE_CDR::ULong*> (buf);
01592 #endif /* ACE_DISABLE_SWAP_ON_READ */
01593       return true;
01594     }
01595   this->good_bit_ = false;
01596   return false;
01597 }

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

Definition at line 1600 of file CDR_Stream.cpp.

References good_bit_, ACE_CDR::LONGLONG_SIZE, and ACE_CDR::swap_8().

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

01601 {
01602   char *buf = 0;
01603 
01604   if (this->adjust (ACE_CDR::LONGLONG_SIZE, buf) == 0)
01605     {
01606 #if !defined (ACE_DISABLE_SWAP_ON_READ)
01607 #  if defined (__arm__)
01608       if (!this->do_byte_swap_)
01609         {
01610           // Convert from Intel format (12345678 => 56781234)
01611           const char *orig = buf;
01612           char *target = reinterpret_cast<char *> (x);
01613           register ACE_UINT32 x =
01614             *reinterpret_cast<const ACE_UINT32 *> (orig);
01615           register ACE_UINT32 y =
01616             *reinterpret_cast<const ACE_UINT32 *> (orig + 4);
01617           *reinterpret_cast<ACE_UINT32 *> (target) = y;
01618           *reinterpret_cast<ACE_UINT32 *> (target + 4) = x;
01619         }
01620       else
01621         {
01622           // Convert from Sparc format (12345678 => 43218765)
01623           const char *orig = buf;
01624           char *target = reinterpret_cast<char *> (x);
01625           register ACE_UINT32 x =
01626             *reinterpret_cast<const ACE_UINT32 *> (orig);
01627           register ACE_UINT32 y =
01628             *reinterpret_cast<const ACE_UINT32 *> (orig + 4);
01629           x = (x << 24) | ((x & 0xff00) << 8) | ((x & 0xff0000) >> 8) | (x >> 24);
01630           y = (y << 24) | ((y & 0xff00) << 8) | ((y & 0xff0000) >> 8) | (y >> 24);
01631           *reinterpret_cast<ACE_UINT32 *> (target) = x;
01632           *reinterpret_cast<ACE_UINT32 *> (target + 4) = y;
01633         }
01634 #  else
01635       if (!this->do_byte_swap_)
01636         *x = *reinterpret_cast<ACE_CDR::ULongLong *> (buf);
01637       else
01638         ACE_CDR::swap_8 (buf, reinterpret_cast<char *> (x));
01639 #  endif /* !__arm__ */
01640 #else
01641       *x = *reinterpret_cast<ACE_CDR::ULongLong *> (buf);
01642 #endif /* ACE_DISABLE_SWAP_ON_READ */
01643       return true;
01644     }
01645 
01646   this->good_bit_ = false;
01647   return false;
01648 }

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 <align>. 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 <memcpy>; as explained above it is expected that using assignment is faster that <memcpy> for one element, but for several elements <memcpy> 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 1436 of file CDR_Stream.cpp.

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

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(), and read_wchar_array().

01440 {
01441   if (length == 0)
01442     return true;
01443   char* buf = 0;
01444 
01445   if (this->adjust (size * length, align, buf) == 0)
01446     {
01447 #if defined (ACE_DISABLE_SWAP_ON_READ)
01448       ACE_OS::memcpy (x, buf, size*length);
01449 #else
01450       if (!this->do_byte_swap_ || size == 1)
01451         ACE_OS::memcpy (x, buf, size*length);
01452       else
01453         {
01454           char *target = reinterpret_cast<char*> (x);
01455           switch (size)
01456             {
01457             case 2:
01458               ACE_CDR::swap_2_array (buf, target, length);
01459               break;
01460             case 4:
01461               ACE_CDR::swap_4_array (buf, target, length);
01462               break;
01463             case 8:
01464               ACE_CDR::swap_8_array (buf, target, length);
01465               break;
01466             case 16:
01467               ACE_CDR::swap_16_array (buf, target, length);
01468               break;
01469             default:
01470               // TODO: print something?
01471               this->good_bit_ = false;
01472               return false;
01473             }
01474         }
01475 #endif /* ACE_DISABLE_SWAP_ON_READ */
01476       return this->good_bit_;
01477     }
01478   return false;
01479 }

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

Return false on failure and true on success.

Definition at line 623 of file CDR_Stream.inl.

References good_bit_.

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

00624 {
00625   ACE_CDR::Octet tmp = 0;
00626   (void) this->read_octet (tmp);
00627   x = tmp ? true : false;
00628   return (ACE_CDR::Boolean) this->good_bit_;
00629 }

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 1523 of file CDR_Stream.cpp.

References good_bit_.

01525 {
01526   // Make sure the length of the array isn't greater than the length of
01527   // the stream.
01528   if (length > this->length ())
01529     {
01530       this->good_bit_ = false;
01531       return false;
01532     }
01533 
01534   // It is hard to optimize this, the spec requires that on the wire
01535   // booleans be represented as a byte with value 0 or 1, but in
01536   // memory it is possible (though very unlikely) that a boolean has
01537   // a non-zero value (different from 1).
01538   // We resort to a simple loop.
01539   for (ACE_CDR::ULong i = 0; i != length && this->good_bit_; ++i)
01540     (void) this->read_boolean (x[i]);
01541 
01542   return this->good_bit_;
01543 }

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

Return false on failure and true on success.

Definition at line 632 of file CDR_Stream.inl.

References char_translator_, read_1(), and ACE_Char_Codeset_Translator::read_char().

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

00633 {
00634   if (this->char_translator_ == 0)
00635     {
00636       void *temp = &x;
00637       return this->read_1 (reinterpret_cast<ACE_CDR::Octet*> (temp));
00638     }
00639   return this->char_translator_->read_char (*this, x);
00640 }

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 712 of file CDR_Stream.inl.

References char_translator_, ACE_CDR::OCTET_ALIGN, ACE_CDR::OCTET_SIZE, read_array(), and ACE_Char_Codeset_Translator::read_char_array().

Referenced by operator>>().

00714 {
00715   // Make sure the length of the array isn't greater than the length of
00716   // the stream.
00717   if (length > this->length ())
00718     {
00719       this->good_bit_ = false;
00720       return false;
00721     }
00722 
00723   if (this->char_translator_ == 0)
00724     return this->read_array (x,
00725                              ACE_CDR::OCTET_SIZE,
00726                              ACE_CDR::OCTET_ALIGN,
00727                              length);
00728   return this->char_translator_->read_char_array (*this, x, length);
00729 }

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

Return false on failure and true on success.

Definition at line 693 of file CDR_Stream.inl.

References read_8().

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

00694 {
00695   void *temp = &x;
00696   return this->read_8 (reinterpret_cast<ACE_CDR::ULongLong*> (temp));
00697 }

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 901 of file CDR_Stream.inl.

References ACE_CDR::LONGLONG_ALIGN, ACE_CDR::LONGLONG_SIZE, and read_array().

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

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

Return false on failure and true on success.

Definition at line 686 of file CDR_Stream.inl.

References read_4().

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

00687 {
00688   void *temp = &x;
00689   return this->read_4 (reinterpret_cast<ACE_CDR::ULong*> (temp));
00690 }

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 882 of file CDR_Stream.inl.

References ACE_CDR::LONG_ALIGN, ACE_CDR::LONG_SIZE, and read_array().

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

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

Return false on failure and true on success.

Definition at line 658 of file CDR_Stream.inl.

References read_4().

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

00659 {
00660   void *temp = &x;
00661   return this->read_4 (reinterpret_cast<ACE_CDR::ULong*> (temp));
00662 }

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 810 of file CDR_Stream.inl.

References ACE_CDR::LONG_ALIGN, ACE_CDR::LONG_SIZE, and read_array().

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

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

Return false on failure and true on success.

Definition at line 700 of file CDR_Stream.inl.

References read_16().

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

00701 {
00702   return this->read_16 (&x);
00703 }

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 919 of file CDR_Stream.inl.

References ACE_CDR::LONGDOUBLE_ALIGN, ACE_CDR::LONGDOUBLE_SIZE, and read_array().

00921 {
00922   // Make sure the length of the array isn't greater than the length of
00923   // the stream.
00924   if (length * ACE_CDR::LONGDOUBLE_SIZE > this->length ())
00925     {
00926       this->good_bit_ = false;
00927       return false;
00928     }
00929   return this->read_array (x,
00930                            ACE_CDR::LONGDOUBLE_SIZE,
00931                            ACE_CDR::LONGDOUBLE_ALIGN,
00932                            length);
00933 }

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

Return false on failure and true on success.

Definition at line 673 of file CDR_Stream.inl.

References read_8().

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

00674 {
00675   void *temp = &x;
00676   return this->read_8 (reinterpret_cast<ACE_CDR::ULongLong*> (temp));
00677 }

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 846 of file CDR_Stream.inl.

References ACE_CDR::LONGLONG_ALIGN, ACE_CDR::LONGLONG_SIZE, and read_array().

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

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

Return false on failure and true on success.

Definition at line 617 of file CDR_Stream.inl.

References read_1().

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

00618 {
00619   return this->read_1 (&x);
00620 }

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 756 of file CDR_Stream.inl.

References ACE_CDR::OCTET_ALIGN, ACE_CDR::OCTET_SIZE, and read_array().

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

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

Return false on failure and true on success.

Definition at line 644 of file CDR_Stream.inl.

References read_2().

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

00645 {
00646   void *temp = &x;
00647   return this->read_2 (reinterpret_cast<ACE_CDR::UShort*> (temp));
00648 }

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 774 of file CDR_Stream.inl.

References read_array(), ACE_CDR::SHORT_ALIGN, and ACE_CDR::SHORT_SIZE.

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

ACE_CDR::Boolean ACE_InputCDR::read_string ( ACE_CString x  ) 

Return false on failure and true on success.

Definition at line 1336 of file CDR_Stream.cpp.

01337 {
01338   ACE_CDR::Char * data = 0;
01339   if (this->read_string (data))
01340     {
01341       ACE_Auto_Basic_Array_Ptr<ACE_CDR::Char> safe_data (data);
01342       x = data;
01343       return true;
01344     }
01345 
01346   x = "";
01347   return (this->good_bit_ = false);
01348 }

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

Return false on failure and true on success.

Definition at line 1287 of file CDR_Stream.cpp.

References ACE_NEW_RETURN, char_translator_, good_bit_, length(), ACE_Char_Codeset_Translator::read_string(), ACE_Auto_Basic_Array_Ptr< X >::release(), and ACE_OS::strcpy().

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

01288 {
01289   // @@ This is a slight violation of "Optimize for the common case",
01290   // i.e. normally the translator will be 0, but OTOH the code is
01291   // smaller and should be better for the cache ;-) ;-)
01292   if (this->char_translator_ != 0)
01293     {
01294       this->good_bit_ = this->char_translator_->read_string (*this, x);
01295       return this->good_bit_;
01296     }
01297 
01298   ACE_CDR::ULong len = 0;
01299 
01300   if (!this->read_ulong (len))
01301     return false;
01302 
01303   // A check for the length being too great is done later in the
01304   // call to read_char_array but we want to have it done before
01305   // the memory is allocated.
01306   if (len > 0 && len <= this->length())
01307     {
01308       ACE_NEW_RETURN (x,
01309                       ACE_CDR::Char[len],
01310                       0);
01311 
01312       ACE_Auto_Basic_Array_Ptr<ACE_CDR::Char> safe_data (x);
01313 
01314       if (this->read_char_array (x, len))
01315         {
01316           (void) safe_data.release ();
01317           return true;
01318         }
01319     }
01320   else if (len == 0)
01321     {
01322       // Convert any null strings to empty strings since empty
01323       // strings can cause crashes. (See bug 58.)
01324       ACE_NEW_RETURN (x,
01325                       ACE_CDR::Char[1],
01326                       0);
01327       ACE_OS::strcpy (const_cast<char *&> (x), "");
01328       return true;
01329     }
01330 
01331   x = 0;
01332   return (this->good_bit_ = false);
01333 }

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

Return false on failure and true on success.

Definition at line 666 of file CDR_Stream.inl.

References read_4().

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

00667 {
00668   return this->read_4 (&x);
00669 }

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 828 of file CDR_Stream.inl.

References ACE_CDR::LONG_ALIGN, ACE_CDR::LONG_SIZE, and read_array().

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

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

Return false on failure and true on success.

Definition at line 680 of file CDR_Stream.inl.

References read_8().

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

00681 {
00682   return this->read_8 (&x);
00683 }

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 864 of file CDR_Stream.inl.

References ACE_CDR::LONGLONG_ALIGN, ACE_CDR::LONGLONG_SIZE, and read_array().

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

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

Return false on failure and true on success.

Definition at line 651 of file CDR_Stream.inl.

References read_2().

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

00652 {
00653   return this->read_2 (&x);
00654 }

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 792 of file CDR_Stream.inl.

References read_array(), ACE_CDR::SHORT_ALIGN, and ACE_CDR::SHORT_SIZE.

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

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

Return false on failure and true on success.

Definition at line 1188 of file CDR_Stream.cpp.

References good_bit_, major_version_, minor_version_, ACE_CDR::OCTET_ALIGN, read_2(), read_4(), ACE_WChar_Codeset_Translator::read_wchar(), ACE_OutputCDR::wchar_maxbytes_, and wchar_translator_.

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

01189 {
01190   if (this->wchar_translator_ != 0)
01191     {
01192       this->good_bit_ = this->wchar_translator_->read_wchar (*this,x);
01193       return this->good_bit_;
01194     }
01195   if (ACE_OutputCDR::wchar_maxbytes_ == 0)
01196     {
01197       errno = EACCES;
01198       return (this->good_bit_ = false);
01199     }
01200 
01201   if (ACE_OutputCDR::wchar_maxbytes_ == sizeof (ACE_CDR::WChar))
01202     {
01203       if (static_cast<ACE_CDR::Short> (major_version_) == 1
01204           && static_cast<ACE_CDR::Short> (minor_version_) == 2)
01205         {
01206           ACE_CDR::Octet len;
01207 
01208           if (this->read_1 (&len))
01209             return this->read_array
01210               (reinterpret_cast<ACE_CDR::Octet*> (&x),
01211                static_cast<ACE_CDR::ULong> (len),
01212                ACE_CDR::OCTET_ALIGN,
01213                1);
01214 
01215           else
01216             return (this->good_bit_ = false);
01217         }
01218 
01219       void * const temp = &x;
01220       if (sizeof (ACE_CDR::WChar) == 2)
01221         return this->read_2 (reinterpret_cast<ACE_CDR::UShort *> (temp));
01222       else
01223         return this->read_4 (reinterpret_cast<ACE_CDR::ULong *> (temp));
01224     }
01225 
01226   if (static_cast<ACE_CDR::Short> (major_version_) == 1
01227       && static_cast<ACE_CDR::Short> (minor_version_) == 2)
01228     {
01229       ACE_CDR::Octet len;
01230 
01231       if (this->read_1 (&len))
01232         {
01233           if (len == 2)
01234             {
01235               ACE_CDR::Short sx;
01236               if (this->read_array
01237                   (reinterpret_cast<ACE_CDR::Octet*> (&sx),
01238                    static_cast<ACE_CDR::ULong> (len),
01239                    ACE_CDR::OCTET_ALIGN,
01240                    1))
01241                 {
01242                   x = static_cast<ACE_CDR::WChar> (sx);
01243                   return true;
01244                 }
01245             }
01246           else
01247             {
01248               ACE_CDR::Octet ox;
01249               if (this->read_array
01250                   (reinterpret_cast<ACE_CDR::Octet*> (&ox),
01251                    static_cast<ACE_CDR::ULong> (len),
01252                    ACE_CDR::OCTET_ALIGN,
01253                    1))
01254                 {
01255                   x = static_cast<ACE_CDR::WChar> (ox);
01256                   return true;
01257                 }
01258             }
01259         }
01260     }
01261   else
01262     {
01263       if (ACE_OutputCDR::wchar_maxbytes_ == 2)
01264         {
01265           ACE_CDR::UShort sx;
01266           if (this->read_2 (reinterpret_cast<ACE_CDR::UShort *> (&sx)))
01267             {
01268               x = static_cast<ACE_CDR::WChar> (sx);
01269               return true;
01270             }
01271         }
01272       else
01273         {
01274           ACE_CDR::Octet ox;
01275           if (this->read_1 (&ox))
01276             {
01277               x = static_cast<ACE_CDR::WChar> (ox);
01278               return true;
01279             }
01280 
01281         }
01282     }
01283   return (this->good_bit_ = false);
01284 }

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 732 of file CDR_Stream.inl.

References ACE_CDR::LONG_ALIGN, read_array(), ACE_WChar_Codeset_Translator::read_wchar_array(), read_wchar_array_i(), ACE_CDR::SHORT_ALIGN, ACE_OutputCDR::wchar_maxbytes_, and wchar_translator_.

Referenced by operator>>().

00734 {
00735   // Make sure the length of the array isn't greater than the length of
00736   // the stream.
00737   if (length * ACE_OutputCDR::wchar_maxbytes_ > this->length ())
00738     {
00739       this->good_bit_ = false;
00740       return false;
00741     }
00742 
00743   if (this->wchar_translator_ != 0)
00744     return this->wchar_translator_->read_wchar_array (*this, x, length);
00745   if (ACE_OutputCDR::wchar_maxbytes_ != sizeof (ACE_CDR::WChar))
00746     return this->read_wchar_array_i (x, length);
00747   return this->read_array (x,
00748                            sizeof (ACE_CDR::WChar),
00749                            sizeof (ACE_CDR::WChar) == 2
00750                            ? ACE_CDR::SHORT_ALIGN
00751                            : ACE_CDR::LONG_ALIGN,
00752                            length);
00753 }

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 1482 of file CDR_Stream.cpp.

References good_bit_, ACE_CDR::OCTET_ALIGN, ACE_CDR::SHORT_ALIGN, ACE_CDR::swap_2(), and ACE_OutputCDR::wchar_maxbytes_.

Referenced by read_wchar_array().

01484 {
01485   if (length == 0)
01486     return true;
01487   char* buf = 0;
01488   size_t const align = (ACE_OutputCDR::wchar_maxbytes_ == 2) ?
01489     ACE_CDR::SHORT_ALIGN :
01490     ACE_CDR::OCTET_ALIGN;
01491 
01492   if (this->adjust (ACE_OutputCDR::wchar_maxbytes_ * length, align, buf) == 0)
01493     {
01494       if (ACE_OutputCDR::wchar_maxbytes_ == 2)
01495         {
01496           ACE_CDR::UShort *sb = reinterpret_cast<ACE_CDR::UShort *> (buf);
01497           for (size_t i = 0; i < length; ++i)
01498 #if defined (ACE_DISABLE_SWAP_ON_READ)
01499             x[i] = static_cast<ACE_CDR::WChar> (sb[i]);
01500 #else
01501             if (!this->do_byte_swap_)
01502               x[i] = static_cast<ACE_CDR::WChar> (sb[i]);
01503             else
01504               {
01505                 ACE_CDR::UShort sx;
01506                 ACE_CDR::swap_2 (&buf[i * 2], reinterpret_cast<char *> (&sx));
01507                 x[i] = static_cast<ACE_CDR::WChar> (sx);
01508               }
01509 #endif /* ACE_DISABLE_SWAP_ON_READ */
01510         }
01511       else
01512         {
01513           for (size_t i = 0; i < length; ++i)
01514             x[i] = static_cast<ACE_CDR::Octet> (buf[i]);
01515         }
01516       return this->good_bit_;
01517     }
01518   return false;
01519 }

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

Return false on failure and true on success.

Definition at line 1351 of file CDR_Stream.cpp.

References ACE_auto_ptr_reset(), ACE_NEW_RETURN, good_bit_, length(), ACE_WChar_Codeset_Translator::read_wstring(), ACE_Auto_Basic_Array_Ptr< X >::release(), ACE_OutputCDR::wchar_maxbytes_, and wchar_translator_.

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

01352 {
01353   // @@ This is a slight violation of "Optimize for the common case",
01354   // i.e. normally the translator will be 0, but OTOH the code is
01355   // smaller and should be better for the cache ;-) ;-)
01356   if (this->wchar_translator_ != 0)
01357     {
01358       this->good_bit_ = this->wchar_translator_->read_wstring (*this, x);
01359       return this->good_bit_;
01360     }
01361   if (ACE_OutputCDR::wchar_maxbytes_ == 0)
01362     {
01363       errno = EACCES;
01364       return (this->good_bit_ = false);
01365     }
01366 
01367   ACE_CDR::ULong len = 0;
01368   if (!this->read_ulong (len))
01369     return false;
01370 
01371   // A check for the length being too great is done later in the
01372   // call to read_char_array but we want to have it done before
01373   // the memory is allocated.
01374   if (len > 0 && len <= this->length ())
01375     {
01376       ACE_Auto_Basic_Array_Ptr<ACE_CDR::WChar> safe_data;
01377 
01378       if (static_cast<ACE_CDR::Short> (this->major_version_) == 1
01379           && static_cast<ACE_CDR::Short> (this->minor_version_) == 2)
01380         {
01381           len /= ACE_OutputCDR::wchar_maxbytes_;
01382 
01383           //allocating one extra for the null character needed by applications
01384           ACE_NEW_RETURN (x,
01385                           ACE_CDR::WChar [len + 1],
01386                           false);
01387 
01388           ACE_auto_ptr_reset (safe_data, x);
01389 
01390           if (this->read_wchar_array (x, len))
01391             {
01392 
01393               //Null character used by applications to find the end of
01394               //the wstring
01395               //Is this okay with the GIOP 1.2 spec??
01396               x[len] = '\x00';
01397 
01398               (void) safe_data.release ();
01399 
01400               return true;
01401             }
01402         }
01403       else
01404         {
01405           ACE_NEW_RETURN (x,
01406                           ACE_CDR::WChar [len],
01407                           false);
01408 
01409           ACE_auto_ptr_reset (safe_data, x);
01410 
01411           if (this->read_wchar_array (x, len))
01412             {
01413               (void) safe_data.release ();
01414 
01415               return true;
01416             }
01417         }
01418     }
01419   else if (len == 0)
01420     {
01421       // Convert any null strings to empty strings since empty
01422       // strings can cause crashes. (See bug 58.)
01423       ACE_NEW_RETURN (x,
01424                       ACE_CDR::WChar[1],
01425                       false);
01426       x[0] = '\x00';
01427       return true;
01428     }
01429 
01430   this->good_bit_ = false;
01431   x = 0;
01432   return false;
01433 }

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 1741 of file CDR_Stream.cpp.

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

Referenced by ACE_InputCDR().

01743 {
01744   this->reset_byte_order (byte_order);
01745   ACE_CDR::consolidate (&this->start_, data);
01746 
01747 #if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1)
01748   this->monitor_->receive (this->start_.total_size ());
01749 #endif /* ACE_HAS_MONITOR_POINTS==1 */
01750 }

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 1463 of file CDR_Stream.inl.

References ACE_CDR_BYTE_ORDER, and do_byte_swap_.

Referenced by reset().

01464 {
01465   this->do_byte_swap_ = (byte_order != ACE_CDR_BYTE_ORDER);
01466 }

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 1966 of file CDR_Stream.cpp.

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

Referenced by steal_from().

01967 {
01968   this->start_.data_block (this->start_.data_block ()->clone_nocopy ());
01969 
01970   // Reset the flags...
01971   this->start_.clr_self_flags (ACE_Message_Block::DONT_DELETE);
01972 
01973 #if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1)
01974   this->monitor_->receive (this->start_.total_size ());
01975 #endif /* ACE_HAS_MONITOR_POINTS==1 */
01976 }

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

Set the underlying GIOP version..

Definition at line 1501 of file CDR_Stream.inl.

References major_version_, and minor_version_.

01502 {
01503   this->major_version_ = major;
01504   this->minor_version_ = minor;
01505 }

ACE_INLINE ACE_CDR::Boolean ACE_InputCDR::skip_boolean ( void   ) 

Return false on failure and true on success.

Definition at line 949 of file CDR_Stream.inl.

References good_bit_, and skip_octet().

00950 {
00951   return this->skip_octet () && this->good_bit_;
00952 }

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 1710 of file CDR_Stream.cpp.

References good_bit_, and wr_ptr().

Referenced by skip_wstring().

01711 {
01712   if (this->rd_ptr () + len <= this->wr_ptr ())
01713     {
01714       this->rd_ptr (len);
01715       return true;
01716     }
01717   this->good_bit_ = false;
01718   return false;
01719 }

ACE_INLINE ACE_CDR::Boolean ACE_InputCDR::skip_char ( void   ) 

Return false on failure and true on success.

Definition at line 943 of file CDR_Stream.inl.

References skip_octet().

00944 {
00945   return this->skip_octet ();  // sizeof (Char) == sizeof (Octet)
00946 }

ACE_INLINE ACE_CDR::Boolean ACE_InputCDR::skip_double ( void   ) 

Return false on failure and true on success.

Definition at line 1000 of file CDR_Stream.inl.

References skip_ulonglong().

01001 {
01002   return this->skip_ulonglong ();  // sizeof(Double) == sizeof (ULongLong)
01003 }

ACE_INLINE ACE_CDR::Boolean ACE_InputCDR::skip_float ( void   ) 

Return false on failure and true on success.

Definition at line 994 of file CDR_Stream.inl.

References skip_ulong().

00995 {
00996   return this->skip_ulong ();  // sizeof(Float) == sizeof (ULong)
00997 }

ACE_INLINE ACE_CDR::Boolean ACE_InputCDR::skip_long ( void   ) 

Return false on failure and true on success.

Definition at line 975 of file CDR_Stream.inl.

References skip_ulong().

00976 {
00977   return this->skip_ulong ();  // sizeof (Long) == sizeof (ULong)
00978 }

ACE_INLINE ACE_CDR::Boolean ACE_InputCDR::skip_longdouble ( void   ) 

Return false on failure and true on success.

Definition at line 1006 of file CDR_Stream.inl.

References read_16().

01007 {
01008   ACE_CDR::LongDouble x;
01009   return this->read_16 (&x);
01010 }

ACE_INLINE ACE_CDR::Boolean ACE_InputCDR::skip_longlong ( void   ) 

Return false on failure and true on success.

Definition at line 988 of file CDR_Stream.inl.

References skip_ulonglong().

00989 {
00990   return this->skip_ulonglong ();  // sizeof (LongLong) == sizeof (ULongLong)
00991 }

ACE_INLINE ACE_CDR::Boolean ACE_InputCDR::skip_octet ( void   ) 

Return false on failure and true on success.

Definition at line 936 of file CDR_Stream.inl.

References read_1().

Referenced by skip_boolean(), and skip_char().

00937 {
00938   ACE_CDR::Octet x;
00939   return this->read_1 (&x);
00940 }

ACE_INLINE ACE_CDR::Boolean ACE_InputCDR::skip_short ( void   ) 

Return false on failure and true on success.

Definition at line 962 of file CDR_Stream.inl.

References skip_ushort().

00963 {
00964   return this->skip_ushort ();
00965 }

ACE_CDR::Boolean ACE_InputCDR::skip_string ( void   ) 

Definition at line 1674 of file CDR_Stream.cpp.

References good_bit_, and wr_ptr().

01675 {
01676   ACE_CDR::ULong len = 0;
01677   if (this->read_ulong (len))
01678     {
01679       if (this->rd_ptr () + len <= this->wr_ptr ())
01680         {
01681           this->rd_ptr (len);
01682           return true;
01683         }
01684       this->good_bit_ = false;
01685     }
01686   return false;
01687 }

ACE_INLINE ACE_CDR::Boolean ACE_InputCDR::skip_ulong ( void   ) 

Return false on failure and true on success.

Definition at line 968 of file CDR_Stream.inl.

References read_4().

Referenced by skip_float(), and skip_long().

00969 {
00970   ACE_CDR::ULong x;
00971   return this->read_4 (&x);
00972 }

ACE_INLINE ACE_CDR::Boolean ACE_InputCDR::skip_ulonglong ( void   ) 

Return false on failure and true on success.

Definition at line 981 of file CDR_Stream.inl.

References read_8().

Referenced by skip_double(), and skip_longlong().

00982 {
00983   ACE_CDR::ULongLong x;
00984   return this->read_8 (&x);
00985 }

ACE_INLINE ACE_CDR::Boolean ACE_InputCDR::skip_ushort ( void   ) 

Return false on failure and true on success.

Definition at line 955 of file CDR_Stream.inl.

References read_2().

Referenced by skip_short().

00956 {
00957   ACE_CDR::UShort x;
00958   return this->read_2 (&x);
00959 }

ACE_CDR::Boolean ACE_InputCDR::skip_wchar ( void   ) 

Return false on failure and true on success.

Definition at line 1165 of file CDR_Stream.cpp.

References major_version_, minor_version_, read_2(), read_4(), and ACE_OutputCDR::wchar_maxbytes_.

Referenced by skip_wstring().

01166 {
01167   if (static_cast<ACE_CDR::Short> (major_version_) == 1
01168       && static_cast<ACE_CDR::Short> (minor_version_) == 2)
01169     {
01170       ACE_CDR::Octet len;
01171       if (this->read_1 (&len))
01172         return this->skip_bytes (static_cast<size_t> (len));
01173     }
01174   else
01175     {
01176       ACE_CDR::WChar x;
01177       void * const temp = &x;
01178       if (ACE_OutputCDR::wchar_maxbytes_ == 2)
01179         return this->read_2 (reinterpret_cast<ACE_CDR::UShort *> (temp));
01180       else
01181         return this->read_4 (reinterpret_cast<ACE_CDR::ULong *> (temp));
01182     }
01183 
01184   return (this->good_bit_ = false);
01185 }

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 1690 of file CDR_Stream.cpp.

References read_ulong(), skip_bytes(), and skip_wchar().

01691 {
01692   ACE_CDR::Boolean continue_skipping = true;
01693   ACE_CDR::ULong len = 0;
01694 
01695   continue_skipping = read_ulong (len);
01696 
01697   if (continue_skipping && len != 0)
01698     {
01699       if (static_cast<ACE_CDR::Short> (this->major_version_) == 1
01700             && static_cast<ACE_CDR::Short> (this->minor_version_) == 2)
01701           continue_skipping = this->skip_bytes ((size_t)len);
01702       else
01703         while (continue_skipping && len--)
01704           continue_skipping = this->skip_wchar ();
01705     }
01706   return continue_skipping;
01707 }

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 1069 of file CDR_Stream.inl.

References start_.

01070 {
01071   return &this->start_;
01072 }

ACE_Message_Block * ACE_InputCDR::steal_contents ( void   ) 

Steal the contents from the current CDR.

Definition at line 1947 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(), ACE_Message_Block::DONT_DELETE, ACE_CDR::mb_align(), and start_.

01948 {
01949   ACE_Message_Block* block = this->start_.clone ();
01950   this->start_.data_block (block->data_block ()->clone ());
01951 
01952   // If at all our message had a DONT_DELETE flag set, just clear it
01953   // off.
01954   this->start_.clr_self_flags (ACE_Message_Block::DONT_DELETE);
01955 
01956   ACE_CDR::mb_align (&this->start_);
01957 
01958 #if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1)
01959   this->monitor_->receive (this->start_.total_size ());
01960 #endif /* ACE_HAS_MONITOR_POINTS==1 */
01961 
01962   return block;
01963 }

void ACE_InputCDR::steal_from ( ACE_InputCDR cdr  ) 

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

Definition at line 1753 of file CDR_Stream.cpp.

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

01754 {
01755   this->do_byte_swap_ = cdr.do_byte_swap_;
01756   this->start_.data_block (cdr.start_.data_block ()->duplicate ());
01757 
01758   // If the message block had a DONT_DELETE flags, just clear it off..
01759   this->start_.clr_self_flags (ACE_Message_Block::DONT_DELETE);
01760   this->start_.rd_ptr (cdr.start_.rd_ptr ());
01761 
01762   this->start_.wr_ptr (cdr.start_.wr_ptr ());
01763   this->major_version_ = cdr.major_version_;
01764   this->minor_version_ = cdr.minor_version_;
01765   cdr.reset_contents ();
01766 
01767 #if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1)
01768   this->monitor_->receive (this->start_.total_size ());
01769 #endif /* ACE_HAS_MONITOR_POINTS==1 */
01770 }

ACE_INLINE void ACE_InputCDR::wchar_translator ( ACE_WChar_Codeset_Translator  ) 

Definition at line 1534 of file CDR_Stream.inl.

References wchar_translator_.

01535 {
01536   this->wchar_translator_ = wctran;
01537 }

ACE_INLINE ACE_WChar_Codeset_Translator * ACE_InputCDR::wchar_translator ( void   )  const

Definition at line 1521 of file CDR_Stream.inl.

References wchar_translator_.

01522 {
01523   return this->wchar_translator_;
01524 }

ACE_INLINE char * ACE_InputCDR::wr_ptr ( void   ) 

Returns the current position for the wr_ptr.

Definition at line 1031 of file CDR_Stream.inl.

References start_, and ACE_Message_Block::wr_ptr().

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

01032 {
01033   return this->start_.wr_ptr ();
01034 }


Friends And Related Function Documentation

friend class ACE_Char_Codeset_Translator [friend]

The translator need privileged access to efficiently demarshal arrays and the such

Definition at line 623 of file CDR_Stream.h.

friend class ACE_WChar_Codeset_Translator [friend]

Definition at line 624 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 1009 of file CDR_Stream.h.

Referenced by char_translator(), clone_from(), operator=(), read_char(), read_char_array(), and read_string().

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 999 of file CDR_Stream.h.

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

bool ACE_InputCDR::good_bit_ [protected]

set to false when an error occurs.

Definition at line 1002 of file CDR_Stream.h.

Referenced by ACE_InputCDR(), adjust(), align_read_ptr(), good_bit(), operator=(), read_1(), read_16(), read_2(), read_4(), read_8(), read_array(), read_boolean(), read_boolean_array(), read_string(), read_wchar(), read_wchar_array_i(), read_wstring(), skip_boolean(), skip_bytes(), and skip_string().

ACE_CDR::Octet ACE_InputCDR::major_version_ [protected]

The GIOP versions for this stream.

Definition at line 1005 of file CDR_Stream.h.

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

ACE_CDR::Octet ACE_InputCDR::minor_version_ [protected]

Definition at line 1006 of file CDR_Stream.h.

Referenced by clone_from(), exchange_data_blocks(), get_version(), ACE_WChar_Codeset_Translator::minor_version(), ACE_Char_Codeset_Translator::minor_version(), operator=(), read_wchar(), set_version(), skip_wchar(), 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 995 of file CDR_Stream.h.

Referenced by ACE_InputCDR(), adjust(), align_read_ptr(), clone_from(), end(), exchange_data_blocks(), grow(), length(), operator=(), rd_ptr(), read_1(), reset_contents(), start(), steal_contents(), steal_from(), and wr_ptr().

ACE_WChar_Codeset_Translator* ACE_InputCDR::wchar_translator_ [protected]

Definition at line 1010 of file CDR_Stream.h.

Referenced by clone_from(), read_wchar(), read_wchar_array(), read_wstring(), and wchar_translator().


The documentation for this class was generated from the following files:
Generated on Tue Feb 2 17:35:13 2010 for ACE by  doxygen 1.4.7