ACE_OutputCDR Class Reference

A CDR stream for writing, i.e. for marshalling. More...

#include <CDR_Stream.h>

Collaboration diagram for ACE_OutputCDR:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 ACE_OutputCDR (size_t size=0, int byte_order=ACE_CDR_BYTE_ORDER, ACE_Allocator *buffer_allocator=0, ACE_Allocator *data_block_allocator=0, ACE_Allocator *message_block_allocator=0, size_t memcpy_tradeoff=ACE_DEFAULT_CDR_MEMCPY_TRADEOFF, ACE_CDR::Octet major_version=ACE_CDR_GIOP_MAJOR_VERSION, ACE_CDR::Octet minor_version=ACE_CDR_GIOP_MINOR_VERSION)
 ACE_OutputCDR (char *data, size_t size, int byte_order=ACE_CDR_BYTE_ORDER, ACE_Allocator *buffer_allocator=0, ACE_Allocator *data_block_allocator=0, ACE_Allocator *message_block_allocator=0, size_t memcpy_tradeoff=ACE_DEFAULT_CDR_MEMCPY_TRADEOFF, ACE_CDR::Octet giop_major_version=ACE_CDR_GIOP_MAJOR_VERSION, ACE_CDR::Octet giop_minor_version=ACE_CDR_GIOP_MINOR_VERSION)
 ACE_OutputCDR (ACE_Data_Block *data_block, int byte_order=ACE_CDR_BYTE_ORDER, ACE_Allocator *message_block_allocator=0, size_t memcpy_tradeoff=ACE_DEFAULT_CDR_MEMCPY_TRADEOFF, ACE_CDR::Octet giop_major_version=ACE_CDR_GIOP_MAJOR_VERSION, ACE_CDR::Octet giop_minor_version=ACE_CDR_GIOP_MINOR_VERSION)
 ACE_OutputCDR (ACE_Message_Block *data, int byte_order=ACE_CDR_BYTE_ORDER, size_t memcpy_tradeoff=ACE_DEFAULT_CDR_MEMCPY_TRADEOFF, ACE_CDR::Octet giop_major_version=ACE_CDR_GIOP_MAJOR_VERSION, ACE_CDR::Octet giop_minor_version=ACE_CDR_GIOP_MINOR_VERSION)
 ~ACE_OutputCDR (void)
 destructor
bool good_bit (void) const
 Returns false if an error has ocurred.
void reset (void)
 Reuse the CDR stream to write on the old buffer.
size_t total_length (void) const
 Add the length of each message block in the chain.
const ACE_Message_Blockbegin (void) const
const ACE_Message_Blockend (void) const
 Return the last message in the chain that is is use.
const ACE_Message_Blockcurrent (void) const
 Return the <current_> message block in chain.
int consolidate (void)
 Replace the message block chain with a single message block.
const char * buffer (void) const
size_t length (void) const
int align_write_ptr (size_t alignment)
ACE_Char_Codeset_Translatorchar_translator (void) const
 Access the codeset translators. They can be null!
ACE_WChar_Codeset_Translatorwchar_translator (void) const
void char_translator (ACE_Char_Codeset_Translator *)
 Set the char codeset translator.
void wchar_translator (ACE_WChar_Codeset_Translator *)
 Set the wchar codeset translator.
size_t current_alignment (void) const
int adjust (size_t size, char *&buf)
int adjust (size_t size, size_t align, char *&buf)
bool do_byte_swap (void) const
int byte_order (void) const
void reset_byte_order (int byte_order)
void set_version (ACE_CDR::Octet major, ACE_CDR::Octet minor)
 set GIOP version info
void get_version (ACE_CDR::Octet &major, ACE_CDR::Octet &minor)
 Set the underlying GIOP version..
Write operations
Return 0 on failure and 1 on success.

ACE_CDR::Boolean write_boolean (ACE_CDR::Boolean x)
ACE_CDR::Boolean write_char (ACE_CDR::Char x)
ACE_CDR::Boolean write_wchar (ACE_CDR::WChar x)
ACE_CDR::Boolean write_octet (ACE_CDR::Octet x)
ACE_CDR::Boolean write_short (ACE_CDR::Short x)
ACE_CDR::Boolean write_ushort (ACE_CDR::UShort x)
ACE_CDR::Boolean write_long (ACE_CDR::Long x)
ACE_CDR::Boolean write_ulong (ACE_CDR::ULong x)
ACE_CDR::Boolean write_longlong (const ACE_CDR::LongLong &x)
ACE_CDR::Boolean write_ulonglong (const ACE_CDR::ULongLong &x)
ACE_CDR::Boolean write_float (ACE_CDR::Float x)
ACE_CDR::Boolean write_double (const ACE_CDR::Double &x)
ACE_CDR::Boolean write_longdouble (const ACE_CDR::LongDouble &x)
ACE_CDR::Boolean write_string (const ACE_CDR::Char *x)
 For string we offer methods that accept a precomputed length.
ACE_CDR::Boolean write_string (ACE_CDR::ULong len, const ACE_CDR::Char *x)
ACE_CDR::Boolean write_string (const ACE_CString &x)
ACE_CDR::Boolean write_wstring (const ACE_CDR::WChar *x)
ACE_CDR::Boolean write_wstring (ACE_CDR::ULong length, const ACE_CDR::WChar *x)
ACE_CDR::Boolean write_boolean_array (const ACE_CDR::Boolean *x, ACE_CDR::ULong length)
ACE_CDR::Boolean write_char_array (const ACE_CDR::Char *x, ACE_CDR::ULong length)
ACE_CDR::Boolean write_wchar_array (const ACE_CDR::WChar *x, ACE_CDR::ULong length)
ACE_CDR::Boolean write_octet_array (const ACE_CDR::Octet *x, ACE_CDR::ULong length)
ACE_CDR::Boolean write_short_array (const ACE_CDR::Short *x, ACE_CDR::ULong length)
ACE_CDR::Boolean write_ushort_array (const ACE_CDR::UShort *x, ACE_CDR::ULong length)
ACE_CDR::Boolean write_long_array (const ACE_CDR::Long *x, ACE_CDR::ULong length)
ACE_CDR::Boolean write_ulong_array (const ACE_CDR::ULong *x, ACE_CDR::ULong length)
ACE_CDR::Boolean write_longlong_array (const ACE_CDR::LongLong *x, ACE_CDR::ULong length)
ACE_CDR::Boolean write_ulonglong_array (const ACE_CDR::ULongLong *x, ACE_CDR::ULong length)
ACE_CDR::Boolean write_float_array (const ACE_CDR::Float *x, ACE_CDR::ULong length)
ACE_CDR::Boolean write_double_array (const ACE_CDR::Double *x, ACE_CDR::ULong length)
ACE_CDR::Boolean write_longdouble_array (const ACE_CDR::LongDouble *x, ACE_CDR::ULong length)
ACE_CDR::Boolean write_octet_array_mb (const ACE_Message_Block *mb)
Placeholder/replace operations
Facilitates writing a placeholder into a CDR stream to be replaced later with a different value.

Note:
An example use for this facility is:
        ACE_OutputCDR strm;
        ...   // insert values...
        char *pos = strm.write_long_placeholder ();
        ...   // insert more values
        ACE_CDR::Long real_val;       // Somehow assign the "correct" value
        strm.replace (real_val, pos); // Replace earlier placeholder


char * write_long_placeholder (void)
char * write_short_placeholder (void)
ACE_CDR::Boolean replace (ACE_CDR::Long x, char *loc)
ACE_CDR::Boolean replace (ACE_CDR::Short x, char *loc)
ACE_CDR::Boolean append_boolean (ACE_InputCDR &)
ACE_CDR::Boolean append_char (ACE_InputCDR &)
ACE_CDR::Boolean append_wchar (ACE_InputCDR &)
ACE_CDR::Boolean append_octet (ACE_InputCDR &)
ACE_CDR::Boolean append_short (ACE_InputCDR &)
ACE_CDR::Boolean append_ushort (ACE_InputCDR &)
ACE_CDR::Boolean append_long (ACE_InputCDR &)
ACE_CDR::Boolean append_ulong (ACE_InputCDR &)
ACE_CDR::Boolean append_longlong (ACE_InputCDR &)
ACE_CDR::Boolean append_ulonglong (ACE_InputCDR &)
ACE_CDR::Boolean append_float (ACE_InputCDR &)
ACE_CDR::Boolean append_double (ACE_InputCDR &)
ACE_CDR::Boolean append_longdouble (ACE_InputCDR &)
ACE_CDR::Boolean append_wstring (ACE_InputCDR &)
ACE_CDR::Boolean append_string (ACE_InputCDR &)

Static Public Member Functions

static void wchar_maxbytes (size_t max_bytes)
static size_t wchar_maxbytes (void)
 access the serialized size of wchars.

Protected Attributes

ACE_CDR::Octet major_version_
 GIOP version information.
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_

Static Protected Attributes

static size_t wchar_maxbytes_ = sizeof (ACE_CDR::WChar)

Private Member Functions

ACE_Message_Blockfind (char *loc)
 ACE_OutputCDR (const ACE_OutputCDR &rhs)
 disallow copying...
ACE_OutputCDRoperator= (const ACE_OutputCDR &rhs)
ACE_CDR::Boolean write_1 (const ACE_CDR::Octet *x)
ACE_CDR::Boolean write_2 (const ACE_CDR::UShort *x)
ACE_CDR::Boolean write_4 (const ACE_CDR::ULong *x)
ACE_CDR::Boolean write_8 (const ACE_CDR::ULongLong *x)
ACE_CDR::Boolean write_16 (const ACE_CDR::LongDouble *x)
ACE_CDR::Boolean write_array (const void *x, size_t size, size_t align, ACE_CDR::ULong length)
ACE_CDR::Boolean write_wchar_array_i (const ACE_CDR::WChar *x, ACE_CDR::ULong length)
int grow_and_adjust (size_t size, size_t align, char *&buf)

Private Attributes

ACE_Message_Block start_
 The start of the chain of message blocks.
ACE_Message_Blockcurrent_
 The current block in the chain where we are writing.
size_t current_alignment_
bool current_is_writable_
bool do_byte_swap_
bool good_bit_
 Set to false when an error ocurrs.
size_t const memcpy_tradeoff_
 Break-even point for copying.

Friends

class ACE_Char_Codeset_Translator
class ACE_WChar_Codeset_Translator
class ACE_InputCDR

Classes

struct  from_boolean
struct  from_char
struct  from_octet
struct  from_string
struct  from_wchar
struct  from_wstring

Detailed Description

A CDR stream for writing, i.e. for marshalling.

This class is based on the the CORBA spec for Java (98-02-29), java class omg.org.CORBA.portable.OutputStream. It diverts in a few ways: + 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 98 of file CDR_Stream.h.


Constructor & Destructor Documentation

