Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

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 Methods

 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)
 Create an empty input stream. The caller is responsible for putting the right data and providing the right alignment. More...

 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)
 Create an input stream from an ACE_Message_Block. More...

 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. More...

 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. More...

 ACE_InputCDR (const ACE_InputCDR &rhs)
ACE_InputCDR & operator= (const ACE_InputCDR &rhs)
 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. More...

 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. More...

 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. More...

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

 ~ACE_InputCDR (void)
 Destructor. More...

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. Return 0 on failure and 1 on success. More...

int good_bit (void) const
 returns zero if a problem has been detected. More...

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)
 Re-initialize the CDR stream, copying the contents of the chain of message_blocks starting from <data>. More...

ACE_Message_Blocksteal_contents (void)
 Steal the contents from the current CDR. More...

void steal_from (ACE_InputCDR &cdr)
 Steal the contents of <cdr> and make a shallow copy into this stream. More...

void exchange_data_blocks (ACE_InputCDR &cdr)
 Exchange data blocks with the caller of this method. The read and write pointers are also exchanged. Note: We now do only with the start_ message block. More...

ACE_Data_Blockclone_from (ACE_InputCDR &cdr)
 Copy the data portion from the <cdr> to this cdr and return the data content (ie. the ACE_Data_Block) from this CDR to the caller. The caller is responsible for managing the memory of the returned ACE_Data_Block. More...

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

char * rd_ptr (void)
 Returns the current position for the rd_ptr.... More...

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

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

int align_read_ptr (size_t alignment)
int do_byte_swap (void) const
 If non-zero then this stream is writing in non-native byte order, this is only meaningful if ACE_ENABLE_SWAP_ON_WRITE is defined. More...

int byte_order (void) const
 If <do_byte_swap> returns 0, this returns ACE_CDR_BYTE_ORDER else it returns !ACE_CDR_BYTE_ORDER. More...

ACE_Char_Codeset_Translatorchar_translator (void) const
 Access the codeset translators. They can be nil! More...

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

void wchar_translator (ACE_WChar_Codeset_Translator *)
int adjust (size_t size, char *&buf)
int adjust (size_t size, size_t align, char *&buf)
 As above, but now the size and alignment requirements may be different. More...

int set_version (ACE_CDR::Octet major, ACE_CDR::Octet minor)
 Set the underlying GIOP version.. More...

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

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_
 The start of the chain of message blocks, even though in the current version the chain always has length 1. More...

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

int good_bit_
 set to 0 when an error occurs. More...

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

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

ACE_WChar_Codeset_Translatorwchar_translator_

Private Methods

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. More...

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


Friends

class ACE_Char_Codeset_Translator
 The translator need privileged access to efficiently demarshal arrays and the such. More...

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

References ACE_CDR_BYTE_ORDER, ACE_CDR::Octet, start_, and ACE_Message_Block::wr_ptr.

00629   : start_ (buf, bufsiz),
00630     do_byte_swap_ (byte_order != ACE_CDR_BYTE_ORDER),
00631     good_bit_ (1),
00632     major_version_ (major_version),
00633     minor_version_ (minor_version),
00634     char_translator_ (0),
00635     wchar_translator_ (0)
00636 {
00637   this->start_.wr_ptr (bufsiz);
00638 }

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

References ACE_CDR_BYTE_ORDER, and ACE_CDR::Octet.

00644   : start_ (bufsiz),
00645     do_byte_swap_ (byte_order != ACE_CDR_BYTE_ORDER),
00646     good_bit_ (1),
00647     major_version_ (major_version),
00648     minor_version_ (minor_version),
00649     char_translator_ (0),
00650     wchar_translator_ (0)
00651 {
00652 }

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
 

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

References byte_order, ACE_CDR::Octet, and reset.

00658   : start_ (),
00659     good_bit_ (1),
00660     major_version_ (major_version),
00661     minor_version_ (minor_version),
00662     char_translator_ (0),
00663     wchar_translator_ (0)
00664 
00665 {
00666   this->reset (data, byte_order);
00667 }

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

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

00674   : start_ (data, flag),
00675     do_byte_swap_ (byte_order != ACE_CDR_BYTE_ORDER),
00676     good_bit_ (1),
00677     major_version_ (major_version),
00678     minor_version_ (minor_version),
00679     char_translator_ (0),
00680     wchar_translator_ (0)
00681 
00682 {
00683 }

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 685 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, start_, and ACE_Message_Block::wr_ptr.

00692   : start_ (data, flag),
00693     do_byte_swap_ (byte_order != ACE_CDR_BYTE_ORDER),
00694     good_bit_ (1),
00695     major_version_ (major_version),
00696     minor_version_ (minor_version),
00697     char_translator_ (0),
00698     wchar_translator_ (0)
00699 
00700 {
00701   // Set the read pointer
00702   this->start_.rd_ptr (rd_pos);
00703 
00704   // Set the write pointer after doing a sanity check.
00705   char* wrpos = this->start_.base () + wr_pos;
00706 
00707   if (this->start_.end () >= wrpos)
00708     {
00709       this->start_.wr_ptr (wr_pos);
00710     }
00711 }

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

References ACE_ptr_align_binary, ACE_CDR::MAX_ALIGNMENT, ACE_Message_Block::rd_ptr, start_, and ACE_Message_Block::wr_ptr.

00782   : start_ (rhs.start_,
00783             ACE_CDR::MAX_ALIGNMENT),
00784   do_byte_swap_ (rhs.do_byte_swap_),
00785   good_bit_ (1),
00786   major_version_ (rhs.major_version_),
00787   minor_version_ (rhs.minor_version_),
00788   char_translator_ (rhs.char_translator_),
00789   wchar_translator_ (rhs.wchar_translator_)
00790 {
00791   char *buf = ACE_ptr_align_binary (rhs.start_.base (),
00792                                     ACE_CDR::MAX_ALIGNMENT);
00793 
00794   size_t rd_offset = rhs.start_.rd_ptr () - buf;
00795   size_t wr_offset = rhs.start_.wr_ptr () - buf;
00796   this->start_.rd_ptr (rd_offset);
00797   this->start_.wr_ptr (wr_offset);
00798 }

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

References ACE_ptr_align_binary, ACE_Message_Block::base, good_bit_, ACE_CDR::Long, ACE_CDR::MAX_ALIGNMENT, ACE_Message_Block::rd_ptr, ACE_Message_Block::space, start_, and ACE_Message_Block::wr_ptr.

00717   : start_ (rhs.start_,
00718             ACE_CDR::MAX_ALIGNMENT),
00719   do_byte_swap_ (rhs.do_byte_swap_),
00720   good_bit_ (1),
00721   major_version_ (rhs.major_version_),
00722   minor_version_ (rhs.minor_version_),
00723   char_translator_ (rhs.char_translator_),
00724   wchar_translator_ (rhs.wchar_translator_)
00725 
00726 {
00727   // Align the base pointer assuming that the incoming stream is also
00728   // aligned the way we are aligned
00729   char *incoming_start = ACE_ptr_align_binary (rhs.start_.base (),
00730                                                ACE_CDR::MAX_ALIGNMENT);
00731 
00732   size_t newpos =
00733     (rhs.start_.rd_ptr() - incoming_start)  + offset;
00734 
00735   if (newpos <= this->start_.space ()
00736       && newpos + size <= this->start_.space ())
00737     {
00738       this->start_.rd_ptr (newpos);
00739       this->start_.wr_ptr (newpos + size);
00740     }
00741   else
00742     this->good_bit_ = 0;
00743 }

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

References ACE_CDR_BYTE_ORDER, ACE_ptr_align_binary, ACE_Message_Block::base, byte_order, do_byte_swap_, good_bit_, ACE_CDR::MAX_ALIGNMENT, ACE_CDR::Octet, ACE_Message_Block::rd_ptr, read_octet, ACE_Message_Block::space, start_, and ACE_Message_Block::wr_ptr.

