ACE_OutputCDR Class Reference

A CDR stream for marshalling data, most often for transmission to another system which may or may not have the same byte order. More...

#include <CDR_Stream.h>

Collaboration diagram for ACE_OutputCDR:
Collaboration graph
[legend]

List of all members.

Classes

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

Public Member Functions

 ACE_OutputCDR (size_t size=0, int byte_order=ACE_CDR::BYTE_ORDER_NATIVE, 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_NATIVE, 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_NATIVE, 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_NATIVE, 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
void current_alignment (size_t current_alignment)
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)
 For string we offer methods that accept a precomputed length.
ACE_CDR::Boolean write_char (ACE_CDR::Char x)
 For string we offer methods that accept a precomputed length.
ACE_CDR::Boolean write_wchar (ACE_CDR::WChar x)
 For string we offer methods that accept a precomputed length.
ACE_CDR::Boolean write_octet (ACE_CDR::Octet x)
 For string we offer methods that accept a precomputed length.
ACE_CDR::Boolean write_short (ACE_CDR::Short x)
 For string we offer methods that accept a precomputed length.
ACE_CDR::Boolean write_ushort (ACE_CDR::UShort x)
 For string we offer methods that accept a precomputed length.
ACE_CDR::Boolean write_long (ACE_CDR::Long x)
 For string we offer methods that accept a precomputed length.
ACE_CDR::Boolean write_ulong (ACE_CDR::ULong x)
 For string we offer methods that accept a precomputed length.
ACE_CDR::Boolean write_longlong (const ACE_CDR::LongLong &x)
 For string we offer methods that accept a precomputed length.
ACE_CDR::Boolean write_ulonglong (const ACE_CDR::ULongLong &x)
 For string we offer methods that accept a precomputed length.
ACE_CDR::Boolean write_float (ACE_CDR::Float x)
 For string we offer methods that accept a precomputed length.
ACE_CDR::Boolean write_double (const ACE_CDR::Double &x)
 For string we offer methods that accept a precomputed length.
ACE_CDR::Boolean write_longdouble (const ACE_CDR::LongDouble &x)
 For string we offer methods that accept a precomputed length.
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)
 For string we offer methods that accept a precomputed length.
ACE_CDR::Boolean write_string (const ACE_CString &x)
 For string we offer methods that accept a precomputed length.
ACE_CDR::Boolean write_wstring (const ACE_CDR::WChar *x)
 For string we offer methods that accept a precomputed length.
ACE_CDR::Boolean write_wstring (ACE_CDR::ULong length, const ACE_CDR::WChar *x)
 For string we offer methods that accept a precomputed length.



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)
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 &)
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)

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_

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

Detailed Description

A CDR stream for marshalling data, most often for transmission to another system which may or may not have the same byte order.

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:

Definition at line 84 of file CDR_Stream.h.


Constructor & Destructor Documentation