ACE_OutputCDR::ACE_OutputCDR ( size_t  size = 0,
int  byte_order = ACE_CDR_BYTE_ORDER,
ACE_Allocator buffer_allocator = 0,
ACE_Allocator data_block_allocator = 0,
ACE_Allocator message_block_allocator = 0,
size_t  memcpy_tradeoff = ACE_DEFAULT_CDR_MEMCPY_TRADEOFF,
ACE_CDR::Octet  major_version = ACE_CDR_GIOP_MAJOR_VERSION,
ACE_CDR::Octet  minor_version = ACE_CDR_GIOP_MINOR_VERSION 
)

Default constructor, allocates size bytes in the internal buffer, if size == 0 it allocates the default size.

Definition at line 23 of file CDR_Stream.cpp.

References ACE_NEW, and ACE_CDR::mb_align().

00031   :  start_ ((size ? size : (size_t) ACE_CDR::DEFAULT_BUFSIZE) + ACE_CDR::MAX_ALIGNMENT,
00032              ACE_Message_Block::MB_DATA,
00033              0,
00034              0,
00035              buffer_allocator,
00036              0,
00037              0,
00038              ACE_Time_Value::zero,
00039              ACE_Time_Value::max_time,
00040              data_block_allocator,
00041              message_block_allocator),
00042 #if !defined (ACE_LACKS_CDR_ALIGNMENT)
00043      current_alignment_ (0),
00044 #endif /* ACE_LACKS_CDR_ALIGNMENT */
00045      current_is_writable_ (true),
00046      do_byte_swap_ (byte_order != ACE_CDR_BYTE_ORDER),
00047      good_bit_ (true),
00048      memcpy_tradeoff_ (memcpy_tradeoff),
00049      major_version_ (major_version),
00050      minor_version_ (minor_version),
00051      char_translator_ (0),
00052      wchar_translator_ (0)
00053 
00054 {
00055   ACE_CDR::mb_align (&this->start_);
00056   this->current_ = &this->start_;
00057 
00058 #if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1)
00059   ACE_NEW (this->monitor_,
00060            ACE::Monitor_Control::Size_Monitor);
00061   this->monitor_->receive (this->total_length ());
00062 #endif /* ACE_HAS_MONITOR_POINTS==1 */
00063 }

ACE_OutputCDR::ACE_OutputCDR ( char *  data,
size_t  size,
int  byte_order = ACE_CDR_BYTE_ORDER,
ACE_Allocator buffer_allocator = 0,
ACE_Allocator data_block_allocator = 0,
ACE_Allocator message_block_allocator = 0,
size_t  memcpy_tradeoff = ACE_DEFAULT_CDR_MEMCPY_TRADEOFF,
ACE_CDR::Octet  giop_major_version = ACE_CDR_GIOP_MAJOR_VERSION,
ACE_CDR::Octet  giop_minor_version = ACE_CDR_GIOP_MINOR_VERSION 
)

Create an output stream from an arbitrary buffer, care must be exercised with alignment, because this contructor will align if needed. In this case data will not point to the start of the output stream. begin()->rd_ptr() points to the start of the output stream. See ACE_ptr_align_binary() to properly align a pointer and use ACE_CDR::MAX_ALIGNMENT for the correct alignment.

Definition at line 65 of file CDR_Stream.cpp.

References ACE_NEW, current_, ACE_CDR::mb_align(), and start_.

00074   :  start_ (size,
00075              ACE_Message_Block::MB_DATA,
00076              0,
00077              data,
00078              buffer_allocator,
00079              0,
00080              0,
00081              ACE_Time_Value::zero,
00082              ACE_Time_Value::max_time,
00083              data_block_allocator,
00084              message_block_allocator),
00085 #if !defined (ACE_LACKS_CDR_ALIGNMENT)
00086      current_alignment_ (0),
00087 #endif /* ACE_LACKS_CDR_ALIGNMENT */
00088      current_is_writable_ (true),
00089      do_byte_swap_ (byte_order != ACE_CDR_BYTE_ORDER),
00090      good_bit_ (true),
00091      memcpy_tradeoff_ (memcpy_tradeoff),
00092      major_version_ (major_version),
00093      minor_version_ (minor_version),
00094      char_translator_ (0),
00095      wchar_translator_ (0)
00096 {
00097   // We cannot trust the buffer to be properly aligned
00098   ACE_CDR::mb_align (&this->start_);
00099   this->current_ = &this->start_;
00100 
00101 #if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1)
00102   ACE_NEW (this->monitor_,
00103            ACE::Monitor_Control::Size_Monitor);
00104   this->monitor_->receive (this->total_length ());
00105 #endif /* ACE_HAS_MONITOR_POINTS==1 */
00106 }

ACE_OutputCDR::ACE_OutputCDR ( ACE_Data_Block data_block,
int  byte_order = ACE_CDR_BYTE_ORDER,
ACE_Allocator message_block_allocator = 0,
size_t  memcpy_tradeoff = ACE_DEFAULT_CDR_MEMCPY_TRADEOFF,
ACE_CDR::Octet  giop_major_version = ACE_CDR_GIOP_MAJOR_VERSION,
ACE_CDR::Octet  giop_minor_version = ACE_CDR_GIOP_MINOR_VERSION 
)

Create an output stream from an arbitrary data block, care must be exercised with alignment, because this contructor will align if needed. In this case data_block will not point to the start of the output stream. begin()->rd_ptr() points to the start off the output stream. See ACE_ptr_align_binary() to properly align a pointer and use ACE_CDR::MAX_ALIGNMENT for the correct alignment.

Definition at line 108 of file CDR_Stream.cpp.

References ACE_NEW, current_, ACE_CDR::mb_align(), and start_.

00114   :  start_ (data_block,
00115              ACE_Message_Block::DONT_DELETE,
00116              message_block_allocator),
00117 #if !defined (ACE_LACKS_CDR_ALIGNMENT)
00118      current_alignment_ (0),
00119 #endif /* ACE_LACKS_CDR_ALIGNMENT */
00120      current_is_writable_ (true),
00121      do_byte_swap_ (byte_order != ACE_CDR_BYTE_ORDER),
00122      good_bit_ (true),
00123      memcpy_tradeoff_ (memcpy_tradeoff),
00124      major_version_ (major_version),
00125      minor_version_ (minor_version),
00126      char_translator_ (0),
00127      wchar_translator_ (0)
00128 {
00129   // We cannot trust the buffer to be properly aligned
00130   ACE_CDR::mb_align (&this->start_);
00131   this->current_ = &this->start_;
00132 
00133 #if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1)
00134   ACE_NEW (this->monitor_,
00135            ACE::Monitor_Control::Size_Monitor);
00136   this->monitor_->receive (this->total_length ());
00137 #endif /* ACE_HAS_MONITOR_POINTS==1 */
00138 }

ACE_OutputCDR::ACE_OutputCDR ( ACE_Message_Block data,
int  byte_order = ACE_CDR_BYTE_ORDER,
size_t  memcpy_tradeoff = ACE_DEFAULT_CDR_MEMCPY_TRADEOFF,
ACE_CDR::Octet  giop_major_version = ACE_CDR_GIOP_MAJOR_VERSION,
ACE_CDR::Octet  giop_minor_version = ACE_CDR_GIOP_MINOR_VERSION 
)

Build a CDR stream with an initial Message_Block chain, it will not* remove data, since it did not allocate it.

Definition at line 140 of file CDR_Stream.cpp.

References ACE_NEW, current_, ACE_CDR::mb_align(), and start_.

00145   :  start_ (data->data_block ()->duplicate ()),
00146 #if !defined (ACE_LACKS_CDR_ALIGNMENT)
00147      current_alignment_ (0),
00148 #endif /* ACE_LACKS_CDR_ALIGNMENT */
00149      current_is_writable_ (true),
00150      do_byte_swap_ (byte_order != ACE_CDR_BYTE_ORDER),
00151      good_bit_ (true),
00152      memcpy_tradeoff_ (memcpy_tradeoff),
00153      major_version_ (major_version),
00154      minor_version_ (minor_version),
00155      char_translator_ (0),
00156      wchar_translator_ (0)
00157 {
00158   // We cannot trust the buffer to be properly aligned
00159   ACE_CDR::mb_align (&this->start_);
00160   this->current_ = &this->start_;
00161 
00162 #if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1)
00163   ACE_NEW (this->monitor_,
00164            ACE::Monitor_Control::Size_Monitor);
00165   this->monitor_->receive (this->total_length ());
00166 #endif /* ACE_HAS_MONITOR_POINTS==1 */
00167 }

ACE_INLINE ACE_OutputCDR::~ACE_OutputCDR ( void   ) 

destructor

Definition at line 142 of file CDR_Stream.inl.

References ACE_Message_Block::cont(), current_, ACE_Message_Block::release(), and start_.

00143 {
00144   if (this->start_.cont () != 0)
00145     {
00146       ACE_Message_Block::release (this->start_.cont ());
00147       this->start_.cont (0);
00148     }
00149 
00150   this->current_ = 0;
00151 
00152 #if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1)
00153   this->monitor_->remove_ref ();
00154 #endif /* ACE_HAS_MONITOR_POINTS==1 */
00155 }

ACE_OutputCDR::ACE_OutputCDR ( const ACE_OutputCDR rhs  )  [private]

disallow copying...


Member Function Documentation

ACE_INLINE int ACE_OutputCDR::adjust ( size_t  size,
size_t  align,
char *&  buf 
)

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

Definition at line 442 of file CDR_Stream.inl.

References ACE_align_binary(), current_, current_alignment_, ACE_Message_Block::end(), end(), grow_and_adjust(), and ACE_Message_Block::wr_ptr().

00445 {
00446   if (!this->current_is_writable_)
00447     return this->grow_and_adjust (size, align, buf);
00448 
00449 #if !defined (ACE_LACKS_CDR_ALIGNMENT)
00450   size_t const offset =
00451     ACE_align_binary (this->current_alignment_, align)
00452     - this->current_alignment_;
00453 
00454   buf = this->current_->wr_ptr () + offset;
00455 #else
00456   buf = this->current_->wr_ptr ();
00457 #endif /* ACE_LACKS_CDR_ALIGNMENT */
00458 
00459   char * const end = buf + size;
00460 
00461   if (end <= this->current_->end () &&
00462       end >= buf)
00463     {
00464 #if !defined (ACE_LACKS_CDR_ALIGNMENT)
00465       this->current_alignment_ += offset + size;
00466 #endif /* ACE_LACKS_CDR_ALIGNMENT */
00467       this->current_->wr_ptr (end);
00468 
00469 #if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1)
00470       this->monitor_->receive (this->total_length ());
00471 #endif /* ACE_HAS_MONITOR_POINTS==1 */
00472 
00473       return 0;
00474     }
00475 
00476   return this->grow_and_adjust (size, align, buf);
00477 }