00747   : start_ (rhs.start_,
00748             ACE_CDR::MAX_ALIGNMENT),
00749   do_byte_swap_ (rhs.do_byte_swap_),
00750   good_bit_ (1),
00751   major_version_ (rhs.major_version_),
00752   minor_version_ (rhs.minor_version_),
00753   char_translator_ (rhs.char_translator_),
00754   wchar_translator_ (rhs.wchar_translator_)
00755 
00756 {
00757   // Align the base pointer assuming that the incoming stream is also
00758   // aligned the way we are aligned
00759   char *incoming_start = ACE_ptr_align_binary (rhs.start_.base (),
00760                                                ACE_CDR::MAX_ALIGNMENT);
00761 
00762   size_t newpos =
00763     rhs.start_.rd_ptr() - incoming_start;
00764 
00765   if (newpos <= this->start_.space ()
00766       && newpos + size <= this->start_.space ())
00767     {
00768       // Notice that ACE_Message_Block::duplicate may leave the
00769       // wr_ptr() with a higher value that what we actually want.
00770       this->start_.rd_ptr (newpos);
00771       this->start_.wr_ptr (newpos + size);
00772 
00773       ACE_CDR::Octet byte_order;
00774       this->read_octet (byte_order);
00775       this->do_byte_swap_ = (byte_order != ACE_CDR_BYTE_ORDER);
00776     }
00777   else
00778     this->good_bit_ = 0;
00779 }

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 834 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, ACE_Message_Block::rd_ptr, and start_.

00838   : start_ (rhs.total_length () + ACE_CDR::MAX_ALIGNMENT,
00839             ACE_Message_Block::MB_DATA,
00840             0,
00841             0,
00842             buffer_allocator,
00843             0,
00844             0,
00845             ACE_Time_Value::zero,
00846             ACE_Time_Value::max_time,
00847             data_block_allocator,
00848             message_block_allocator),
00849                                            do_byte_swap_ (rhs.do_byte_swap_),
00850                                            good_bit_ (1),
00851                                            major_version_ (rhs.major_version_),
00852                                            minor_version_ (rhs.minor_version_),
00853                                            char_translator_ (rhs.char_translator_),
00854                                            wchar_translator_ (rhs.wchar_translator_)
00855 {
00856   ACE_CDR::mb_align (&this->start_);
00857   for (const ACE_Message_Block *i = rhs.begin ();
00858        i != rhs.end ();
00859        i = i->cont ())
00860     this->start_.copy (i->rd_ptr (), i->length ());
00861 }

ACE_InputCDR::ACE_InputCDR Transfer_Contents    rhs
 

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

Definition at line 800 of file CDR_Stream.cpp.

References ACE_Data_Block::clone_nocopy, ACE_Message_Block::data_block, ACE_Message_Block::rd_ptr, start_, and ACE_Message_Block::wr_ptr.

00801   : start_ (x.rhs_.start_.data_block ()),
00802     do_byte_swap_ (x.rhs_.do_byte_swap_),
00803     good_bit_ (1),
00804     major_version_ (x.rhs_.major_version_),
00805     minor_version_ (x.rhs_.minor_version_),
00806     char_translator_ (x.rhs_.char_translator_),
00807     wchar_translator_ (x.rhs_.wchar_translator_)
00808 {
00809 
00810   this->start_.rd_ptr (x.rhs_.start_.rd_ptr ());
00811   this->start_.wr_ptr (x.rhs_.start_.wr_ptr ());
00812 
00813   ACE_Data_Block* db = this->start_.data_block ()->clone_nocopy ();
00814   (void) x.rhs_.start_.replace_data_block (db);
00815 }

ACE_INLINE ACE_InputCDR::~ACE_InputCDR void   
 

Destructor.

Definition at line 543 of file CDR_Stream.i.

00544 {
00545 }


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 972 of file CDR_Stream.i.

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

00975 {
00976   buf = ACE_ptr_align_binary (this->rd_ptr (), align);
00977   char *end = buf + size;
00978   if (end <= this->wr_ptr ())
00979     {
00980       this->start_.rd_ptr (end);
00981       return 0;
00982     }
00983 
00984   this->good_bit_ = 0;
00985   return -1;
00986 }

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 0 and returns a -1 on failure.

Definition at line 989 of file CDR_Stream.i.

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

00991 {
00992   return this->adjust (size, size, buf);
00993 }

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 1413 of file CDR_Stream.i.

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

01414 {
01415   char *buf = ACE_ptr_align_binary (this->rd_ptr (),
01416                                     alignment);
01417 
01418   if (buf <= this->wr_ptr ())
01419     {
01420       this->start_.rd_ptr (buf);
01421       return 0;
01422     }
01423 
01424   this->good_bit_ = 0;
01425   return -1;
01426 }

ACE_INLINE int ACE_InputCDR::byte_order void    const
 

If <do_byte_swap> returns 0, this returns ACE_CDR_BYTE_ORDER else it returns !ACE_CDR_BYTE_ORDER.

Definition at line 1404 of file CDR_Stream.i.

References ACE_CDR_BYTE_ORDER, and do_byte_swap.

Referenced by ACE_InputCDR, exchange_data_blocks, reset, and reset_byte_order.

01405 {
01406   if (this->do_byte_swap ())
01407     return !ACE_CDR_BYTE_ORDER;
01408   else
01409     return ACE_CDR_BYTE_ORDER;
01410 }

ACE_INLINE void ACE_InputCDR::char_translator ACE_Char_Codeset_Translator  
 

Set the codeset translators.

Definition at line 1460 of file CDR_Stream.i.

References char_translator_.

01461 {
01462   this->char_translator_ = ctran;
01463 }

ACE_INLINE ACE_Char_Codeset_Translator * ACE_InputCDR::char_translator void    const
 

Access the codeset translators. They can be nil!

Definition at line 1447 of file CDR_Stream.i.

References char_translator_.

01448 {
01449   return this->char_translator_;
01450 }

ACE_Data_Block * ACE_InputCDR::clone_from ACE_InputCDR &    cdr
 

Copy the data portion from the <cdr> to this cdr and return the data content (ie. the ACE_Data_Block) from this CDR to the caller. The caller is responsible for managing the memory of the returned ACE_Data_Block.

Definition at line 1495 of file CDR_Stream.cpp.

References 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::mb_align, ACE_OS_String::memcpy, minor_version_, ACE_Message_Block::rd_ptr, rd_ptr, ACE_Message_Block::replace_data_block, ACE_Message_Block::reset, start_, ACE_Message_Block::wr_ptr, and wr_ptr.

01496 {
01497   this->do_byte_swap_ = cdr.do_byte_swap_;
01498 
01499   // Replace our data block by using the incoming CDR stream.
01500   ACE_Data_Block *db =
01501     this->start_.replace_data_block (cdr.start_.data_block ()->clone_nocopy ());
01502 
01503   // Align the start_ message block.
01504   ACE_CDR::mb_align (&this->start_);
01505 
01506   // Clear the DONT_DELETE flag if it has been set
01507   this->start_.clr_self_flags (ACE_Message_Block::DONT_DELETE);
01508 
01509   // Get the read & write pointer positions in the incoming CDR
01510   // streams
01511   char *rd_ptr = cdr.start_.rd_ptr ();
01512   char *wr_ptr = cdr.start_.wr_ptr ();
01513 
01514   // Now reset the incoming CDR stream
01515   cdr.start_.reset ();
01516 
01517   // As we have reset the stream, try to align the underlying message
01518   // block in the incoming stream
01519   ACE_CDR::mb_align (&cdr.start_);
01520 
01521   // Get the read & write pointer positions again
01522   char *nrd_ptr = cdr.start_.rd_ptr ();
01523   char *nwr_ptr = cdr.start_.wr_ptr ();
01524 
01525   // Actual length of the stream is..
01526   // @todo: This will look idiotic, but we dont seem to have much of a
01527   // choice. How do we calculate the length of the incoming stream?
01528   // Calling the method before calling reset () would give us the
01529   // wrong length of the stream that needs copying.  So we do the
01530   // calulation like this
01531   // (1) We get the <rd_ptr> and <wr_ptr> positions of the incoming
01532   // stream.
01533   // (2) Then we reset the <incoming> stream and then align it.
01534   // (3) We get the <rd_ptr> and <wr_ptr> positions again. (Points #1
01535   // thru #3 has been done already)
01536   // (4) The difference in the <rd_ptr> and <wr_ptr> positions gives
01537   // us the following, the actual bytes traversed by the <rd_ptr> and
01538   // <wr_ptr>.
01539   // (5) The bytes traversed by the <wr_ptr> is the actual length of
01540   // the stream.
01541 
01542   // Actual bytes traversed
01543   size_t rd_bytes = rd_ptr - nrd_ptr;
01544   size_t wr_bytes = wr_ptr - nwr_ptr;
01545 
01546   // Now do the copy
01547   (void) ACE_OS::memcpy (this->start_.wr_ptr (),
01548                          cdr.start_.rd_ptr (),
01549                          wr_bytes);
01550 
01551   // Set the read pointer position to the same point as that was in
01552   // <incoming> cdr.
01553   this->start_.rd_ptr (rd_bytes);
01554   this->start_.wr_ptr (wr_bytes);
01555 
01556   // We have changed the read & write pointers for the incoming
01557   // stream. Set them back to the positions that they were before..
01558   cdr.start_.rd_ptr (rd_bytes);
01559   cdr.start_.wr_ptr (wr_bytes);
01560 
01561   this->major_version_ = cdr.major_version_;
01562   this->minor_version_ = cdr.minor_version_;
01563 
01564   return db;
01565 }