ACE_OutputCDR::ACE_OutputCDR ( size_t  size = 0,
int  byte_order = ACE_CDR::BYTE_ORDER_NATIVE,
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; allows one to set byte ordering, allocators, and tuning information.

Parameters:
size Causes constructor to preallocate size bytes; if size is 0 it allocates the default size.
byte_order The byte order that data will have within this object. Unless otherwise specified, the byte order will be the order native to the hardware this is executed on. To force the marshalled data to have a specific order, specify one of the values defined in ACE_CDR::Byte_Order.
Note:
The ACE_ENABLE_SWAP_ON_WRITE config macro must be set for any local byte swapping to occur as data is inserted into an ACE_OutputCDR object.
ACE_OutputCDR::ACE_OutputCDR ( char *  data,
size_t  size,
int  byte_order = ACE_CDR::BYTE_ORDER_NATIVE,
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 
)

Build a CDR stream with an initial buffer, it will *not* remove data, since it did not allocated it. It's important to be careful with the alignment of data. 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 62 of file CDR_Stream.cpp.

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

ACE_OutputCDR::ACE_OutputCDR ( ACE_Data_Block data_block,
int  byte_order = ACE_CDR::BYTE_ORDER_NATIVE,
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 
)

Build a CDR stream with an initial data block, it will *not* remove <data_block>, since it did not allocated it. It's important to be 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 105 of file CDR_Stream.cpp.

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

ACE_OutputCDR::ACE_OutputCDR ( ACE_Message_Block data,
int  byte_order = ACE_CDR::BYTE_ORDER_NATIVE,
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 137 of file CDR_Stream.cpp.

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

ACE_OutputCDR::~ACE_OutputCDR ( void   ) 

destructor

Definition at line 142 of file CDR_Stream.inl.

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

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.

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 }

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.

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

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

00580 {
00581 #if !defined (ACE_LACKS_CDR_ALIGNMENT)
00582   char *dummy;
00583   return this->adjust (0, alignment, dummy);
00584 #else
00585   ACE_UNUSED_ARG (alignment);
00586   // A return value of -1 from this function is used
00587   // to indicate failure, returning 0
00588   return 0;
00589 #endif /* ACE_LACKS_CDR_ALIGNMENT */
00590 }

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

Return 0 on failure and 1 on success.

Definition at line 1362 of file CDR_Stream.inl.

01363 {
01364   ACE_CDR::Boolean x;
01365   return stream.read_boolean (x) ? this->write_boolean (x) : false;
01366 }

ACE_CDR::Boolean ACE_OutputCDR::append_char ( ACE_InputCDR stream  ) 
Note:
the portion written starts at x and ends at x + length. The length is *NOT* stored into the CDR stream.

Definition at line 1369 of file CDR_Stream.inl.

01370 {
01371   ACE_CDR::Char x;
01372   return stream.read_char (x) ? this->write_char (x) : false;
01373 }

ACE_CDR::Boolean ACE_OutputCDR::append_double ( ACE_InputCDR stream  ) 
Note:
the portion written starts at x and ends at x + length. The length is *NOT* stored into the CDR stream.

Definition at line 1439 of file CDR_Stream.inl.

01440 {
01441   ACE_CDR::Double x;
01442   return stream.read_double (x) ? this->write_double (x) : false;
01443 }

ACE_CDR::Boolean ACE_OutputCDR::append_float ( ACE_InputCDR stream  ) 
Note:
the portion written starts at x and ends at x + length. The length is *NOT* stored into the CDR stream.

Definition at line 1432 of file CDR_Stream.inl.

01433 {
01434   ACE_CDR::Float x;
01435   return stream.read_float (x) ? this->write_float (x) : false;
01436 }

ACE_CDR::Boolean ACE_OutputCDR::append_long ( ACE_InputCDR stream  ) 
Note:
the portion written starts at x and ends at x + length. The length is *NOT* stored into the CDR stream.

Definition at line 1404 of file CDR_Stream.inl.

01405 {
01406   ACE_CDR::Long x;
01407   return stream.read_long (x) ? this->write_long (x) : false;
01408 }

ACE_CDR::Boolean ACE_OutputCDR::append_longdouble ( ACE_InputCDR stream  ) 
Note:
the portion written starts at x and ends at x + length. The length is *NOT* stored into the CDR stream.

Definition at line 1446 of file CDR_Stream.inl.

01447 {
01448   ACE_CDR::LongDouble x;
01449   return stream.read_longdouble (x) ? this->write_longdouble (x) : false;
01450 }

ACE_CDR::Boolean ACE_OutputCDR::append_longlong ( ACE_InputCDR stream  ) 
Note:
the portion written starts at x and ends at x + length. The length is *NOT* stored into the CDR stream.

Definition at line 1418 of file CDR_Stream.inl.

01419 {
01420   ACE_CDR::LongLong x;
01421   return stream.read_longlong (x) ? this->write_longlong (x) : false;
01422 }

ACE_CDR::Boolean ACE_OutputCDR::append_octet ( ACE_InputCDR stream  ) 
Note:
the portion written starts at x and ends at x + length. The length is *NOT* stored into the CDR stream.

Definition at line 1383 of file CDR_Stream.inl.

01384 {
01385   ACE_CDR::Octet x;
01386   return stream.read_octet (x) ? this->write_octet (x) : false;
01387 }

ACE_CDR::Boolean ACE_OutputCDR::append_short ( ACE_InputCDR stream  ) 
Note:
the portion written starts at x and ends at x + length. The length is *NOT* stored into the CDR stream.

Definition at line 1390 of file CDR_Stream.inl.

01391 {
01392   ACE_CDR::Short x;
01393   return stream.read_short (x) ? this->write_short (x) : false;
01394 }

ACE_CDR::Boolean ACE_OutputCDR::append_string ( ACE_InputCDR stream  ) 
Note:
the portion written starts at x and ends at x + length. The length is *NOT* stored into the CDR stream.

Definition at line 1453 of file CDR_Stream.inl.

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

ACE_CDR::Boolean ACE_OutputCDR::append_ulong ( ACE_InputCDR stream  ) 
Note:
the portion written starts at x and ends at x + length. The length is *NOT* stored into the CDR stream.

Definition at line 1411 of file CDR_Stream.inl.

01412 {
01413   ACE_CDR::ULong x;
01414   return stream.read_ulong (x) ? this->write_ulong (x) : false;
01415 }

ACE_CDR::Boolean ACE_OutputCDR::append_ulonglong ( ACE_InputCDR stream  ) 
Note:
the portion written starts at x and ends at x + length. The length is *NOT* stored into the CDR stream.

Definition at line 1425 of file CDR_Stream.inl.

01426 {
01427   ACE_CDR::ULongLong x;
01428   return stream.read_ulonglong (x) ? this->write_ulonglong (x) : false;
01429 }

ACE_CDR::Boolean ACE_OutputCDR::append_ushort ( ACE_InputCDR stream  ) 
Note:
the portion written starts at x and ends at x + length. The length is *NOT* stored into the CDR stream.

Definition at line 1397 of file CDR_Stream.inl.

01398 {
01399   ACE_CDR::UShort x;
01400   return stream.read_ushort (x) ? this->write_ushort (x) : false;
01401 }

ACE_CDR::Boolean ACE_OutputCDR::append_wchar ( ACE_InputCDR stream  ) 
Note:
the portion written starts at x and ends at x + length. The length is *NOT* stored into the CDR stream.

Definition at line 1376 of file CDR_Stream.inl.

01377 {
01378   ACE_CDR::WChar x;
01379   return stream.read_wchar (x) ? this->write_wchar (x) : false;
01380 }

ACE_CDR::Boolean ACE_OutputCDR::append_wstring ( ACE_InputCDR stream  ) 
Note:
the portion written starts at x and ends at x + length. The length is *NOT* stored into the CDR stream.

Definition at line 1463 of file CDR_Stream.inl.

01464 {
01465   ACE_CDR::WChar *x = 0;
01466   ACE_CDR::Boolean const flag =
01467     (stream.read_wstring (x) ? this->write_wstring (x) : false);
01468   delete [] x;
01469   return flag;
01470 }

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.

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

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.

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

int ACE_OutputCDR::byte_order ( void   )  const

Returns the byte order this stream is marshaling data in. Will be one of the values in ACE_CDR::Byte_Order.

Definition at line 543 of file CDR_Stream.inl.

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

void ACE_OutputCDR::char_translator ( ACE_Char_Codeset_Translator ctran  ) 

Set the char codeset translator.

Definition at line 605 of file CDR_Stream.inl.

00606 {
00607   this->char_translator_ = ctran;
00608 }

ACE_Char_Codeset_Translator * ACE_OutputCDR::char_translator ( void   )  const

Access the codeset translators. They can be null!

Definition at line 593 of file CDR_Stream.inl.

00594 {
00595   return this->char_translator_;
00596 }

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

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

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.

00514 {
00515   return this->current_;
00516 }

void ACE_OutputCDR::current_alignment ( size_t  current_alignment  ) 

Definition at line 569 of file CDR_Stream.inl.

00570 {
00571 #if !defined (ACE_LACKS_CDR_ALIGNMENT)
00572   this->current_alignment_ = current_alignment;
00573 #else
00574   ACE_UNUSED_ARG (current_alignment);
00575 #endif /* ACE_LACKS_CDR_ALIGNMENT */
00576 }

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.

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 }