ACE_INLINE int ACE_OutputCDR::adjust ( size_t  size,
char *&  buf 
)

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

Definition at line 480 of file CDR_Stream.inl.

Referenced by ACE_WChar_Codeset_Translator::adjust(), ACE_Char_Codeset_Translator::adjust(), align_write_ptr(), and grow_and_adjust().

00481 {
00482   return this->adjust (size, size, buf);
00483 }

ACE_INLINE int ACE_OutputCDR::align_write_ptr ( size_t  alignment  ) 

Utility function to allow the user more flexibility. Pads the stream 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 569 of file CDR_Stream.inl.

References adjust().

00570 {
00571 #if !defined (ACE_LACKS_CDR_ALIGNMENT)
00572   char *dummy;
00573   return this->adjust (0, alignment, dummy);
00574 #else
00575   ACE_UNUSED_ARG (alignment);
00576   // A return value of -1 from this function is used
00577   // to indicate failure, returning 0
00578   return 0;
00579 #endif /* ACE_LACKS_CDR_ALIGNMENT */
00580 }

ACE_INLINE ACE_CDR::Boolean ACE_OutputCDR::append_boolean ( ACE_InputCDR  ) 

Return 0 on failure and 1 on success.

Definition at line 1352 of file CDR_Stream.inl.

References ACE_InputCDR::read_boolean(), and write_boolean().

01353 {
01354   ACE_CDR::Boolean x;
01355   return stream.read_boolean (x) ? this->write_boolean (x) : false;
01356 }

ACE_INLINE ACE_CDR::Boolean ACE_OutputCDR::append_char ( ACE_InputCDR  ) 

Return 0 on failure and 1 on success.

Definition at line 1359 of file CDR_Stream.inl.

References ACE_InputCDR::read_char(), and write_char().

01360 {
01361   ACE_CDR::Char x;
01362   return stream.read_char (x) ? this->write_char (x) : false;
01363 }

ACE_INLINE ACE_CDR::Boolean ACE_OutputCDR::append_double ( ACE_InputCDR  ) 

Return 0 on failure and 1 on success.

Definition at line 1429 of file CDR_Stream.inl.

References ACE_InputCDR::read_double(), and write_double().

01430 {
01431   ACE_CDR::Double x;
01432   return stream.read_double (x) ? this->write_double (x) : false;
01433 }

ACE_INLINE ACE_CDR::Boolean ACE_OutputCDR::append_float ( ACE_InputCDR  ) 

Return 0 on failure and 1 on success.

Definition at line 1422 of file CDR_Stream.inl.

References ACE_InputCDR::read_float(), and write_float().

01423 {
01424   ACE_CDR::Float x;
01425   return stream.read_float (x) ? this->write_float (x) : false;
01426 }

ACE_INLINE ACE_CDR::Boolean ACE_OutputCDR::append_long ( ACE_InputCDR  ) 

Return 0 on failure and 1 on success.

Definition at line 1394 of file CDR_Stream.inl.

References ACE_InputCDR::read_long(), and write_long().

01395 {
01396   ACE_CDR::Long x;
01397   return stream.read_long (x) ? this->write_long (x) : false;
01398 }

ACE_INLINE ACE_CDR::Boolean ACE_OutputCDR::append_longdouble ( ACE_InputCDR  ) 

Return 0 on failure and 1 on success.

Definition at line 1436 of file CDR_Stream.inl.

References ACE_InputCDR::read_longdouble(), and write_longdouble().

01437 {
01438   ACE_CDR::LongDouble x;
01439   return stream.read_longdouble (x) ? this->write_longdouble (x) : false;
01440 }

ACE_INLINE ACE_CDR::Boolean ACE_OutputCDR::append_longlong ( ACE_InputCDR  ) 

Return 0 on failure and 1 on success.

Definition at line 1408 of file CDR_Stream.inl.

References ACE_InputCDR::read_longlong(), and write_longlong().

01409 {
01410   ACE_CDR::LongLong x;
01411   return stream.read_longlong (x) ? this->write_longlong (x) : false;
01412 }

ACE_INLINE ACE_CDR::Boolean ACE_OutputCDR::append_octet ( ACE_InputCDR  ) 

Return 0 on failure and 1 on success.

Definition at line 1373 of file CDR_Stream.inl.

References ACE_InputCDR::read_octet(), and write_octet().

01374 {
01375   ACE_CDR::Octet x;
01376   return stream.read_octet (x) ? this->write_octet (x) : false;
01377 }

ACE_INLINE ACE_CDR::Boolean ACE_OutputCDR::append_short ( ACE_InputCDR  ) 

Return 0 on failure and 1 on success.

Definition at line 1380 of file CDR_Stream.inl.

References ACE_InputCDR::read_short(), and write_short().

01381 {
01382   ACE_CDR::Short x;
01383   return stream.read_short (x) ? this->write_short (x) : false;
01384 }

ACE_INLINE ACE_CDR::Boolean ACE_OutputCDR::append_string ( ACE_InputCDR  ) 

Return 0 on failure and 1 on success.

Definition at line 1443 of file CDR_Stream.inl.

References ACE_InputCDR::read_string(), and write_string().

01444 {
01445   ACE_CDR::Char *x;
01446   const ACE_CDR::Boolean flag =
01447     (stream.read_string (x) ? this->write_string (x) : false);
01448   delete [] x;
01449   return flag;
01450 }

ACE_INLINE ACE_CDR::Boolean ACE_OutputCDR::append_ulong ( ACE_InputCDR  ) 

Return 0 on failure and 1 on success.

Definition at line 1401 of file CDR_Stream.inl.

References ACE_InputCDR::read_ulong(), and write_ulong().

01402 {
01403   ACE_CDR::ULong x;
01404   return stream.read_ulong (x) ? this->write_ulong (x) : false;
01405 }

ACE_INLINE ACE_CDR::Boolean ACE_OutputCDR::append_ulonglong ( ACE_InputCDR  ) 

Return 0 on failure and 1 on success.

Definition at line 1415 of file CDR_Stream.inl.

References ACE_InputCDR::read_ulonglong(), and write_ulonglong().

01416 {
01417   ACE_CDR::ULongLong x;
01418   return stream.read_ulonglong (x) ? this->write_ulonglong (x) : false;
01419 }

ACE_INLINE ACE_CDR::Boolean ACE_OutputCDR::append_ushort ( ACE_InputCDR  ) 

Return 0 on failure and 1 on success.

Definition at line 1387 of file CDR_Stream.inl.

References ACE_InputCDR::read_ushort(), and write_ushort().

01388 {
01389   ACE_CDR::UShort x;
01390   return stream.read_ushort (x) ? this->write_ushort (x) : false;
01391 }

ACE_INLINE ACE_CDR::Boolean ACE_OutputCDR::append_wchar ( ACE_InputCDR  ) 

Return 0 on failure and 1 on success.

Definition at line 1366 of file CDR_Stream.inl.

References ACE_InputCDR::read_wchar(), and write_wchar().

01367 {
01368   ACE_CDR::WChar x;
01369   return stream.read_wchar (x) ? this->write_wchar (x) : false;
01370 }

ACE_INLINE ACE_CDR::Boolean ACE_OutputCDR::append_wstring ( ACE_InputCDR  ) 

Return 0 on failure and 1 on success.

Definition at line 1453 of file CDR_Stream.inl.

References ACE_InputCDR::read_wstring(), and write_wstring().

01454 {
01455   ACE_CDR::WChar *x;
01456   const ACE_CDR::Boolean flag =
01457     (stream.read_wstring (x) ? this->write_wstring (x) : false);
01458   delete [] x;
01459   return flag;
01460 }

ACE_INLINE const ACE_Message_Block * ACE_OutputCDR::begin ( void   )  const

Return the start of the message block chain for this CDR stream.

Note:
The complete CDR stream is represented by a chain of message blocks.

Definition at line 501 of file CDR_Stream.inl.

References start_.

Referenced by ACE_InputCDR::ACE_InputCDR(), and ACE_Log_Msg_IPC::log().

00502 {
00503   return &this->start_;
00504 }

ACE_INLINE const char * ACE_OutputCDR::buffer ( void   )  const

Access the underlying buffer (read only).

Note:
This method only returns a pointer to the first block in the chain.

Definition at line 525 of file CDR_Stream.inl.

References ACE_Message_Block::rd_ptr(), and start_.

00526 {
00527   return this->start_.rd_ptr ();
00528 }

ACE_INLINE int ACE_OutputCDR::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 543 of file CDR_Stream.inl.

References ACE_CDR_BYTE_ORDER.

00544 {
00545   if (this->do_byte_swap ())
00546     return !ACE_CDR_BYTE_ORDER;
00547   else
00548     return ACE_CDR_BYTE_ORDER;
00549 }

ACE_INLINE void ACE_OutputCDR::char_translator ( ACE_Char_Codeset_Translator  ) 

Set the char codeset translator.

Definition at line 595 of file CDR_Stream.inl.

References char_translator_.

00596 {
00597   this->char_translator_ = ctran;
00598 }

ACE_INLINE ACE_Char_Codeset_Translator * ACE_OutputCDR::char_translator ( void   )  const

Access the codeset translators. They can be null!

Definition at line 583 of file CDR_Stream.inl.

References char_translator_.

00584 {
00585   return this->char_translator_;
00586 }

int ACE_OutputCDR::consolidate ( void   ) 

Replace the message block chain with a single message block.

Upon successful completion, there will be a single message block containing the data from the complete message block chain.

Note:
The only expected error is to run out of memory.

Definition at line 772 of file CDR_Stream.cpp.

References ACE_Message_Block::cont(), ACE_Message_Block::copy(), current_, current_is_writable_, ACE_CDR::first_size(), ACE_CDR::MAX_ALIGNMENT, ACE_Message_Block::release(), and start_.

00773 {
00774   // Optimize by only doing something if we need to
00775   if (this->current_ != &this->start_)
00776     {
00777       // Set the number of bytes in the top-level block, reallocating
00778       // if necessary.  The rd_ptr and wr_ptr remain at the original offsets
00779       // into the buffer, even if it is reallocated.
00780       // Return an error if the allocation failed.
00781       size_t const newsize =
00782         ACE_CDR::first_size (this->total_length ()
00783                              + ACE_CDR::MAX_ALIGNMENT);
00784       if (this->start_.size (newsize) < 0)
00785         {
00786           return -1;
00787         }
00788 
00789       // Consolidate the chain into the first block.  NOTE that
00790       // ACE_CDR::consolidate can not be used since we don't want to
00791       // overwrite what is already in the first block. We just append it since
00792       // the read and write pointers weren't affected by the resizing above.
00793       // We also don't have to worry about alignment since the start block is
00794       // already aligned.
00795       // NOTE also we know there is a continuation since we checked for it
00796       // above.  There is therefore no reason to check for a 0 continuation
00797       // field here.
00798       ACE_Message_Block *cont = this->start_.cont ();
00799       for (const ACE_Message_Block* i = cont; i != 0; i = i->cont ())
00800         {
00801           this->start_.copy (i->rd_ptr (), i->length ());
00802         }
00803 
00804       // Release the old blocks that were consolidated and reset the
00805       // current_ and current_is_writable_ to reflect the single used block.
00806       ACE_Message_Block::release (cont);
00807       this->start_.cont (0);
00808       this->current_ = &this->start_;
00809       this->current_is_writable_ = true;
00810     }
00811 
00812   return 0;
00813 }