ACE_INLINE int ACE_InputCDR::do_byte_swap void    const
 

If non-zero 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 1398 of file CDR_Stream.i.

References do_byte_swap_.

Referenced by byte_order.

01399 {
01400   return this->do_byte_swap_;
01401 }

ACE_INLINE char * ACE_InputCDR::end void    [private]
 

Points to the continuation field of the current message block.

Definition at line 948 of file CDR_Stream.i.

References ACE_Message_Block::end, and start_.

Referenced by adjust.

00949 {
00950   return this->start_.end ();
00951 }

void ACE_InputCDR::exchange_data_blocks ACE_InputCDR &    cdr
 

Exchange data blocks with the caller of this method. The read and write pointers are also exchanged. Note: We now do only with the start_ message block.

Definition at line 1432 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_, 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.

01433 {
01434   // Exchange byte orders
01435   int byte_order = cdr.do_byte_swap_;
01436   cdr.do_byte_swap_ = this->do_byte_swap_;
01437   this->do_byte_swap_ = byte_order;
01438 
01439   // Get the destination read and write pointers
01440   size_t drd_pos =
01441     cdr.start_.rd_ptr () - cdr.start_.base ();
01442   size_t dwr_pos =
01443     cdr.start_.wr_ptr () - cdr.start_.base ();
01444 
01445   // Get the source read & write pointers
01446   size_t srd_pos =
01447     this->start_.rd_ptr () - this->start_.base ();
01448   size_t swr_pos =
01449     this->start_.wr_ptr () - this->start_.base ();
01450 
01451   // Exchange data_blocks. Dont release any of the data blocks.
01452   ACE_Data_Block *dnb =
01453     this->start_.replace_data_block (cdr.start_.data_block ());
01454   cdr.start_.replace_data_block (dnb);
01455 
01456   // Exchange the flags information..
01457   ACE_Message_Block::Message_Flags df = cdr.start_.self_flags ();
01458   ACE_Message_Block::Message_Flags sf = this->start_.self_flags ();
01459 
01460   cdr.start_.clr_self_flags (df);
01461   this->start_.clr_self_flags (sf);
01462 
01463   cdr.start_.set_self_flags (sf);
01464   this->start_.set_self_flags (df);
01465 
01466   // Reset the <cdr> pointers to zero before it is set again.
01467   cdr.start_.reset ();
01468   this->start_.reset ();
01469 
01470   // Set the read and write pointers.
01471   if (cdr.start_.size () >= srd_pos)
01472     cdr.start_.rd_ptr (srd_pos);
01473 
01474   if (cdr.start_.size () >= swr_pos)
01475     cdr.start_.wr_ptr (swr_pos);
01476 
01477   if (this->start_.size () >= drd_pos)
01478     this->start_.rd_ptr (drd_pos);
01479 
01480   if (this->start_.size () >= dwr_pos)
01481     this->start_.wr_ptr (dwr_pos);
01482 
01483   ACE_CDR::Octet dmajor = cdr.major_version_;
01484   ACE_CDR::Octet dminor = cdr.minor_version_;
01485 
01486   // Exchange the GIOP version info
01487   cdr.major_version_ = this->major_version_;
01488   cdr.minor_version_ = this->minor_version_;
01489 
01490   this->major_version_ = dmajor;
01491   this->minor_version_ = dminor;
01492 }

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

Set the underlying GIOP version..

Definition at line 1438 of file CDR_Stream.i.

References major_version_, minor_version_, and ACE_CDR::Octet.

01440 {
01441   major = this->major_version_;
01442   minor = this->minor_version_;
01443   return 0;
01444 }

ACE_INLINE int ACE_InputCDR::good_bit void    const
 

returns zero if a problem has been detected.

Definition at line 1002 of file CDR_Stream.i.

References good_bit_.

Referenced by operator>>.

01003 {
01004   return this->good_bit_;
01005 }

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

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

01398 {
01399   if (ACE_CDR::grow (&this->start_, newsize) == -1)
01400     return -1;
01401 
01402   ACE_CDR::mb_align (&this->start_);
01403   this->start_.wr_ptr (newsize);
01404   return 0;
01405 }

ACE_INLINE size_t ACE_InputCDR::length void    const
 

Return how many bytes are left in the stream.

Definition at line 631 of file CDR_Stream.i.

References ACE_Message_Block::length, and start_.

Referenced by read_array, 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, read_wchar_array_i, and read_wstring.

00632 {
00633   return this->start_.length ();
00634 }

ACE_InputCDR & ACE_InputCDR::operator= const ACE_InputCDR &    rhs
 

Definition at line 818 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.

00819 {
00820   if (this != &rhs)
00821     {
00822       this->start_.data_block (rhs.start_.data_block ()->duplicate ());
00823       this->start_.rd_ptr (rhs.start_.rd_ptr ());
00824       this->start_.wr_ptr (rhs.start_.wr_ptr ());
00825       this->do_byte_swap_ = rhs.do_byte_swap_;
00826       this->good_bit_ = 1;
00827       this->char_translator_ = rhs.char_translator_;
00828       this->major_version_ = rhs.major_version_;
00829       this->minor_version_ = rhs.minor_version_;
00830     }
00831   return *this;
00832 }

ACE_INLINE void ACE_InputCDR::rd_ptr size_t    offset [private]
 

Move the rd_ptr ahead by <offset> bytes.

Definition at line 954 of file CDR_Stream.i.

References ACE_Message_Block::rd_ptr, and start_.

00955 {
00956   this->start_.rd_ptr (offset);
00957 }

ACE_INLINE char * ACE_InputCDR::rd_ptr void   
 

Returns the current position for the rd_ptr....

Definition at line 960 of file CDR_Stream.i.

References ACE_Message_Block::rd_ptr, and start_.

Referenced by clone_from, read_1, skip_bytes, and skip_string.

00961 {
00962   return this->start_.rd_ptr ();
00963 }

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

Definition at line 1221 of file CDR_Stream.cpp.

References good_bit_, ACE_CDR::Octet, ACE_Message_Block::rd_ptr, rd_ptr, start_, and wr_ptr.

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

01222 {
01223   if (this->rd_ptr () < this->wr_ptr ())
01224     {
01225       *x = *ACE_reinterpret_cast (ACE_CDR::Octet*,this->rd_ptr ());
01226       this->start_.rd_ptr (1);
01227       return 1;
01228     }
01229 
01230   this->good_bit_ = 0;
01231   return 0;
01232 }

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

Definition at line 1326 of file CDR_Stream.cpp.

References adjust, do_byte_swap_, good_bit_, ACE_CDR::LONGLONG_ALIGN, ACE_CDR::LONGLONG_SIZE, and ACE_CDR::swap_16.

Referenced by read_longdouble, and skip_longdouble.

01327 {
01328   char *buf;
01329   if (this->adjust (ACE_CDR::LONGLONG_SIZE,
01330                     ACE_CDR::LONGLONG_ALIGN,
01331                     buf) == 0)
01332     {
01333 #if !defined (ACE_DISABLE_SWAP_ON_READ)
01334       if (!this->do_byte_swap_)
01335         *x = *ACE_reinterpret_cast (ACE_CDR::LongDouble *, buf);
01336       else
01337         ACE_CDR::swap_16 (buf, ACE_reinterpret_cast (char*, x));
01338 #else
01339       *x = *ACE_reinterpret_cast(ACE_CDR::LongDouble*,buf);
01340 #endif /* ACE_DISABLE_SWAP_ON_READ */
01341       return 1;
01342     }
01343 
01344   this->good_bit_ = 0;
01345   return 0;
01346 }

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

Definition at line 1235 of file CDR_Stream.cpp.

References adjust, do_byte_swap_, good_bit_, ACE_CDR::SHORT_SIZE, ACE_CDR::swap_2, and ACE_CDR::UShort.

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