bool ACE_OutputCDR::do_byte_swap ( void   )  const

Returns true if this stream is writing in non-native byte order and false otherwise. For example, it would be true if either ACE_ENABLE_SWAP_ON_WRITE is defined or a specific byte order was specified for this stream.

Definition at line 537 of file CDR_Stream.inl.

00538 {
00539   return this->do_byte_swap_;
00540 }

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.

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

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

Definition at line 820 of file CDR_Stream.cpp.

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

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.

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

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.

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

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

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.

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

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

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

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

void ACE_OutputCDR::reset ( void   ) 

Reuse the CDR stream to write on the old buffer.

Definition at line 158 of file CDR_Stream.inl.

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 }

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.

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

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.

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

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.

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

00174 {
00175   return ACE_OutputCDR::wchar_maxbytes_;
00176 }

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

00168 {
00169   ACE_OutputCDR::wchar_maxbytes_ = maxbytes;
00170 }

void ACE_OutputCDR::wchar_translator ( ACE_WChar_Codeset_Translator wctran  ) 

Set the wchar codeset translator.

Definition at line 611 of file CDR_Stream.inl.

00612 {
00613   this->wchar_translator_ = wctran;
00614 }

ACE_WChar_Codeset_Translator * ACE_OutputCDR::wchar_translator ( void   )  const

Definition at line 599 of file CDR_Stream.inl.

00600 {
00601   return this->wchar_translator_;
00602 }

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