ACE_INLINE const ACE_Message_Block * ACE_OutputCDR::current ( void   )  const

Return the <current_> message block in chain.

Definition at line 513 of file CDR_Stream.inl.

References current_.

00514 {
00515   return this->current_;
00516 }

ACE_INLINE size_t ACE_OutputCDR::current_alignment ( void   )  const

Return alignment of the wr_ptr(), with respect to the start of the CDR stream. This is not the same as the alignment of current->wr_ptr()!

Definition at line 558 of file CDR_Stream.inl.

References current_alignment_.

00559 {
00560 #if !defined (ACE_LACKS_CDR_ALIGNMENT)
00561   return this->current_alignment_;
00562 #else
00563   // Default value set to 0
00564   return 0;
00565 #endif /* ACE_LACKS_CDR_ALIGNMENT */
00566 }

ACE_INLINE bool ACE_OutputCDR::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 537 of file CDR_Stream.inl.

References do_byte_swap_.

00538 {
00539   return this->do_byte_swap_;
00540 }

ACE_INLINE const ACE_Message_Block * ACE_OutputCDR::end ( void   )  const

Return the last message in the chain that is is use.

Definition at line 507 of file CDR_Stream.inl.

References ACE_Message_Block::cont(), and current_.

Referenced by ACE_InputCDR::ACE_InputCDR(), adjust(), total_length(), and write_boolean_array().

00508 {
00509   return this->current_->cont ();
00510 }

ACE_Message_Block * ACE_OutputCDR::find ( char *  loc  )  [private]

Definition at line 817 of file CDR_Stream.cpp.

References ACE_Message_Block::cont(), and ACE_Message_Block::rd_ptr().

00818 {
00819   ACE_Message_Block* mb = 0;
00820   for (mb = &this->start_; mb != 0; mb = mb->cont ())
00821   {
00822     if (loc <= mb->wr_ptr () && loc >= mb->rd_ptr ())
00823     {
00824       break;
00825     }
00826   }
00827 
00828   return mb;
00829 }

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

Set the underlying GIOP version..

Definition at line 493 of file CDR_Stream.inl.

References major_version_, and minor_version_.

00494 {
00495   major = this->major_version_;
00496   minor = this->minor_version_;
00497 }

ACE_INLINE bool ACE_OutputCDR::good_bit ( void   )  const

Returns false if an error has ocurred.

Note:
The only expected error is to run out of memory.

Definition at line 436 of file CDR_Stream.inl.

References good_bit_.

Referenced by operator<<(), and write_boolean_array().

00437 {
00438   return this->good_bit_;
00439 }

int ACE_OutputCDR::grow_and_adjust ( size_t  size,
size_t  align,
char *&  buf 
) [private]

Grow the CDR stream. When it returns buf contains a pointer to memory in the CDR stream, with at least size bytes ahead of it and aligned to an <align> boundary. It moved the <wr_ptr> to <buf + size>.

Definition at line 182 of file CDR_Stream.cpp.

References ACE_NEW_RETURN, adjust(), ACE_Message_Block::cont(), current_, current_alignment_, current_is_writable_, ACE_Message_Block::data_block(), ACE_Data_Block::data_block_allocator(), good_bit_, ACE_CDR::MAX_ALIGNMENT, ACE_Time_Value::max_time, ACE_Message_Block::MB_DATA, ACE_CDR::next_size(), ACE_Message_Block::rd_ptr(), ACE_Message_Block::size(), ACE_Message_Block::wr_ptr(), and ACE_Time_Value::zero.

Referenced by adjust().

00185 {
00186   if (!this->current_is_writable_
00187       || this->current_->cont () == 0
00188       || this->current_->cont ()->size () < size + ACE_CDR::MAX_ALIGNMENT)
00189     {
00190       // Calculate the new buffer's length; if growing for encode, we
00191       // don't grow in "small" chunks because of the cost.
00192       size_t cursize = this->current_->size ();
00193       if (this->current_->cont () != 0)
00194         cursize = this->current_->cont ()->size ();
00195       size_t minsize = size;
00196 
00197 #if !defined (ACE_LACKS_CDR_ALIGNMENT)
00198       minsize += ACE_CDR::MAX_ALIGNMENT;
00199 #endif /* ACE_LACKS_CDR_ALIGNMENT */
00200 
00201       // Make sure that there is enough room for <minsize> bytes, but
00202       // also make it bigger than whatever our current size is.
00203       if (minsize < cursize)
00204         minsize = cursize;
00205 
00206       size_t const newsize = ACE_CDR::next_size (minsize);
00207 
00208       this->good_bit_ = false;
00209       ACE_Message_Block* tmp = 0;
00210       ACE_NEW_RETURN (tmp,
00211                       ACE_Message_Block (newsize,
00212                                          ACE_Message_Block::MB_DATA,
00213                                          0,
00214                                          0,
00215                                          this->current_->data_block ()->allocator_strategy (),
00216                                          0,
00217                                          0,
00218                                          ACE_Time_Value::zero,
00219                                          ACE_Time_Value::max_time,
00220                                          this->current_->data_block ()->data_block_allocator ()),
00221                       -1);
00222 
00223       // Message block initialization may fail while the construction
00224       // succeds.  Since as a matter of policy, ACE may throw no
00225       // exceptions, we have to do a separate check like this.
00226       if (tmp != 0 && tmp->size () < newsize)
00227         {
00228           delete tmp;
00229           errno = ENOMEM;
00230           return -1;
00231         }
00232 
00233       this->good_bit_ = true;
00234 
00235 #if !defined (ACE_LACKS_CDR_ALIGNMENT)
00236       // The new block must start with the same alignment as the
00237       // previous block finished.
00238       ptrdiff_t const tmpalign =
00239         reinterpret_cast<ptrdiff_t> (tmp->rd_ptr ()) % ACE_CDR::MAX_ALIGNMENT;
00240       ptrdiff_t const curalign =
00241         static_cast<ptrdiff_t> (this->current_alignment_) % ACE_CDR::MAX_ALIGNMENT;
00242       ptrdiff_t offset = curalign - tmpalign;
00243       if (offset < 0)
00244         offset += ACE_CDR::MAX_ALIGNMENT;
00245       tmp->rd_ptr (static_cast<size_t> (offset));
00246       tmp->wr_ptr (tmp->rd_ptr ());
00247 #endif /* ACE_LACKS_CDR_ALIGNMENT */
00248 
00249       // grow the chain and set the current block.
00250       tmp->cont (this->current_->cont ());
00251       this->current_->cont (tmp);
00252     }
00253   this->current_ = this->current_->cont ();
00254   this->current_is_writable_ = true;
00255 
00256   return this->adjust (size, align, buf);
00257 }

ACE_INLINE size_t ACE_OutputCDR::length ( void   )  const

Return the size of first message block in the block chain.

Note:
This method only returns information about the first block in the chain.

Definition at line 531 of file CDR_Stream.inl.

References ACE_Message_Block::length(), and start_.

Referenced by write_octet_array_mb().

00532 {
00533   return this->start_.length ();
00534 }

ACE_OutputCDR& ACE_OutputCDR::operator= ( const ACE_OutputCDR rhs  )  [private]

ACE_CDR::Boolean ACE_OutputCDR::replace ( ACE_CDR::Short  x,
char *  loc 
)

Write a placeholder into the stream. The placeholder's pointer is returned so it may later be passed as the loc argument to replace (). These methods align the stream's write pointer properly prior to writing the placeholder.

Return values:
Pointer to the placeholder; 0 if there is not enough space in the stream and memory could not be allocated.

Definition at line 749 of file CDR_Stream.cpp.

References ACE_CDR::swap_2().

00750 {
00751   if (this->find (loc) == 0)
00752     return false;
00753 
00754 #if !defined (ACE_ENABLE_SWAP_ON_WRITE)
00755   *reinterpret_cast<ACE_CDR::Short*> (loc) = x;
00756 #else
00757   if (!this->do_byte_swap_)
00758   {
00759     *reinterpret_cast<ACE_CDR::Short *> (loc) = x;
00760   }
00761   else
00762   {
00763     ACE_CDR::swap_2 (reinterpret_cast<const char*> (&x), loc);
00764   }
00765 #endif /* ACE_ENABLE_SWAP_ON_WRITE */
00766 
00767   return true;
00768 }

ACE_CDR::Boolean ACE_OutputCDR::replace ( ACE_CDR::Long  x,
char *  loc 
)

Writes a new value into a specific location. This is commonly used to update a prior "placeholder" location in the stream. The specified location is assumed to have proper CDR alignment for the type to insert. This requirement is satisfied by using one of the placeholder-writing methods to align the stream for the anticipated value and obtain the correct location. Treatment of x with repect to byte swapping is the same as for when any value is inserted.

Parameters:
x The value to insert into the specified location.
loc The location at which to insert x. loc must be a valid position within the stream's current set of message blocks.
See also:
write_long_placeholder(), write_short_placeholder ()

Definition at line 726 of file CDR_Stream.cpp.

References ACE_CDR::swap_4().

00727 {
00728   if (this->find (loc) == 0)
00729     return false;
00730 
00731 #if !defined (ACE_ENABLE_SWAP_ON_WRITE)
00732   *reinterpret_cast<ACE_CDR::Long*> (loc) = x;
00733 #else
00734   if (!this->do_byte_swap_)
00735   {
00736     *reinterpret_cast<ACE_CDR::Long *> (loc) = x;
00737   }
00738   else
00739   {
00740     ACE_CDR::swap_4 (reinterpret_cast<const char*> (&x), loc);
00741   }
00742 #endif /* ACE_ENABLE_SWAP_ON_WRITE */
00743 
00744   return true;
00745 }

ACE_INLINE void ACE_OutputCDR::reset ( void   ) 

Reuse the CDR stream to write on the old buffer.

Definition at line 158 of file CDR_Stream.inl.

References ACE_Message_Block::cont(), current_, current_alignment_, current_is_writable_, ACE_CDR::mb_align(), ACE_Message_Block::release(), and start_.