01236 {
01237   char *buf;
01238   if (this->adjust (ACE_CDR::SHORT_SIZE, buf) == 0)
01239     {
01240 #if !defined (ACE_DISABLE_SWAP_ON_READ)
01241       if (!this->do_byte_swap_)
01242         *x = *ACE_reinterpret_cast (ACE_CDR::UShort*, buf);
01243       else
01244         ACE_CDR::swap_2 (buf, ACE_reinterpret_cast (char*, x));
01245 #else
01246       *x = *ACE_reinterpret_cast(ACE_CDR::UShort*,buf);
01247 #endif /* ACE_DISABLE_SWAP_ON_READ */
01248       return 1;
01249     }
01250   this->good_bit_ = 0;
01251   return 0;
01252 }

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

Definition at line 1255 of file CDR_Stream.cpp.

References adjust, do_byte_swap_, good_bit_, ACE_CDR::LONG_SIZE, 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_float, skip_long, skip_ulong, and skip_wchar.

01256 {
01257   char *buf;
01258   if (this->adjust (ACE_CDR::LONG_SIZE, buf) == 0)
01259     {
01260 #if !defined (ACE_DISABLE_SWAP_ON_READ)
01261       if (!this->do_byte_swap_)
01262         *x = *ACE_reinterpret_cast (ACE_CDR::ULong*, buf);
01263       else
01264         ACE_CDR::swap_4 (buf, ACE_reinterpret_cast (char*, x));
01265 #else
01266       *x = *ACE_reinterpret_cast(ACE_CDR::ULong*,buf);
01267 #endif /* ACE_DISABLE_SWAP_ON_READ */
01268       return 1;
01269     }
01270   this->good_bit_ = 0;
01271   return 0;
01272 }

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

Definition at line 1275 of file CDR_Stream.cpp.

References adjust, do_byte_swap_, good_bit_, ACE_CDR::LONGLONG_SIZE, ACE_CDR::swap_8, and ACE_CDR::ULongLong.

Referenced by read_double, read_longlong, read_ulonglong, skip_double, skip_longlong, and skip_ulonglong.

01276 {
01277   char *buf;
01278 
01279   if (this->adjust (ACE_CDR::LONGLONG_SIZE, buf) == 0)
01280     {
01281 #if !defined (ACE_DISABLE_SWAP_ON_READ)
01282 #  if defined (__arm__)
01283       if (!this->do_byte_swap_)
01284         {
01285           // Convert from Intel format (12345678 => 56781234)
01286           const char *orig = buf;
01287           char *target = ACE_reinterpret_cast (char *, x);
01288           register ACE_UINT32 x =
01289             *ACE_reinterpret_cast (const ACE_UINT32 *, orig);
01290           register ACE_UINT32 y =
01291             *ACE_reinterpret_cast (const ACE_UINT32 *, orig + 4);
01292           *ACE_reinterpret_cast (ACE_UINT32 *, target) = y;
01293           *ACE_reinterpret_cast (ACE_UINT32 *, target + 4) = x;
01294         }
01295       else
01296         {
01297           // Convert from Sparc format (12345678 => 43218765)
01298           const char *orig = buf;
01299           char *target = ACE_reinterpret_cast (char *, x);
01300           register ACE_UINT32 x =
01301             *ACE_reinterpret_cast (const ACE_UINT32 *, orig);
01302           register ACE_UINT32 y =
01303             *ACE_reinterpret_cast (const ACE_UINT32 *, orig + 4);
01304           x = (x << 24) | ((x & 0xff00) << 8) | ((x & 0xff0000) >> 8) | (x >> 24);
01305           y = (y << 24) | ((y & 0xff00) << 8) | ((y & 0xff0000) >> 8) | (y >> 24);
01306           *ACE_reinterpret_cast (ACE_UINT32 *, target) = x;
01307           *ACE_reinterpret_cast (ACE_UINT32 *, target + 4) = y;
01308         }
01309 #  else
01310       if (!this->do_byte_swap_)
01311         *x = *ACE_reinterpret_cast (ACE_CDR::ULongLong *, buf);
01312       else
01313         ACE_CDR::swap_8 (buf, ACE_reinterpret_cast (char *, x));
01314 #  endif /* !__arm__ */
01315 #else
01316       *x = *ACE_reinterpret_cast (ACE_CDR::ULongLong *, buf);
01317 #endif /* ACE_DISABLE_SWAP_ON_READ */
01318       return 1;
01319     }
01320 
01321   this->good_bit_ = 0;
01322   return 0;
01323 }

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

References adjust, do_byte_swap_, good_bit_, length, ACE_OS_String::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, and read_wchar_array.

01115 {
01116   if (length == 0)
01117     return 1;
01118   char* buf;
01119 
01120   if (this->adjust (size * length, align, buf) == 0)
01121     {
01122 #if defined (ACE_DISABLE_SWAP_ON_READ)
01123       ACE_OS::memcpy (x, buf, size*length);
01124 #else
01125       if (!this->do_byte_swap_ || size == 1)
01126         ACE_OS::memcpy (x, buf, size*length);
01127       else
01128         {
01129           char *target = ACE_reinterpret_cast (char*, x);
01130           switch (size)
01131             {
01132             case 2:
01133               ACE_CDR::swap_2_array (buf, target, length);
01134               break;
01135             case 4:
01136               ACE_CDR::swap_4_array (buf, target, length);
01137               break;
01138             case 8:
01139               ACE_CDR::swap_8_array (buf, target, length);
01140               break;
01141             case 16:
01142               ACE_CDR::swap_16_array (buf, target, length);
01143               break;
01144             default:
01145               // TODO: print something?
01146               this->good_bit_ = 0;
01147               return 0;
01148             }
01149         }
01150 #endif /* ACE_DISABLE_SWAP_ON_READ */
01151       return this->good_bit_;
01152     }
01153   return 0;
01154 }

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

Return 0 on failure and 1 on success.

Definition at line 554 of file CDR_Stream.i.

References ACE_CDR::Boolean, good_bit_, ACE_CDR::Octet, and read_octet.

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

00555 {
00556   ACE_CDR::Octet tmp;
00557   this->read_octet (tmp);
00558   x = tmp ? (ACE_CDR::Boolean) 1 : (ACE_CDR::Boolean) 0;
00559   return (ACE_CDR::Boolean) this->good_bit_;
00560 }

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 0 on failure and 1 on success.

Definition at line 1198 of file CDR_Stream.cpp.

References ACE_CDR::Boolean, good_bit_, length, read_boolean, and ACE_CDR::ULong.

01200 {
01201   // Make sure the length of the array isn't greater than the length of
01202   // the stream.
01203   if (length > this->length())
01204     {
01205       this->good_bit_ = 0;
01206       return 0;
01207     }
01208 
01209   // It is hard to optimize this, the spec requires that on the wire
01210   // booleans be represented as a byte with value 0 or 1, but in
01211   // memoery it is possible (though very unlikely) that a boolean has
01212   // a non-zero value (different from 1).
01213   // We resort to a simple loop.
01214   for (ACE_CDR::ULong i = 0; i != length && this->good_bit_; ++i)
01215     this->read_boolean (x[i]);
01216 
01217   return this->good_bit_;
01218 }

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

Return 0 on failure and 1 on success.

Definition at line 563 of file CDR_Stream.i.

References ACE_CDR::Char, char_translator_, ACE_CDR::Octet, read_1, and ACE_Char_Codeset_Translator::read_char.

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

00564 {
00565   if (this->char_translator_ == 0)
00566     return this->read_1 (ACE_reinterpret_cast (ACE_CDR::Octet*, &x));
00567   return this->char_translator_->read_char (*this, x);
00568 }

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 0 on failure and 1 on success.

Definition at line 637 of file CDR_Stream.i.

References ACE_CDR::Char, char_translator_, good_bit_, length, ACE_CDR::OCTET_ALIGN, ACE_CDR::OCTET_SIZE, read_array, ACE_Char_Codeset_Translator::read_char_array, and ACE_CDR::ULong.

Referenced by read_string.

00639 {
00640   // Make sure the length of the array isn't greater than the length of
00641   // the stream.
00642   if (length > this->length())
00643     {
00644       this->good_bit_ = 0;
00645       return 0;
00646     }
00647 
00648   if (this->char_translator_ == 0)
00649     return this->read_array (x,
00650                              ACE_CDR::OCTET_SIZE,
00651                              ACE_CDR::OCTET_ALIGN,
00652                              length);
00653   return this->char_translator_->read_char_array (*this, x, length);
00654 }

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