Definition at line 465 of file CDR_Stream.cpp.

00466 {
00467   char *buf = 0;
00468   if (this->adjust (1, buf) == 0)
00469     {
00470       *reinterpret_cast<ACE_CDR::Octet*> (buf) = *x;
00471       return true;
00472     }
00473 
00474   return false;
00475 }

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

Definition at line 570 of file CDR_Stream.cpp.

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

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

Definition at line 478 of file CDR_Stream.cpp.

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

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

Definition at line 504 of file CDR_Stream.cpp.

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

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

Definition at line 530 of file CDR_Stream.cpp.

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

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

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

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

For string we offer methods that accept a precomputed length.

Definition at line 193 of file CDR_Stream.inl.

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

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

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

For string we offer methods that accept a precomputed length.

Definition at line 204 of file CDR_Stream.inl.

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

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_CDR::Boolean ACE_OutputCDR::write_double ( const ACE_CDR::Double x  ) 

For string we offer methods that accept a precomputed length.

Definition at line 261 of file CDR_Stream.inl.

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

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.

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

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

For string we offer methods that accept a precomputed length.

Definition at line 254 of file CDR_Stream.inl.

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

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.

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

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

For string we offer methods that accept a precomputed length.

Definition at line 228 of file CDR_Stream.inl.

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

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.

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

00708 {
00709   char *buf = 0;
00710   if (this->adjust (ACE_CDR::LONG_SIZE, buf) == 0)
00711     *reinterpret_cast<ACE_CDR::ULong*> (buf) = 0;
00712   else
00713     buf = 0;
00714   return buf;
00715 }

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

For string we offer methods that accept a precomputed length.

Definition at line 268 of file CDR_Stream.inl.

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

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.

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

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

For string we offer methods that accept a precomputed length.

Definition at line 241 of file CDR_Stream.inl.

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

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.

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

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

For string we offer methods that accept a precomputed length.

Definition at line 187 of file CDR_Stream.inl.

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

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.

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

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

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

For string we offer methods that accept a precomputed length.

Definition at line 215 of file CDR_Stream.inl.

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

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.

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

00719 {
00720   char *buf = 0;
00721   if (this->adjust (ACE_CDR::SHORT_SIZE, buf) == 0)
00722     *reinterpret_cast<ACE_CDR::UShort*> (buf) = 0;
00723   else
00724     buf = 0;
00725   return buf;
00726 }

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

For string we offer methods that accept a precomputed length.

Definition at line 346 of file CDR_Stream.cpp.

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

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

For string we offer methods that accept a precomputed length.

Definition at line 318 of file CDR_Stream.cpp.

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

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.

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_CDR::Boolean ACE_OutputCDR::write_ulong ( ACE_CDR::ULong  x  ) 

For string we offer methods that accept a precomputed length.

Definition at line 235 of file CDR_Stream.inl.

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

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.

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

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

For string we offer methods that accept a precomputed length.

Definition at line 248 of file CDR_Stream.inl.

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

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.

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

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

For string we offer methods that accept a precomputed length.

Definition at line 222 of file CDR_Stream.inl.

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

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.

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  ) 

For string we offer methods that accept a precomputed length.

Definition at line 257 of file CDR_Stream.cpp.

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

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.

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

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

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

For string we offer methods that accept a precomputed length.

Definition at line 355 of file CDR_Stream.cpp.

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

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

For string we offer methods that accept a precomputed length.

Definition at line 287 of file CDR_Stream.inl.

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

friend class ACE_InputCDR [friend]

Definition at line 94 of file CDR_Stream.h.

friend class ACE_WChar_Codeset_Translator [friend]

Definition at line 93 of file CDR_Stream.h.


Member Data Documentation

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

Definition at line 590 of file CDR_Stream.h.

The current block in the chain where we are writing.

Definition at line 541 of file CDR_Stream.h.

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

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

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

bool ACE_OutputCDR::good_bit_ [private]

Set to false when an error ocurrs.

Definition at line 575 of file CDR_Stream.h.

GIOP version information.

Definition at line 586 of file CDR_Stream.h.

size_t const ACE_OutputCDR::memcpy_tradeoff_ [private]

Break-even point for copying.

Definition at line 578 of file CDR_Stream.h.

Definition at line 587 of file CDR_Stream.h.

The start of the chain of message blocks.

Definition at line 538 of file CDR_Stream.h.

size_t ACE_OutputCDR::wchar_maxbytes_ [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 602 of file CDR_Stream.h.

Definition at line 591 of file CDR_Stream.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on Sun Nov 22 23:15:41 2009 for ACE by  doxygen 1.6.1