00159 {
00160   this->current_ = &this->start_;
00161   this->current_is_writable_ = true;
00162   ACE_CDR::mb_align (&this->start_);
00163 
00164 #if !defined (ACE_LACKS_CDR_ALIGNMENT)
00165   this->current_alignment_ = 0;
00166 #endif /* ACE_LACKS_CDR_ALIGNMENT */
00167 
00168   // It is tempting not to remove the memory, but we need to do so to
00169   // release any potential user buffers chained in the continuation
00170   // field.
00171 
00172   ACE_Message_Block * const cont = this->start_.cont ();
00173   if (cont)
00174     {
00175       ACE_Message_Block::release (cont);
00176       this->start_.cont (0);
00177     }
00178 
00179 #if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1)
00180   this->monitor_->receive (this->start_.total_size ());
00181 #endif /* ACE_HAS_MONITOR_POINTS==1 */
00182 }

ACE_INLINE void ACE_OutputCDR::reset_byte_order ( int  byte_order  ) 

For use by a gateway, which creates the output stream for the reply to the client in its native byte order, but which must send the reply in the byte order of the target's reply to the gateway.

Definition at line 552 of file CDR_Stream.inl.

References ACE_CDR_BYTE_ORDER, and do_byte_swap_.

00553 {
00554   this->do_byte_swap_ = (byte_order != ACE_CDR_BYTE_ORDER);
00555 }

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

set GIOP version info

Definition at line 486 of file CDR_Stream.inl.

References major_version_, and minor_version_.

00487 {
00488   this->major_version_ = major;
00489   this->minor_version_ = minor;
00490 }

ACE_INLINE size_t ACE_OutputCDR::total_length ( void   )  const

Add the length of each message block in the chain.

Definition at line 519 of file CDR_Stream.inl.

References end(), and ACE_CDR::total_length().

Referenced by ACE_Log_Msg_IPC::log().

00520 {
00521   return ACE_CDR::total_length (this->begin (), this->end ());
00522 }

size_t ACE_OutputCDR::wchar_maxbytes ( void   )  [static]

access the serialized size of wchars.

Definition at line 176 of file CDR_Stream.cpp.

References wchar_maxbytes_.

Referenced by ACE_Log_Msg_IPC::log(), ACE_SizeCDR::write_wchar(), ACE_SizeCDR::write_wchar_array(), ACE_SizeCDR::write_wchar_array_i(), and ACE_SizeCDR::write_wstring().

00177 {
00178   return ACE_OutputCDR::wchar_maxbytes_;
00179 }

void ACE_OutputCDR::wchar_maxbytes ( size_t  max_bytes  )  [static]

set the global size of serialized wchars. This may be different than the size of a wchar_t.

Definition at line 170 of file CDR_Stream.cpp.

References wchar_maxbytes_.

00171 {
00172   ACE_OutputCDR::wchar_maxbytes_ = maxbytes;
00173 }

ACE_INLINE void ACE_OutputCDR::wchar_translator ( ACE_WChar_Codeset_Translator  ) 

Set the wchar codeset translator.

Definition at line 601 of file CDR_Stream.inl.

References wchar_translator_.

00602 {
00603   this->wchar_translator_ = wctran;
00604 }

ACE_INLINE ACE_WChar_Codeset_Translator * ACE_OutputCDR::wchar_translator ( void   )  const

Definition at line 589 of file CDR_Stream.inl.

References wchar_translator_.

00590 {
00591   return this->wchar_translator_;
00592 }

ACE_CDR::Boolean ACE_OutputCDR::write_1 ( const ACE_CDR::Octet x  )  [private]

Definition at line 459 of file CDR_Stream.cpp.

Referenced by ACE_WChar_Codeset_Translator::write_1(), ACE_Char_Codeset_Translator::write_1(), write_char(), write_octet(), and write_wchar().

00460 {
00461   char *buf = 0;
00462   if (this->adjust (1, buf) == 0)
00463     {
00464       *reinterpret_cast<ACE_CDR::Octet*> (buf) = *x;
00465       return true;
00466     }
00467 
00468   return false;
00469 }

ACE_CDR::Boolean ACE_OutputCDR::write_16 ( const ACE_CDR::LongDouble x  )  [private]

Definition at line 564 of file CDR_Stream.cpp.

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

Referenced by write_longdouble().

00565 {
00566   char* buf = 0;
00567   if (this->adjust (ACE_CDR::LONGDOUBLE_SIZE,
00568                     ACE_CDR::LONGDOUBLE_ALIGN,
00569                     buf) == 0)
00570     {
00571 #if !defined (ACE_ENABLE_SWAP_ON_WRITE)
00572       *reinterpret_cast<ACE_CDR::LongDouble*> (buf) = *x;
00573       return 1;
00574 #else
00575       if (!this->do_byte_swap_)
00576         {
00577           *reinterpret_cast<ACE_CDR::LongDouble *> (buf) = *x;
00578           return true;
00579         }
00580       else
00581         {
00582           ACE_CDR::swap_16 (reinterpret_cast<const char*> (x), buf);
00583           return true;
00584         }
00585 #endif /* ACE_ENABLE_SWAP_ON_WRITE */
00586     }
00587 
00588   return false;
00589 }

ACE_CDR::Boolean ACE_OutputCDR::write_2 ( const ACE_CDR::UShort x  )  [private]

Definition at line 472 of file CDR_Stream.cpp.

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

Referenced by ACE_WChar_Codeset_Translator::write_2(), write_short(), write_ushort(), and write_wchar().

00473 {
00474   char *buf = 0;
00475   if (this->adjust (ACE_CDR::SHORT_SIZE, buf) == 0)
00476     {
00477 #if !defined (ACE_ENABLE_SWAP_ON_WRITE)
00478       *reinterpret_cast<ACE_CDR::UShort*> (buf) = *x;
00479       return true;
00480 #else
00481       if (!this->do_byte_swap_)
00482         {
00483           *reinterpret_cast<ACE_CDR::UShort *> (buf) = *x;
00484           return true;
00485         }
00486       else
00487         {
00488           ACE_CDR::swap_2 (reinterpret_cast<const char*> (x), buf);
00489           return true;
00490         }
00491 #endif /* ACE_ENABLE_SWAP_ON_WRITE */
00492     }
00493 
00494   return false;
00495 }

ACE_CDR::Boolean ACE_OutputCDR::write_4 ( const ACE_CDR::ULong x  )  [private]

Definition at line 498 of file CDR_Stream.cpp.

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

Referenced by ACE_WChar_Codeset_Translator::write_4(), write_float(), write_long(), write_ulong(), and write_wchar().

00499 {
00500   char *buf = 0;
00501   if (this->adjust (ACE_CDR::LONG_SIZE, buf) == 0)
00502     {
00503 #if !defined (ACE_ENABLE_SWAP_ON_WRITE)
00504       *reinterpret_cast<ACE_CDR::ULong*> (buf) = *x;
00505       return true;
00506 #else
00507       if (!this->do_byte_swap_)
00508         {
00509           *reinterpret_cast<ACE_CDR::ULong *> (buf) = *x;
00510           return true;
00511         }
00512       else
00513         {
00514           ACE_CDR::swap_4 (reinterpret_cast<const char*> (x), buf);
00515           return true;
00516         }
00517 #endif /* ACE_ENABLE_SWAP_ON_WRITE */
00518     }
00519 
00520   return false;
00521 }

ACE_CDR::Boolean ACE_OutputCDR::write_8 ( const ACE_CDR::ULongLong x  )  [private]

Definition at line 524 of file CDR_Stream.cpp.

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

Referenced by write_double(), write_longlong(), and write_ulonglong().

00525 {
00526   char *buf = 0;
00527 
00528   if (this->adjust (ACE_CDR::LONGLONG_SIZE, buf) == 0)
00529     {
00530 #if defined (__arm__)
00531       // Convert to Intel format (12345678 => 56781234)
00532       const char *orig = reinterpret_cast<const char *> (x);
00533       char *target = buf;
00534       register ACE_UINT32 x =
00535         *reinterpret_cast<const ACE_UINT32 *> (orig);
00536       register ACE_UINT32 y =
00537         *reinterpret_cast<const ACE_UINT32 *> (orig + 4);
00538       *reinterpret_cast<ACE_UINT32 *> (target) = y;
00539       *reinterpret_cast<ACE_UINT32 *> (target + 4) = x;
00540       return true;
00541 #else
00542 #  if !defined (ACE_ENABLE_SWAP_ON_WRITE)
00543       *reinterpret_cast<ACE_CDR::ULongLong *> (buf) = *x;
00544       return true;
00545 #  else
00546       if (!this->do_byte_swap_)
00547         {
00548           *reinterpret_cast<ACE_CDR::ULongLong *> (buf) = *x;
00549           return true;
00550         }
00551       else
00552         {
00553           ACE_CDR::swap_8 (reinterpret_cast<const char*> (x), buf);
00554           return true;
00555         }
00556 #  endif /* ACE_ENABLE_SWAP_ON_WRITE */
00557 #endif /* !__arm__ */
00558      }
00559 
00560   return false;
00561 }

ACE_CDR::Boolean ACE_OutputCDR::write_array ( const void *  x,
size_t  size,
size_t  align,
ACE_CDR::ULong  length 
) [private]

write 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 632 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::write_array(), ACE_Char_Codeset_Translator::write_array(), write_char_array(), write_double_array(), write_float_array(), write_long_array(), write_longdouble_array(), write_longlong_array(), write_octet_array(), write_short_array(), write_ulong_array(), write_ulonglong_array(), write_ushort_array(), and write_wchar_array().

00636 {
00637   if (length == 0)
00638     return true;
00639   char *buf = 0;
00640   if (this->adjust (size * length, align, buf) == 0)
00641     {
00642 #if !defined (ACE_ENABLE_SWAP_ON_WRITE)
00643       ACE_OS::memcpy (buf, x, size*length);
00644       return true;
00645 #else
00646       if (!this->do_byte_swap_ || size == 1)
00647         {
00648           ACE_OS::memcpy (buf, x, size*length);
00649           return true;
00650         }
00651       else
00652         {
00653           const char *source = reinterpret_cast<const char *> (x);
00654           switch (size)
00655             {
00656             case 2:
00657               ACE_CDR::swap_2_array (source, buf, length);
00658               return true;
00659             case 4:
00660               ACE_CDR::swap_4_array (source, buf, length);
00661               return true;
00662             case 8:
00663               ACE_CDR::swap_8_array (source, buf, length);
00664               return true;
00665             case 16:
00666               ACE_CDR::swap_16_array (source, buf, length);
00667               return true;
00668             default:
00669               // TODO: print something?
00670               this->good_bit_ = false;
00671               return false;
00672             }
00673         }
00674 #endif /* ACE_ENABLE_SWAP_ON_WRITE */
00675     }
00676   this->good_bit_ = false;
00677   return false;
00678 }