Return 0 on failure and 1 on success.

Definition at line 619 of file CDR_Stream.i.

References read_8, and ACE_CDR::ULongLong.

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

00620 {
00621   return this->read_8 (ACE_reinterpret_cast (ACE_CDR::ULongLong*, &x));
00622 }

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 0 on failure and 1 on success.

Definition at line 826 of file CDR_Stream.i.

References good_bit_, length, ACE_CDR::LONGLONG_ALIGN, ACE_CDR::LONGLONG_SIZE, read_array, and ACE_CDR::ULong.

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

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

Return 0 on failure and 1 on success.

Definition at line 612 of file CDR_Stream.i.

References read_4, and ACE_CDR::ULong.

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

00613 {
00614   return this->read_4 (ACE_reinterpret_cast (ACE_CDR::ULong*, &x));
00615 }

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 0 on failure and 1 on success.

Definition at line 807 of file CDR_Stream.i.

References good_bit_, length, ACE_CDR::LONG_ALIGN, ACE_CDR::LONG_SIZE, read_array, and ACE_CDR::ULong.

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

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

Return 0 on failure and 1 on success.

Definition at line 585 of file CDR_Stream.i.

References ACE_CDR::Long, read_4, and ACE_CDR::ULong.

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

00586 {
00587   return this->read_4 (ACE_reinterpret_cast (ACE_CDR::ULong*, &x));
00588 }

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 0 on failure and 1 on success.

Definition at line 735 of file CDR_Stream.i.

References good_bit_, length, ACE_CDR::Long, ACE_CDR::LONG_ALIGN, ACE_CDR::LONG_SIZE, read_array, and ACE_CDR::ULong.

00737 {
00738   // Make sure the length of the array isn't greater than the length of
00739   // the stream.
00740   if (length * ACE_CDR::LONG_SIZE > this->length())
00741     {
00742       this->good_bit_ = 0;
00743       return 0;
00744     }
00745 
00746   return this->read_array (x,
00747                            ACE_CDR::LONG_SIZE,
00748                            ACE_CDR::LONG_ALIGN,
00749                            length);
00750 }

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

Return 0 on failure and 1 on success.

Definition at line 625 of file CDR_Stream.i.

References read_16.

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

00626 {
00627   return this->read_16 (ACE_reinterpret_cast (ACE_CDR::LongDouble*,&x));
00628 }

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 0 on failure and 1 on success.

Definition at line 844 of file CDR_Stream.i.

References good_bit_, length, ACE_CDR::LONGDOUBLE_ALIGN, ACE_CDR::LONGDOUBLE_SIZE, read_array, and ACE_CDR::ULong.

00846 {
00847   // Make sure the length of the array isn't greater than the length of
00848   // the stream.
00849   if (length * ACE_CDR::LONGDOUBLE_SIZE > this->length())
00850     {
00851       this->good_bit_ = 0;
00852       return 0;
00853     }
00854   return this->read_array (x,
00855                            ACE_CDR::LONGDOUBLE_SIZE,
00856                            ACE_CDR::LONGDOUBLE_ALIGN,
00857                            length);
00858 }

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

Return 0 on failure and 1 on success.

Definition at line 599 of file CDR_Stream.i.

References ACE_CDR::LongLong, read_8, and ACE_CDR::ULongLong.

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

00600 {
00601   return this->read_8 (ACE_reinterpret_cast (ACE_CDR::ULongLong*, &x));
00602 }

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 0 on failure and 1 on success.

Definition at line 771 of file CDR_Stream.i.

References good_bit_, length, ACE_CDR::LongLong, ACE_CDR::LONGLONG_ALIGN, ACE_CDR::LONGLONG_SIZE, read_array, and ACE_CDR::ULong.

00773 {
00774   // Make sure the length of the array isn't greater than the length of
00775   // the stream.
00776   if (length * ACE_CDR::LONGLONG_SIZE > this->length())
00777     {
00778       this->good_bit_ = 0;
00779       return 0;
00780     }
00781 
00782   return this->read_array (x,
00783                            ACE_CDR::LONGLONG_SIZE,
00784                            ACE_CDR::LONGLONG_ALIGN,
00785                            length);
00786 }

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

Return 0 on failure and 1 on success.

Definition at line 548 of file CDR_Stream.i.

References ACE_CDR::Octet, and read_1.

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

00549 {
00550   return this->read_1 (&x);
00551 }

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 0 on failure and 1 on success.

Definition at line 681 of file CDR_Stream.i.

References good_bit_, length, ACE_CDR::Octet, ACE_CDR::OCTET_ALIGN, ACE_CDR::OCTET_SIZE, read_array, and ACE_CDR::ULong.

Referenced by read_wchar.

00683 {
00684   // Make sure the length of the array isn't greater than the length of
00685   // the stream.
00686   if (length * ACE_CDR::OCTET_SIZE > this->length())
00687     {
00688       this->good_bit_ = 0;
00689       return 0;
00690     }
00691 
00692   return this->read_array (x,
00693                            ACE_CDR::OCTET_SIZE,
00694                            ACE_CDR::OCTET_ALIGN,
00695                            length);
00696 }

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

Return 0 on failure and 1 on success.

Definition at line 572 of file CDR_Stream.i.

References read_2, ACE_CDR::Short, and ACE_CDR::UShort.

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

00573 {
00574   return this->read_2 (ACE_reinterpret_cast (ACE_CDR::UShort*, &x));
00575 }

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 0 on failure and 1 on success.

Definition at line 699 of file CDR_Stream.i.

References good_bit_, length, read_array, ACE_CDR::Short, ACE_CDR::SHORT_ALIGN, ACE_CDR::SHORT_SIZE, and ACE_CDR::ULong.

00701 {
00702   // Make sure the length of the array isn't greater than the length of
00703   // the stream.
00704   if (length * ACE_CDR::SHORT_SIZE > this->length())
00705     {
00706       this->good_bit_ = 0;
00707       return 0;
00708     }
00709 
00710   return this->read_array (x,
00711                            ACE_CDR::SHORT_SIZE,
00712                            ACE_CDR::SHORT_ALIGN,
00713                            length);
00714 }

ACE_CDR::Boolean ACE_InputCDR::read_string ACE_CString   x
 

Return 0 on failure and 1 on success.

Definition at line 1020 of file CDR_Stream.cpp.

References ACE_CDR::Char, good_bit_, and read_string.

01021 {
01022   ACE_CDR::Char *data;
01023   if (this->read_string (data))
01024     {
01025       x = data;
01026       delete [] data;
01027       return 1;
01028     }
01029 
01030   x = "";
01031   return (this->good_bit_ = 0);
01032 }

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

Return 0 on failure and 1 on success.

Definition at line 977 of file CDR_Stream.cpp.

References ACE_NEW_RETURN, ACE_CDR::Char, char_translator_, good_bit_, length, read_char_array, ACE_Char_Codeset_Translator::read_string, read_ulong, ACE_OS_String::strcpy, and ACE_CDR::ULong.

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

00978 {
00979   // @@ This is a slight violation of "Optimize for the common case",
00980   // i.e. normally the translator will be 0, but OTOH the code is
00981   // smaller and should be better for the cache ;-) ;-)
00982   if (this->char_translator_ != 0)
00983     {
00984       this->good_bit_ = this->char_translator_->read_string (*this, x);
00985       return this->good_bit_;
00986     }
00987 
00988   ACE_CDR::ULong len;
00989 
00990   this->read_ulong (len);
00991   // A check for the length being too great is done later in the
00992   // call to read_char_array but we want to have it done before
00993   // the memory is allocated.
00994   if (len > 0 && len <= this->length())
00995     {
00996       ACE_NEW_RETURN (x,
00997                       ACE_CDR::Char[len],
00998                       0);
00999       if (this->read_char_array (x, len))
01000         return 1;
01001 
01002       delete [] x;
01003     }
01004   else if (len == 0)
01005     {
01006       // Convert any null strings to empty strings since empty
01007       // strings can cause crashes. (See bug 58.)
01008       ACE_NEW_RETURN (x,
01009                       ACE_CDR::Char[1],
01010                       0);
01011       ACE_OS::strcpy (ACE_const_cast (char *&, x), "");
01012       return 1;
01013     }
01014 
01015   x = 0;
01016   return (this->good_bit_ = 0);
01017 }

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

Return 0 on failure and 1 on success.

Definition at line 592 of file CDR_Stream.i.

References read_4, and ACE_CDR::ULong.

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

00593 {
00594   return this->read_4 (ACE_reinterpret_cast (ACE_CDR::ULong*, &x));
00595 }

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 0 on failure and 1 on success.

Definition at line 753 of file CDR_Stream.i.

References good_bit_, length, ACE_CDR::LONG_ALIGN, ACE_CDR::LONG_SIZE, read_array, and ACE_CDR::ULong.

00755 {
00756   // Make sure the length of the array isn't greater than the length of
00757   // the stream.
00758   if (length * ACE_CDR::LONG_SIZE > this->length())
00759     {
00760       this->good_bit_ = 0;
00761       return 0;
00762     }
00763 
00764   return this->read_array (x,
00765                            ACE_CDR::LONG_SIZE,
00766                            ACE_CDR::LONG_ALIGN,
00767                            length);
00768 }

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

Return 0 on failure and 1 on success.

Definition at line 605 of file CDR_Stream.i.

References read_8, and ACE_CDR::ULongLong.

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

00606 {
00607   return this->read_8 (ACE_reinterpret_cast (ACE_CDR::ULongLong*,&x));
00608 }

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 0 on failure and 1 on success.

Definition at line 789 of file CDR_Stream.i.

References good_bit_, length, ACE_CDR::LONGLONG_ALIGN, ACE_CDR::LONGLONG_SIZE, read_array, ACE_CDR::ULong, and ACE_CDR::ULongLong.

00791 {
00792   // Make sure the length of the array isn't greater than the length of
00793   // the stream.
00794   if (length * ACE_CDR::LONGLONG_SIZE > this->length())
00795     {
00796       this->good_bit_ = 0;
00797       return 0;
00798     }
00799 
00800   return this->read_array (x,
00801                            ACE_CDR::LONGLONG_SIZE,
00802                            ACE_CDR::LONGLONG_ALIGN,
00803                            length);
00804 }

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

Return 0 on failure and 1 on success.

Definition at line 578 of file CDR_Stream.i.

References read_2, and ACE_CDR::UShort.

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

00579 {
00580   return this->read_2 (ACE_reinterpret_cast (ACE_CDR::UShort*, &x));
00581 }

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 0 on failure and 1 on success.

Definition at line 717 of file CDR_Stream.i.

References good_bit_, length, read_array, ACE_CDR::SHORT_ALIGN, ACE_CDR::SHORT_SIZE, ACE_CDR::ULong, and ACE_CDR::UShort.

00719 {
00720   // Make sure the length of the array isn't greater than the length of
00721   // the stream.
00722   if (length * ACE_CDR::SHORT_SIZE > this->length())
00723     {
00724       this->good_bit_ = 0;
00725       return 0;
00726     }
00727 
00728   return this->read_array (x,
00729                            ACE_CDR::SHORT_SIZE,
00730                            ACE_CDR::SHORT_ALIGN,
00731                            length);
00732 }

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

Return 0 on failure and 1 on success.

Definition at line 886 of file CDR_Stream.cpp.

References good_bit_, major_version_, minor_version_, ACE_CDR::Octet, read_1, read_2, read_4, read_octet_array, ACE_WChar_Codeset_Translator::read_wchar, ACE_CDR::Short, ACE_CDR::ULong, ACE_CDR::UShort, ACE_CDR::WChar, ACE_OutputCDR::wchar_maxbytes_, and wchar_translator_.

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

00887 {
00888   if (this->wchar_translator_ != 0)
00889     {
00890       this->good_bit_ = this->wchar_translator_->read_wchar (*this,x);
00891       return this->good_bit_;
00892     }
00893   if (ACE_OutputCDR::wchar_maxbytes_ == 0)
00894     {
00895       errno = EACCES;
00896       return (this->good_bit_ = 0);
00897     }
00898 
00899   if (ACE_OutputCDR::wchar_maxbytes_ == sizeof (ACE_CDR::WChar))
00900     {
00901       if (ACE_static_cast (ACE_CDR::Short, major_version_) == 1
00902           && ACE_static_cast (ACE_CDR::Short, minor_version_) == 2)
00903         {
00904           ACE_CDR::Octet len;
00905 
00906           if (this->read_1 (&len))
00907             return this->read_octet_array
00908               (ACE_reinterpret_cast (ACE_CDR::Octet*, &x),
00909                ACE_static_cast (ACE_CDR::ULong, len));
00910           else
00911             return (this->good_bit_ = 0);
00912         }
00913 
00914       if (sizeof (ACE_CDR::WChar) == 2)
00915         return this->read_2 (ACE_reinterpret_cast (ACE_CDR::UShort *, &x));
00916       else
00917         return this->read_4 (ACE_reinterpret_cast (ACE_CDR::ULong *, &x));
00918     }
00919 
00920   if (ACE_static_cast (ACE_CDR::Short, major_version_) == 1
00921       && ACE_static_cast (ACE_CDR::Short, minor_version_) == 2)
00922     {
00923       ACE_CDR::Octet len;
00924 
00925       if (this->read_1 (&len))
00926         {
00927           if (len == 2)
00928             {
00929               ACE_CDR::Short sx;
00930               if (this->read_octet_array
00931                   (ACE_reinterpret_cast (ACE_CDR::Octet*, &sx),
00932                    ACE_static_cast (ACE_CDR::ULong, len)))
00933                 {
00934                   x = ACE_static_cast(ACE_CDR::WChar, sx);
00935                   return 1;
00936                 }
00937             }
00938           else
00939             {
00940               ACE_CDR::Octet ox;
00941               if (this->read_octet_array
00942                   (ACE_reinterpret_cast (ACE_CDR::Octet*, &ox),
00943                    ACE_static_cast (ACE_CDR::ULong, len)))
00944                 {
00945                   x = ACE_static_cast(ACE_CDR::WChar, ox);
00946                   return 1;
00947                 }
00948             }
00949         }
00950     }
00951   else
00952     {
00953       if (ACE_OutputCDR::wchar_maxbytes_ == 2)
00954         {
00955           ACE_CDR::UShort sx;
00956           if (this->read_2 (ACE_reinterpret_cast (ACE_CDR::UShort *, &sx)))
00957             {
00958               x = ACE_static_cast(ACE_CDR::WChar, sx);
00959               return 1;
00960             }
00961         }
00962       else
00963         {
00964           ACE_CDR::Octet ox;
00965           if (this->read_1 (&ox))
00966             {
00967               x = ACE_static_cast(ACE_CDR::WChar, ox);
00968               return 1;
00969             }
00970 
00971         }
00972     }
00973   return (this->good_bit_ = 0);
00974 }

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 0 on failure and 1 on success.

Definition at line 657 of file CDR_Stream.i.

References good_bit_, length, ACE_CDR::LONG_ALIGN, read_array, ACE_WChar_Codeset_Translator::read_wchar_array, read_wchar_array_i, ACE_CDR::SHORT_ALIGN, ACE_CDR::ULong, ACE_CDR::WChar, ACE_OutputCDR::wchar_maxbytes_, and wchar_translator_.

Referenced by read_wstring.

00659 {
00660   // Make sure the length of the array isn't greater than the length of
00661   // the stream.
00662   if (length * ACE_OutputCDR::wchar_maxbytes_ > this->length())
00663     {
00664       this->good_bit_ = 0;
00665       return 0;
00666     }
00667 
00668   if (this->wchar_translator_ != 0)
00669     return this->wchar_translator_->read_wchar_array (*this, x, length);
00670   if (ACE_OutputCDR::wchar_maxbytes_ != sizeof (ACE_CDR::WChar))
00671     return this->read_wchar_array_i (x, length);
00672   return this->read_array (x,
00673                            sizeof (ACE_CDR::WChar),
00674                            sizeof (ACE_CDR::WChar) == 2
00675                            ? ACE_CDR::SHORT_ALIGN
00676                            : ACE_CDR::LONG_ALIGN,
00677                            length);
00678 }

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

References adjust, do_byte_swap_, good_bit_, length, ACE_CDR::Octet, ACE_CDR::OCTET_ALIGN, ACE_CDR::SHORT_ALIGN, ACE_CDR::swap_2, ACE_CDR::ULong, ACE_CDR::UShort, ACE_CDR::WChar, and ACE_OutputCDR::wchar_maxbytes_.

Referenced by read_wchar_array.