ACE_INLINE ACE_CDR::Boolean ACE_OutputCDR::write_boolean ( ACE_CDR::Boolean  x  ) 

Definition at line 193 of file CDR_Stream.inl.

References write_octet().

Referenced by append_boolean(), operator<<(), and write_boolean_array().

00194 {
00195   return
00196     static_cast<ACE_CDR::Boolean> (
00197       this->write_octet (
00198         x
00199         ? static_cast<ACE_CDR::Octet> (1)
00200         : static_cast<ACE_CDR::Octet> (0)));
00201 }

ACE_CDR::Boolean ACE_OutputCDR::write_boolean_array ( const ACE_CDR::Boolean x,
ACE_CDR::ULong  length 
)

Note:
the portion written starts at <x> and ends at <x + length>. The length is *NOT* stored into the CDR stream.

Definition at line 682 of file CDR_Stream.cpp.

References end(), good_bit(), and write_boolean().

00684 {
00685   // It is hard to optimize this, the spec requires that on the wire
00686   // booleans be represented as a byte with value 0 or 1, but in
00687   // memory it is possible (though very unlikely) that a boolean has
00688   // a non-zero value (different from 1).
00689   // We resort to a simple loop.
00690   ACE_CDR::Boolean const * const end = x + length;
00691 
00692   for (ACE_CDR::Boolean const * i = x;
00693        i != end && this->good_bit ();
00694        ++i)
00695     (void) this->write_boolean (*i);
00696 
00697   return this->good_bit ();
00698 }

ACE_INLINE ACE_CDR::Boolean ACE_OutputCDR::write_char ( ACE_CDR::Char  x  ) 

Definition at line 204 of file CDR_Stream.inl.

References char_translator_, write_1(), and ACE_Char_Codeset_Translator::write_char().

Referenced by append_char(), and operator<<().

00205 {
00206   if (this->char_translator_ == 0)
00207     {
00208       ACE_CDR::Octet temp = static_cast<ACE_CDR::Octet> (x);
00209       return this->write_1 (&temp);
00210     }
00211   return this->char_translator_->write_char (*this, x);
00212 }

ACE_INLINE ACE_CDR::Boolean ACE_OutputCDR::write_char_array ( const ACE_CDR::Char x,
ACE_CDR::ULong  length 
)

Note:
the portion written starts at <x> and ends at <x + length>. The length is *NOT* stored into the CDR stream.

Definition at line 300 of file CDR_Stream.inl.

References char_translator_, ACE_CDR::OCTET_ALIGN, ACE_CDR::OCTET_SIZE, write_array(), and ACE_Char_Codeset_Translator::write_char_array().

Referenced by operator<<().

00302 {
00303   if (this->char_translator_ == 0)
00304     return this->write_array (x,
00305                               ACE_CDR::OCTET_SIZE,
00306                               ACE_CDR::OCTET_ALIGN,
00307                               length);
00308   return this->char_translator_->write_char_array (*this, x, length);
00309 }

ACE_INLINE ACE_CDR::Boolean ACE_OutputCDR::write_double ( const ACE_CDR::Double x  ) 

Definition at line 261 of file CDR_Stream.inl.

References write_8().

Referenced by append_double(), and operator<<().

00262 {
00263   void const * const temp = &x;
00264   return this->write_8 (reinterpret_cast<ACE_CDR::ULongLong const *> (temp));
00265 }

ACE_INLINE ACE_CDR::Boolean ACE_OutputCDR::write_double_array ( const ACE_CDR::Double x,
ACE_CDR::ULong  length 
)

Note:
the portion written starts at <x> and ends at <x + length>. The length is *NOT* stored into the CDR stream.

Definition at line 416 of file CDR_Stream.inl.

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

00418 {
00419   return this->write_array (x,
00420                             ACE_CDR::LONGLONG_SIZE,
00421                             ACE_CDR::LONGLONG_ALIGN,
00422                             length);
00423 }

ACE_INLINE ACE_CDR::Boolean ACE_OutputCDR::write_float ( ACE_CDR::Float  x  ) 

Definition at line 254 of file CDR_Stream.inl.

References write_4().

Referenced by append_float(), and operator<<().

00255 {
00256   void const * const temp = &x;
00257   return this->write_4 (reinterpret_cast<ACE_CDR::ULong const *> (temp));
00258 }

ACE_INLINE ACE_CDR::Boolean ACE_OutputCDR::write_float_array ( const ACE_CDR::Float x,
ACE_CDR::ULong  length 
)

Note:
the portion written starts at <x> and ends at <x + length>. The length is *NOT* stored into the CDR stream.

Definition at line 405 of file CDR_Stream.inl.

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

00407 {
00408   return this->write_array (x,
00409                             ACE_CDR::LONG_SIZE,
00410                             ACE_CDR::LONG_ALIGN,
00411                             length);
00412 }

ACE_INLINE ACE_CDR::Boolean ACE_OutputCDR::write_long ( ACE_CDR::Long  x  ) 

Definition at line 228 of file CDR_Stream.inl.

References write_4().

Referenced by append_long(), and operator<<().

00229 {
00230   ACE_CDR::ULong temp = static_cast<ACE_CDR::ULong> (x);
00231   return this->write_4 (&temp);
00232 }

ACE_INLINE ACE_CDR::Boolean ACE_OutputCDR::write_long_array ( const ACE_CDR::Long x,
ACE_CDR::ULong  length 
)

Note:
the portion written starts at <x> and ends at <x + length>. The length is *NOT* stored into the CDR stream.

Definition at line 365 of file CDR_Stream.inl.

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

00367 {
00368   return this->write_array (x,
00369                             ACE_CDR::LONG_SIZE,
00370                             ACE_CDR::LONG_ALIGN,
00371                             length);
00372 }

char * ACE_OutputCDR::write_long_placeholder ( void   ) 

Write a placeholder into the stream. The placeholder's pointer is returned so it may later be passed as the loc argument to replace (). These methods align the stream's write pointer properly prior to writing the placeholder.

Return values:
Pointer to the placeholder; 0 if there is not enough space in the stream and memory could not be allocated.

Definition at line 702 of file CDR_Stream.cpp.

References ACE_CDR::LONG_SIZE.

00703 {
00704   char *buf = 0;
00705   if (this->adjust (ACE_CDR::LONG_SIZE, buf) == 0)
00706     *reinterpret_cast<ACE_CDR::ULong*> (buf) = 0;
00707   else
00708     buf = 0;
00709   return buf;
00710 }

ACE_INLINE ACE_CDR::Boolean ACE_OutputCDR::write_longdouble ( const ACE_CDR::LongDouble x  ) 

Definition at line 268 of file CDR_Stream.inl.

References write_16().

Referenced by append_longdouble(), and operator<<().

00269 {
00270   return this->write_16 (&x);
00271 }

ACE_INLINE ACE_CDR::Boolean ACE_OutputCDR::write_longdouble_array ( const ACE_CDR::LongDouble x,
ACE_CDR::ULong  length 
)

Note:
the portion written starts at <x> and ends at <x + length>. The length is *NOT* stored into the CDR stream.

Definition at line 426 of file CDR_Stream.inl.

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

00428 {
00429   return this->write_array (x,
00430                             ACE_CDR::LONGDOUBLE_SIZE,
00431                             ACE_CDR::LONGDOUBLE_ALIGN,
00432                             length);
00433 }

ACE_INLINE ACE_CDR::Boolean ACE_OutputCDR::write_longlong ( const ACE_CDR::LongLong x  ) 

Definition at line 241 of file CDR_Stream.inl.

References write_8().

Referenced by append_longlong(), and operator<<().

00242 {
00243   void const * const temp = &x;
00244   return this->write_8 (reinterpret_cast<ACE_CDR::ULongLong const *> (temp));
00245 }

ACE_INLINE ACE_CDR::Boolean ACE_OutputCDR::write_longlong_array ( const ACE_CDR::LongLong x,
ACE_CDR::ULong  length 
)

Note:
the portion written starts at <x> and ends at <x + length>. The length is *NOT* stored into the CDR stream.

Definition at line 385 of file CDR_Stream.inl.

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

00387 {
00388   return this->write_array (x,
00389                             ACE_CDR::LONGLONG_SIZE,
00390                             ACE_CDR::LONGLONG_ALIGN,
00391                             length);
00392 }

ACE_INLINE ACE_CDR::Boolean ACE_OutputCDR::write_octet ( ACE_CDR::Octet  x  ) 

Definition at line 187 of file CDR_Stream.inl.

References write_1().

Referenced by append_octet(), operator<<(), and write_boolean().

00188 {
00189   return this->write_1 (&x);
00190 }

ACE_INLINE ACE_CDR::Boolean ACE_OutputCDR::write_octet_array ( const ACE_CDR::Octet x,
ACE_CDR::ULong  length 
)

Note:
the portion written starts at <x> and ends at <x + length>. The length is *NOT* stored into the CDR stream.

Definition at line 335 of file CDR_Stream.inl.

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

Referenced by write_wchar().

00337 {
00338   return this->write_array (x,
00339                             ACE_CDR::OCTET_SIZE,
00340                             ACE_CDR::OCTET_ALIGN,
00341                             length);
00342 }

ACE_CDR::Boolean ACE_OutputCDR::write_octet_array_mb ( const ACE_Message_Block mb  ) 

Write an octet array contained inside a MB, this can be optimized to minimize copies.

Definition at line 401 of file CDR_Stream.cpp.

References ACE_BIT_ENABLED, ACE_NEW_RETURN, ACE_Message_Block::cont(), current_, current_alignment_, current_is_writable_, ACE_Message_Block::DONT_DELETE, ACE_Message_Block::end(), good_bit_, length(), ACE_CDR::MAX_ALIGNMENT, memcpy_tradeoff_, ACE_CDR::OCTET_ALIGN, ACE_CDR::OCTET_SIZE, ACE_Message_Block::rd_ptr(), ACE_Message_Block::release(), and ACE_Message_Block::wr_ptr().