01159 {
01160   if (length == 0)
01161     return 1;
01162   char* buf;
01163   size_t align = (ACE_OutputCDR::wchar_maxbytes_ == 2) ?
01164     ACE_CDR::SHORT_ALIGN :
01165     ACE_CDR::OCTET_ALIGN;
01166 
01167   if (this->adjust (ACE_OutputCDR::wchar_maxbytes_ * length, align, buf) == 0)
01168     {
01169       if (ACE_OutputCDR::wchar_maxbytes_ == 2)
01170         {
01171           ACE_CDR::UShort *sb = ACE_reinterpret_cast(ACE_CDR::UShort *, buf);
01172           for (size_t i = 0; i < length; i++)
01173 #if defined (ACE_DISABLE_SWAP_ON_READ)
01174             x[i] = ACE_static_cast (ACE_CDR::WChar, sb[i]);
01175 #else
01176           if (!this->do_byte_swap_)
01177             x[i] = ACE_static_cast (ACE_CDR::WChar, sb[i]);
01178           else
01179             {
01180               ACE_CDR::UShort sx;
01181               ACE_CDR::swap_2 (&buf[i*2], ACE_reinterpret_cast(char *,&sx));
01182               x[i] = ACE_static_cast (ACE_CDR::WChar,sx);
01183             }
01184 #endif /* ACE_DISABLE_SWAP_ON_READ */
01185         }
01186       else
01187         {
01188           for (size_t i = 0; i < length; i++)
01189             x[i] = ACE_static_cast (ACE_CDR::Octet, buf[i]);
01190         }
01191       return this->good_bit_;
01192     }
01193   return 0;
01194 }

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

Return 0 on failure and 1 on success.

Definition at line 1035 of file CDR_Stream.cpp.

References ACE_NEW_RETURN, good_bit_, length, read_ulong, read_wchar_array, ACE_WChar_Codeset_Translator::read_wstring, ACE_CDR::Short, ACE_CDR::ULong, ACE_CDR::WChar, ACE_OutputCDR::wchar_maxbytes_, and wchar_translator_.

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

01036 {
01037   // @@ This is a slight violation of "Optimize for the common case",
01038   // i.e. normally the translator will be 0, but OTOH the code is
01039   // smaller and should be better for the cache ;-) ;-)
01040   if (this->wchar_translator_ != 0)
01041     {
01042       this->good_bit_ = this->wchar_translator_->read_wstring (*this, x);
01043       return this->good_bit_;
01044     }
01045   if (ACE_OutputCDR::wchar_maxbytes_ == 0)
01046     {
01047       errno = EACCES;
01048       return (this->good_bit_ = 0);
01049     }
01050 
01051   ACE_CDR::ULong len;
01052   if (!this->read_ulong (len))
01053     return 0;
01054 
01055   // A check for the length being too great is done later in the
01056   // call to read_char_array but we want to have it done before
01057   // the memory is allocated.
01058   if (len > 0 && len <= this->length())
01059     {
01060 
01061       if (ACE_static_cast (ACE_CDR::Short, this->major_version_) == 1
01062           && ACE_static_cast (ACE_CDR::Short, this->minor_version_) == 2)
01063         {
01064           len /= ACE_OutputCDR::wchar_maxbytes_;
01065 
01066           //allocating one extra for the null character needed by applications
01067           ACE_NEW_RETURN (x,
01068                           ACE_CDR::WChar [len + 1],
01069                           0);
01070 
01071           if (this->read_wchar_array (x, len))
01072             {
01073 
01074               //Null character used by applications to find the end of
01075               //the wstring
01076               //Is this okay with the GIOP 1.2 spec??
01077               x[len] = '\x00';
01078 
01079               return 1;
01080             }
01081         }
01082       else
01083         {
01084           ACE_NEW_RETURN (x,
01085                           ACE_CDR::WChar [len],
01086                           0);
01087 
01088           if (this->read_wchar_array (x, len))
01089             return 1;
01090         }
01091 
01092       delete [] x;
01093     }
01094   else if (len == 0)
01095     {
01096       // Convert any null strings to empty strings since empty
01097       // strings can cause crashes. (See bug 58.)
01098       ACE_NEW_RETURN (x,
01099                       ACE_CDR::WChar[1],
01100                       0);
01101       x[0] = '\x00';
01102       return 1;
01103     }
01104 
01105   this->good_bit_ = 0;
01106   x = 0;
01107   return 0;
01108 }

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

References byte_order, ACE_CDR::consolidate, and reset_byte_order.

Referenced by ACE_InputCDR.

01410 {
01411   this->reset_byte_order (byte_order);
01412   ACE_CDR::consolidate (&this->start_, data);
01413 }

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 change it.

Definition at line 1392 of file CDR_Stream.i.

References ACE_CDR_BYTE_ORDER, byte_order, and do_byte_swap_.

Referenced by reset.

01393 {
01394   this->do_byte_swap_ = (byte_order != ACE_CDR_BYTE_ORDER);
01395 }

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 1584 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.

01585 {
01586   this->start_.data_block (this->start_.data_block ()->clone_nocopy
01587                            ());
01588 
01589   // Reset the flags...
01590   this->start_.clr_self_flags (ACE_Message_Block::DONT_DELETE);
01591 }

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

Set the underlying GIOP version..

Definition at line 1429 of file CDR_Stream.i.

References major_version_, minor_version_, and ACE_CDR::Octet.

01431 {
01432   this->major_version_ = major;
01433   this->minor_version_ = minor;
01434   return 0;
01435 }

ACE_INLINE ACE_CDR::Boolean ACE_InputCDR::skip_boolean void   
 

Return 0 on failure and 1 on success.

Definition at line 875 of file CDR_Stream.i.

References good_bit_, ACE_CDR::Octet, and read_octet.

00876 {
00877   ACE_CDR::Octet tmp;
00878   this->read_octet (tmp);
00879   return (ACE_CDR::Boolean) this->good_bit_;
00880 }

ACE_CDR::Boolean ACE_InputCDR::skip_bytes size_t    n
 

Skip <n> bytes in the CDR stream. Return 0 on failure and 1 on success.

Definition at line 1385 of file CDR_Stream.cpp.

References good_bit_, rd_ptr, and wr_ptr.

Referenced by skip_wchar, and skip_wstring.

01386 {
01387   if (this->rd_ptr () + len <= this->wr_ptr ())
01388     {
01389       this->rd_ptr (len);
01390       return 1;
01391     }
01392   this->good_bit_ = 0;
01393   return 0;
01394 }

ACE_INLINE ACE_CDR::Boolean ACE_InputCDR::skip_char void   
 

Return 0 on failure and 1 on success.

Definition at line 861 of file CDR_Stream.i.

References ACE_CDR::Char, ACE_CDR::Octet, and read_1.

00862 {
00863   ACE_CDR::Char x;
00864   return this->read_1 (ACE_reinterpret_cast (ACE_CDR::Octet*,&x));
00865 }

ACE_INLINE ACE_CDR::Boolean ACE_InputCDR::skip_double void   
 

Return 0 on failure and 1 on success.

Definition at line 934 of file CDR_Stream.i.

References read_8, and ACE_CDR::ULongLong.

00935 {
00936   double x;
00937   return this->read_8 (ACE_reinterpret_cast (ACE_CDR::ULongLong*,&x));
00938 }

ACE_INLINE ACE_CDR::Boolean ACE_InputCDR::skip_float void   
 

Return 0 on failure and 1 on success.

Definition at line 925 of file CDR_Stream.i.

References read_4, and ACE_CDR::ULong.

00926 {
00927   // Changing this removes the warning for GHS and it
00928   // stops the compiler from getting an internal error.
00929   ACE_CDR::ULong value;
00930   return this->read_4 (&value);
00931 }

ACE_INLINE ACE_CDR::Boolean ACE_InputCDR::skip_long void   
 

Return 0 on failure and 1 on success.

Definition at line 897 of file CDR_Stream.i.

References ACE_CDR::Long, read_4, and ACE_CDR::ULong.

00898 {
00899   ACE_CDR::Long x;
00900   return this->read_4 (ACE_reinterpret_cast (ACE_CDR::ULong*,&x));
00901 }

ACE_INLINE ACE_CDR::Boolean ACE_InputCDR::skip_longdouble void   
 

Return 0 on failure and 1 on success.

Definition at line 941 of file CDR_Stream.i.

References read_16.

00942 {
00943   ACE_CDR::LongDouble x;
00944   return this->read_16 (ACE_reinterpret_cast (ACE_CDR::LongDouble*,&x));
00945 }

ACE_INLINE ACE_CDR::Boolean ACE_InputCDR::skip_longlong void   
 