00402 {
00403   // If the buffer is small and it fits in the current message
00404   // block it is be cheaper just to copy the buffer.
00405   for (const ACE_Message_Block* i = mb;
00406        i != 0;
00407        i = i->cont ())
00408     {
00409       size_t const length = i->length ();
00410 
00411       // If the mb does not own its data we are forced to make a copy.
00412       if (ACE_BIT_ENABLED (i->flags (),
00413                            ACE_Message_Block::DONT_DELETE))
00414         {
00415           if (! this->write_array (i->rd_ptr (),
00416                                    ACE_CDR::OCTET_SIZE,
00417                                    ACE_CDR::OCTET_ALIGN,
00418                                    static_cast<ACE_CDR::ULong> (length)))
00419             return (this->good_bit_ = false);
00420           continue;
00421         }
00422 
00423       if (length < this->memcpy_tradeoff_
00424           && this->current_->wr_ptr () + length < this->current_->end ())
00425         {
00426           if (! this->write_array (i->rd_ptr (),
00427                                    ACE_CDR::OCTET_SIZE,
00428                                    ACE_CDR::OCTET_ALIGN,
00429                                    static_cast<ACE_CDR::ULong> (length)))
00430             return (this->good_bit_ = false);
00431           continue;
00432         }
00433 
00434       ACE_Message_Block* cont = 0;
00435       this->good_bit_ = false;
00436       ACE_NEW_RETURN (cont,
00437                       ACE_Message_Block (i->data_block ()->duplicate ()),
00438                       false);
00439       this->good_bit_ = true;
00440 
00441       if (this->current_->cont () != 0)
00442         ACE_Message_Block::release (this->current_->cont ());
00443       cont->rd_ptr (i->rd_ptr ());
00444       cont->wr_ptr (i->wr_ptr ());
00445 
00446       this->current_->cont (cont);
00447       this->current_ = cont;
00448       this->current_is_writable_ = false;
00449 #if !defined (ACE_LACKS_CDR_ALIGNMENT)
00450       this->current_alignment_ =
00451         (this->current_alignment_ + cont->length ()) % ACE_CDR::MAX_ALIGNMENT;
00452 #endif /* ACE_LACKS_CDR_ALIGNMENT */
00453     }
00454 
00455   return true;
00456 }

ACE_INLINE ACE_CDR::Boolean ACE_OutputCDR::write_short ( ACE_CDR::Short  x  ) 

Definition at line 215 of file CDR_Stream.inl.

References write_2().

Referenced by append_short(), and operator<<().

00216 {
00217   ACE_CDR::UShort temp = static_cast<ACE_CDR::UShort> (x);
00218   return this->write_2 (&temp);
00219 }

ACE_INLINE ACE_CDR::Boolean ACE_OutputCDR::write_short_array ( const ACE_CDR::Short x,
ACE_CDR::ULong  length 
)

Note:
the portion written starts at <x> and ends at <x + length>. The length is *NOT* stored into the CDR stream.

Definition at line 345 of file CDR_Stream.inl.

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

00347 {
00348   return this->write_array (x,
00349                             ACE_CDR::SHORT_SIZE,
00350                             ACE_CDR::SHORT_ALIGN,
00351                             length);
00352 }

char * ACE_OutputCDR::write_short_placeholder ( void   ) 

Write a placeholder into the stream. The placeholder's pointer is returned so it may later be passed as the loc argument to replace (). These methods align the stream's write pointer properly prior to writing the placeholder.

Return values:
Pointer to the placeholder; 0 if there is not enough space in the stream and memory could not be allocated.

Definition at line 714 of file CDR_Stream.cpp.

References ACE_CDR::SHORT_SIZE.

00715 {
00716   char *buf = 0;
00717   if (this->adjust (ACE_CDR::SHORT_SIZE, buf) == 0)
00718     *reinterpret_cast<ACE_CDR::UShort*> (buf) = 0;
00719   else
00720     buf = 0;
00721   return buf;
00722 }

ACE_CDR::Boolean ACE_OutputCDR::write_string ( const ACE_CString x  ) 

Definition at line 349 of file CDR_Stream.cpp.

References ACE_String_Base< CHAR >::c_str(), ACE_String_Base< CHAR >::length(), and write_string().

00350 {
00351   // @@ Leave this method in here, not the `.i' file so that we don't
00352   //    have to unnecessarily pull in the `ace/SString.h' header.
00353   return this->write_string (static_cast<ACE_CDR::ULong> (x.length ()),
00354                              x.c_str());
00355 }

ACE_CDR::Boolean ACE_OutputCDR::write_string ( ACE_CDR::ULong  len,
const ACE_CDR::Char x 
)

Definition at line 321 of file CDR_Stream.cpp.

References char_translator_, and ACE_Char_Codeset_Translator::write_string().

00323 {
00324   // @@ This is a slight violation of "Optimize for the common case",
00325   // i.e. normally the translator will be 0, but OTOH the code is
00326   // smaller and should be better for the cache ;-) ;-)
00327   if (this->char_translator_ != 0)
00328     return this->char_translator_->write_string (*this, len, x);
00329 
00330   if (len != 0)
00331     {
00332       if (this->write_ulong (len + 1))
00333         return this->write_char_array (x, len + 1);
00334     }
00335   else
00336     {
00337       // Be nice to programmers: treat nulls as empty strings not
00338       // errors. (OMG-IDL supports languages that don't use the C/C++
00339       // notion of null v. empty strings; nulls aren't part of the OMG-IDL
00340       // string model.)
00341       if (this->write_ulong (1))
00342         return this->write_char (0);
00343     }
00344 
00345   return (this->good_bit_ = false);
00346 }

ACE_INLINE ACE_CDR::Boolean ACE_OutputCDR::write_string ( const ACE_CDR::Char x  ) 

For string we offer methods that accept a precomputed length.

Definition at line 274 of file CDR_Stream.inl.

References ACE_OS::strlen().

Referenced by append_string(), operator<<(), and write_string().

00275 {
00276   if (x)
00277     {
00278       ACE_CDR::ULong const len =
00279         static_cast<ACE_CDR::ULong> (ACE_OS::strlen (x));
00280       return this->write_string (len, x);
00281     }
00282 
00283   return this->write_string (0, 0);
00284 }

ACE_INLINE ACE_CDR::Boolean ACE_OutputCDR::write_ulong ( ACE_CDR::ULong  x  ) 

Definition at line 235 of file CDR_Stream.inl.

References write_4().

Referenced by append_ulong(), operator<<(), and write_wstring().

00236 {
00237   return this->write_4 (&x);
00238 }

ACE_INLINE ACE_CDR::Boolean ACE_OutputCDR::write_ulong_array ( const ACE_CDR::ULong x,
ACE_CDR::ULong  length 
)

Note:
the portion written starts at <x> and ends at <x + length>. The length is *NOT* stored into the CDR stream.

Definition at line 375 of file CDR_Stream.inl.

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

00377 {
00378   return this->write_array (x,
00379                             ACE_CDR::LONG_SIZE,
00380                             ACE_CDR::LONG_ALIGN,
00381                             length);
00382 }

ACE_INLINE ACE_CDR::Boolean ACE_OutputCDR::write_ulonglong ( const ACE_CDR::ULongLong x  ) 

Definition at line 248 of file CDR_Stream.inl.

References write_8().

Referenced by append_ulonglong(), and operator<<().

00249 {
00250   return this->write_8 (&x);
00251 }

ACE_INLINE ACE_CDR::Boolean ACE_OutputCDR::write_ulonglong_array ( const ACE_CDR::ULongLong x,
ACE_CDR::ULong  length 
)

Note:
the portion written starts at <x> and ends at <x + length>. The length is *NOT* stored into the CDR stream.

Definition at line 395 of file CDR_Stream.inl.

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

00397 {
00398   return this->write_array (x,
00399                             ACE_CDR::LONGLONG_SIZE,
00400                             ACE_CDR::LONGLONG_ALIGN,
00401                             length);
00402 }

ACE_INLINE ACE_CDR::Boolean ACE_OutputCDR::write_ushort ( ACE_CDR::UShort  x  ) 

Definition at line 222 of file CDR_Stream.inl.

References write_2().

Referenced by append_ushort(), and operator<<().

00223 {
00224   return this->write_2 (&x);
00225 }

ACE_INLINE ACE_CDR::Boolean ACE_OutputCDR::write_ushort_array ( const ACE_CDR::UShort x,
ACE_CDR::ULong  length 
)

Note:
the portion written starts at <x> and ends at <x + length>. The length is *NOT* stored into the CDR stream.

Definition at line 355 of file CDR_Stream.inl.

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

00357 {
00358   return this->write_array (x,
00359                             ACE_CDR::SHORT_SIZE,
00360                             ACE_CDR::SHORT_ALIGN,
00361                             length);
00362 }

ACE_CDR::Boolean ACE_OutputCDR::write_wchar ( ACE_CDR::WChar  x  ) 

Definition at line 260 of file CDR_Stream.cpp.

References major_version_, minor_version_, wchar_maxbytes_, write_1(), write_2(), write_4(), and write_octet_array().

Referenced by append_wchar(), and operator<<().

00261 {
00262   if (this->wchar_translator_ != 0)
00263     return (this->good_bit_ = this->wchar_translator_->write_wchar (*this, x));
00264   if (ACE_OutputCDR::wchar_maxbytes_ == 0)
00265     {
00266       errno = EACCES;
00267       return (this->good_bit_ = false);
00268     }
00269   if (static_cast<ACE_CDR::Short> (major_version_) == 1
00270       && static_cast<ACE_CDR::Short> (minor_version_) == 2)
00271     {
00272       ACE_CDR::Octet len =
00273         static_cast<ACE_CDR::Octet> (ACE_OutputCDR::wchar_maxbytes_);
00274       if (this->write_1 (&len))
00275         {
00276           if (ACE_OutputCDR::wchar_maxbytes_ == sizeof(ACE_CDR::WChar))
00277             return
00278               this->write_octet_array (
00279                                        reinterpret_cast<const ACE_CDR::Octet*> (&x),
00280                                        static_cast<ACE_CDR::ULong> (len));
00281           else
00282             if (ACE_OutputCDR::wchar_maxbytes_ == 2)
00283               {
00284                 ACE_CDR::Short sx = static_cast<ACE_CDR::Short> (x);
00285                 return
00286                   this->write_octet_array (
00287                                            reinterpret_cast<const ACE_CDR::Octet*> (&sx),
00288                                            static_cast<ACE_CDR::ULong> (len));
00289               }
00290             else
00291               {
00292                 ACE_CDR::Octet ox = static_cast<ACE_CDR::Octet> (x);
00293                 return
00294                   this->write_octet_array (
00295                                            reinterpret_cast<const ACE_CDR::Octet*> (&ox),
00296                                            static_cast<ACE_CDR::ULong> (len));
00297               }
00298         }
00299     }
00300   else if (static_cast<ACE_CDR::Short> (minor_version_) == 0)
00301     { // wchar is not allowed with GIOP 1.0.
00302       errno = EINVAL;
00303       return (this->good_bit_ = false);
00304     }
00305   if (ACE_OutputCDR::wchar_maxbytes_ == sizeof (ACE_CDR::WChar))
00306     {
00307       void const * const temp = &x;
00308       return
00309         this->write_4 (reinterpret_cast<const ACE_CDR::ULong *> (temp));
00310     }
00311   else if (ACE_OutputCDR::wchar_maxbytes_ == 2)
00312     {
00313       ACE_CDR::Short sx = static_cast<ACE_CDR::Short> (x);
00314       return this->write_2 (reinterpret_cast<const ACE_CDR::UShort *> (&sx));
00315     }
00316   ACE_CDR::Octet ox = static_cast<ACE_CDR::Octet> (x);
00317   return this->write_1 (reinterpret_cast<const ACE_CDR::Octet *> (&ox));
00318 }

ACE_INLINE ACE_CDR::Boolean ACE_OutputCDR::write_wchar_array ( const ACE_CDR::WChar x,
ACE_CDR::ULong  length 
)

Note:
the portion written starts at <x> and ends at <x + length>. The length is *NOT* stored into the CDR stream.

Definition at line 312 of file CDR_Stream.inl.

References good_bit_, ACE_CDR::LONG_ALIGN, ACE_CDR::SHORT_ALIGN, wchar_maxbytes_, wchar_translator_, write_array(), ACE_WChar_Codeset_Translator::write_wchar_array(), and write_wchar_array_i().

Referenced by operator<<().

00314 {
00315   if (this->wchar_translator_)
00316     return this->wchar_translator_->write_wchar_array (*this, x, length);
00317 
00318   if (ACE_OutputCDR::wchar_maxbytes_ == 0)
00319     {
00320       errno = EACCES;
00321       return (ACE_CDR::Boolean) (this->good_bit_ = false);
00322     }
00323 
00324   if (ACE_OutputCDR::wchar_maxbytes_ == sizeof (ACE_CDR::WChar))
00325     return this->write_array (x,
00326                               sizeof (ACE_CDR::WChar),
00327                               sizeof (ACE_CDR::WChar) == 2
00328                               ? ACE_CDR::SHORT_ALIGN
00329                               : ACE_CDR::LONG_ALIGN,
00330                               length);
00331   return this->write_wchar_array_i (x,length);
00332 }

ACE_CDR::Boolean ACE_OutputCDR::write_wchar_array_i ( const ACE_CDR::WChar x,
ACE_CDR::ULong  length 
) [private]

Definition at line 592 of file CDR_Stream.cpp.

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

Referenced by write_wchar_array().

00594 {
00595   if (length == 0)
00596     return true;
00597   char* buf = 0;
00598   size_t const align = (ACE_OutputCDR::wchar_maxbytes_ == 2) ?
00599     ACE_CDR::SHORT_ALIGN :
00600     ACE_CDR::OCTET_ALIGN;
00601 
00602   if (this->adjust (ACE_OutputCDR::wchar_maxbytes_ * length, align, buf) == 0)
00603     {
00604       if (ACE_OutputCDR::wchar_maxbytes_ == 2)
00605         {
00606           ACE_CDR::UShort *sb = reinterpret_cast<ACE_CDR::UShort *> (buf);
00607           for (size_t i = 0; i < length; ++i)
00608 #if !defined (ACE_ENABLE_SWAP_ON_WRITE)
00609             sb[i] = static_cast<ACE_CDR::UShort> (x[i]);
00610 #else
00611               if (!this->do_byte_swap_)
00612               sb[i] = static_cast<ACE_CDR::UShort> (x[i]);
00613             else
00614               {
00615                 ACE_CDR::UShort sx = static_cast<ACE_CDR::UShort> (x[i]);
00616                 ACE_CDR::swap_2 (reinterpret_cast<char *> (&sx), &buf[i * 2]);
00617               }
00618 #endif /* ACE_ENABLE_SWAP_ON_WRITE */
00619         }
00620       else
00621         {
00622           for (size_t i = 0; i < length; ++i)
00623             buf[i] = static_cast<char> (x[i]);
00624         }
00625       return this->good_bit_;
00626     }
00627   return false;
00628 }

ACE_CDR::Boolean ACE_OutputCDR::write_wstring ( ACE_CDR::ULong  length,
const ACE_CDR::WChar x 
)

Definition at line 358 of file CDR_Stream.cpp.

References wchar_maxbytes_, wchar_translator_, write_ulong(), and ACE_WChar_Codeset_Translator::write_wstring().

00360 {
00361   // @@ This is a slight violation of "Optimize for the common case",
00362   // i.e. normally the translator will be 0, but OTOH the code is
00363   // smaller and should be better for the cache ;-) ;-)
00364   // What do we do for GIOP 1.2???
00365   if (this->wchar_translator_ != 0)
00366     return this->wchar_translator_->write_wstring (*this, len, x);
00367   if (ACE_OutputCDR::wchar_maxbytes_ == 0)
00368     {
00369       errno = EACCES;
00370       return (this->good_bit_ = false);
00371     }
00372 
00373   if (static_cast<ACE_CDR::Short> (this->major_version_) == 1
00374       && static_cast<ACE_CDR::Short> (this->minor_version_) == 2)
00375     {
00376       if (x != 0)
00377         {
00378           //In GIOP 1.2 the length field contains the number of bytes
00379           //the wstring occupies rather than number of wchars
00380           //Taking sizeof might not be a good way! This is a temporary fix.
00381           if (this->write_ulong (ACE_OutputCDR::wchar_maxbytes_ * len))
00382             return this->write_wchar_array (x, len);
00383         }
00384       else
00385         //In GIOP 1.2 zero length wstrings are legal
00386         return this->write_ulong (0);
00387     }
00388 
00389   else
00390     if (x != 0)
00391       {
00392         if (this->write_ulong (len + 1))
00393           return this->write_wchar_array (x, len + 1);
00394       }
00395     else if (this->write_ulong (1))
00396       return this->write_wchar (0);
00397   return (this->good_bit_ = false);
00398 }

ACE_INLINE ACE_CDR::Boolean ACE_OutputCDR::write_wstring ( const ACE_CDR::WChar x  ) 

Definition at line 287 of file CDR_Stream.inl.

References ACE_OS::strlen().

Referenced by append_wstring(), and operator<<().

00288 {
00289   if (x)
00290     {
00291       ACE_CDR::ULong const len =
00292         static_cast<ACE_CDR::ULong> (ACE_OS::strlen (x));
00293       return this->write_wstring (len, x);
00294     }
00295 
00296   return this->write_wstring (0, 0);
00297 }


Friends And Related Function Documentation

friend class ACE_Char_Codeset_Translator [friend]

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

Definition at line 106 of file CDR_Stream.h.

friend class ACE_InputCDR [friend]

Definition at line 108 of file CDR_Stream.h.

friend class ACE_WChar_Codeset_Translator [friend]

Definition at line 107 of file CDR_Stream.h.


Member Data Documentation

ACE_Char_Codeset_Translator* ACE_OutputCDR::char_translator_ [protected]

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

Definition at line 585 of file CDR_Stream.h.

Referenced by char_translator(), write_char(), write_char_array(), and write_string().

ACE_Message_Block* ACE_OutputCDR::current_ [private]

The current block in the chain where we are writing.

Definition at line 536 of file CDR_Stream.h.

Referenced by ACE_OutputCDR(), adjust(), consolidate(), current(), end(), grow_and_adjust(), reset(), write_octet_array_mb(), and ~ACE_OutputCDR().

size_t ACE_OutputCDR::current_alignment_ [private]

The current alignment as measured from the start of the buffer. Usually this coincides with the alignment of the buffer in memory, but, when we chain another buffer this "quasi invariant" is broken. The current_alignment is used to readjust the buffer following the stolen message block.

Definition at line 547 of file CDR_Stream.h.

Referenced by adjust(), current_alignment(), grow_and_adjust(), reset(), and write_octet_array_mb().

bool ACE_OutputCDR::current_is_writable_ [private]

Is the current block writable. When we steal a buffer from the user and just chain it into the message block we are not supposed to write on it, even if it is past the start and end of the buffer.

Definition at line 556 of file CDR_Stream.h.

Referenced by consolidate(), grow_and_adjust(), reset(), and write_octet_array_mb().

bool ACE_OutputCDR::do_byte_swap_ [private]

If not zero swap bytes at writing so the created CDR stream byte order does *not* match the machine byte order. The motivation for such a beast is that in some setting a few (fast) machines can be serving hundreds of slow machines with the opposite byte order, so it makes sense (as a load balancing device) to put the responsibility in the writers. THIS IS NOT A STANDARD IN CORBA, USE AT YOUR OWN RISK

Definition at line 567 of file CDR_Stream.h.

Referenced by do_byte_swap(), and reset_byte_order().

bool ACE_OutputCDR::good_bit_ [private]

Set to false when an error ocurrs.

Definition at line 570 of file CDR_Stream.h.

Referenced by ACE_WChar_Codeset_Translator::good_bit(), ACE_Char_Codeset_Translator::good_bit(), good_bit(), grow_and_adjust(), write_array(), write_octet_array_mb(), write_wchar_array(), and write_wchar_array_i().

ACE_CDR::Octet ACE_OutputCDR::major_version_ [protected]

GIOP version information.

Definition at line 581 of file CDR_Stream.h.

Referenced by get_version(), ACE_WChar_Codeset_Translator::major_version(), ACE_Char_Codeset_Translator::major_version(), set_version(), and write_wchar().

size_t const ACE_OutputCDR::memcpy_tradeoff_ [private]

Break-even point for copying.

Definition at line 573 of file CDR_Stream.h.

Referenced by write_octet_array_mb().

ACE_CDR::Octet ACE_OutputCDR::minor_version_ [protected]

Definition at line 582 of file CDR_Stream.h.

Referenced by get_version(), ACE_WChar_Codeset_Translator::minor_version(), ACE_Char_Codeset_Translator::minor_version(), set_version(), and write_wchar().

ACE_Message_Block ACE_OutputCDR::start_ [private]

The start of the chain of message blocks.

Definition at line 533 of file CDR_Stream.h.

Referenced by ACE_OutputCDR(), begin(), buffer(), consolidate(), length(), reset(), and ~ACE_OutputCDR().

ACE_BEGIN_VERSIONED_NAMESPACE_DECL size_t ACE_OutputCDR::wchar_maxbytes_ = sizeof (ACE_CDR::WChar) [static, protected]

Some wide char codesets may be defined with a maximum number of bytes that is smaller than the size of a wchar_t. This means that the CDR cannot simply memcpy a block of wchars to and from the stream, but must instead realign the bytes appropriately. In cases when wchar i/o is not allowed, such as with GIOP 1.0, or not having a native wchar codeset defined, the maxbytes is set to zero, indicating no wchar data is allowed.

Definition at line 597 of file CDR_Stream.h.

Referenced by ACE_InputCDR::read_wchar(), ACE_InputCDR::read_wchar_array(), ACE_InputCDR::read_wchar_array_i(), ACE_InputCDR::read_wstring(), ACE_InputCDR::skip_wchar(), wchar_maxbytes(), write_wchar(), write_wchar_array(), write_wchar_array_i(), and write_wstring().

ACE_WChar_Codeset_Translator* ACE_OutputCDR::wchar_translator_ [protected]

Definition at line 586 of file CDR_Stream.h.

Referenced by wchar_translator(), write_wchar_array(), and write_wstring().


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