Return 0 on failure and 1 on success.

Definition at line 911 of file CDR_Stream.i.

References ACE_CDR::LongLong, read_8, and ACE_CDR::ULongLong.

00912 {
00913   ACE_CDR::LongLong x;
00914   return this->read_8 (ACE_reinterpret_cast (ACE_CDR::ULongLong*,&x));
00915 }

ACE_INLINE ACE_CDR::Boolean ACE_InputCDR::skip_octet void   
 

Return 0 on failure and 1 on success.

Definition at line 868 of file CDR_Stream.i.

References ACE_CDR::Octet, and read_1.

00869 {
00870   ACE_CDR::Octet x;
00871   return this->read_1 (&x);
00872 }

ACE_INLINE ACE_CDR::Boolean ACE_InputCDR::skip_short void   
 

Return 0 on failure and 1 on success.

Definition at line 883 of file CDR_Stream.i.

References read_2, ACE_CDR::Short, and ACE_CDR::UShort.

00884 {
00885   ACE_CDR::Short x;
00886   return this->read_2 (ACE_reinterpret_cast (ACE_CDR::UShort*,&x));
00887 }

ACE_CDR::Boolean ACE_InputCDR::skip_string void   
 

Definition at line 1349 of file CDR_Stream.cpp.

References good_bit_, rd_ptr, read_ulong, ACE_CDR::ULong, and wr_ptr.

01350 {
01351   ACE_CDR::ULong len;
01352   if (this->read_ulong (len))
01353     {
01354       if (this->rd_ptr () + len <= this->wr_ptr ())
01355         {
01356           this->rd_ptr (len);
01357           return 1;
01358         }
01359       this->good_bit_ = 0;
01360     }
01361   return 0;
01362 }

ACE_INLINE ACE_CDR::Boolean ACE_InputCDR::skip_ulong void   
 

Return 0 on failure and 1 on success.

Definition at line 904 of file CDR_Stream.i.

References read_4, and ACE_CDR::ULong.

00905 {
00906   ACE_CDR::ULong x;
00907   return this->read_4 (ACE_reinterpret_cast (ACE_CDR::ULong*,&x));
00908 }

ACE_INLINE ACE_CDR::Boolean ACE_InputCDR::skip_ulonglong void   
 

Return 0 on failure and 1 on success.

Definition at line 918 of file CDR_Stream.i.

References read_8, and ACE_CDR::ULongLong.

00919 {
00920   ACE_CDR::ULongLong x;
00921   return this->read_8 (ACE_reinterpret_cast (ACE_CDR::ULongLong*,&x));
00922 }

ACE_INLINE ACE_CDR::Boolean ACE_InputCDR::skip_ushort void   
 

Return 0 on failure and 1 on success.

Definition at line 890 of file CDR_Stream.i.

References read_2, and ACE_CDR::UShort.

00891 {
00892   ACE_CDR::UShort x;
00893   return this->read_2 (ACE_reinterpret_cast (ACE_CDR::UShort*,&x));
00894 }

ACE_CDR::Boolean ACE_InputCDR::skip_wchar void   
 

Return 0 on failure and 1 on success.

Definition at line 864 of file CDR_Stream.cpp.

References good_bit_, major_version_, minor_version_, ACE_CDR::Octet, read_1, read_2, read_4, ACE_CDR::Short, skip_bytes, ACE_CDR::ULong, ACE_CDR::UShort, and ACE_CDR::WChar.

Referenced by skip_wstring.

00865 {
00866   if (ACE_static_cast (ACE_CDR::Short, major_version_) == 1
00867       && ACE_static_cast (ACE_CDR::Short, minor_version_) == 2)
00868     {
00869       ACE_CDR::Octet len;
00870       if (this->read_1 (&len))
00871         return this->skip_bytes (ACE_static_cast (size_t, len));
00872     }
00873   else
00874     {
00875       ACE_CDR::WChar x;
00876       if (sizeof (ACE_CDR::WChar) == 2)
00877         return this->read_2 (ACE_reinterpret_cast (ACE_CDR::UShort *,&x));
00878       else
00879         return this->read_4 (ACE_reinterpret_cast (ACE_CDR::ULong *,&x));
00880     }
00881 
00882   return (this->good_bit_ = 0);
00883 }

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. Return 0 on failure and 1 on success.

Definition at line 1365 of file CDR_Stream.cpp.

References ACE_CDR::Boolean, read_ulong, ACE_CDR::Short, skip_bytes, skip_wchar, and ACE_CDR::ULong.

01366 {
01367   ACE_CDR::Boolean continue_skipping = 1;
01368   ACE_CDR::ULong len;
01369 
01370   continue_skipping = read_ulong (len);
01371 
01372   if (continue_skipping != 0 && len != 0)
01373     {
01374       if (ACE_static_cast (ACE_CDR::Short, this->major_version_) == 1
01375           && ACE_static_cast (ACE_CDR::Short, this->minor_version_) == 2)
01376         continue_skipping = this->skip_bytes ((size_t)len);
01377       else
01378         while (continue_skipping != 0 && len--)
01379           continue_skipping = this->skip_wchar ();
01380     }
01381   return continue_skipping;
01382 }

ACE_INLINE const ACE_Message_Block * ACE_InputCDR::start void    const
 

Return 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 996 of file CDR_Stream.i.

References start_.

00997 {
00998   return &this->start_;
00999 }

ACE_Message_Block * ACE_InputCDR::steal_contents void   
 

Steal the contents from the current CDR.

Definition at line 1568 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_.

01569 {
01570   ACE_Message_Block* block =
01571     this->start_.clone ();
01572   this->start_.data_block (block->data_block ()->clone ());
01573 
01574   // If at all our message had a DONT_DELETE flag set, just clear it
01575   // off.
01576   this->start_.clr_self_flags (ACE_Message_Block::DONT_DELETE);
01577 
01578   ACE_CDR::mb_align (&this->start_);
01579 
01580   return block;
01581 }

void ACE_InputCDR::steal_from ACE_InputCDR &    cdr
 

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

Definition at line 1416 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.

01417 {
01418   this->do_byte_swap_ = cdr.do_byte_swap_;
01419   this->start_.data_block (cdr.start_.data_block ()->duplicate ());
01420 
01421   // If the message block had a DONT_DELETE flags, just clear it off..
01422   this->start_.clr_self_flags (ACE_Message_Block::DONT_DELETE);
01423   this->start_.rd_ptr (cdr.start_.rd_ptr ());
01424 
01425   this->start_.wr_ptr (cdr.start_.wr_ptr ());
01426   this->major_version_ = cdr.major_version_;
01427   this->minor_version_ = cdr.minor_version_;
01428   cdr.reset_contents ();
01429 }

ACE_INLINE void ACE_InputCDR::wchar_translator ACE_WChar_Codeset_Translator  
 

Definition at line 1466 of file CDR_Stream.i.

References wchar_translator_.

01467 {
01468   this->wchar_translator_ = wctran;
01469 }

ACE_INLINE ACE_WChar_Codeset_Translator * ACE_InputCDR::wchar_translator void    const
 

Definition at line 1453 of file CDR_Stream.i.

References wchar_translator_.

01454 {
01455   return this->wchar_translator_;
01456 }

ACE_INLINE char * ACE_InputCDR::wr_ptr void   
 

Returns the current position for the wr_ptr....

Definition at line 966 of file CDR_Stream.i.

References start_, and ACE_Message_Block::wr_ptr.

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

00967 {
00968   return this->start_.wr_ptr ();
00969 }


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

friend class ACE_WChar_Codeset_Translator [friend]
 

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

Referenced by char_translator, operator=, read_char, read_char_array, and read_string.

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

Referenced by ACE_InputCDR, clone_from, do_byte_swap, exchange_data_blocks, operator=, read_16, read_2, read_4, read_8, read_array, read_wchar_array_i, reset_byte_order, and steal_from.

int ACE_InputCDR::good_bit_ [protected]
 

set to 0 when an error occurs.

Definition at line 879 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_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, read_wchar_array, read_wchar_array_i, read_wstring, skip_boolean, skip_bytes, skip_string, and skip_wchar.

ACE_CDR::Octet ACE_InputCDR::major_version_ [protected]
 

The GIOP versions for this stream.

Definition at line 882 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 883 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 872 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 887 of file CDR_Stream.h.

Referenced by read_wchar, read_wchar_array, read_wstring, and wchar_translator.


The documentation for this class was generated from the following files:
Generated on Mon Jun 16 12:49:04 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002