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 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
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 replace (ACE_CDR::Long x, char *loc)
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)
Array write operations
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)
Append contents of own CDR stream to another
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

void wchar_maxbytes (size_t max_bytes)
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

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

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

References ACE_CDR_BYTE_ORDER, ACE_CDR::mb_align(), ACE_CDR::Octet, and start_.

00027   :  start_ ((size ? size : (size_t) ACE_CDR::DEFAULT_BUFSIZE) + ACE_CDR::MAX_ALIGNMENT,
00028              ACE_Message_Block::MB_DATA,
00029              0,
00030              0,
00031              buffer_allocator,
00032              0,
00033              0,
00034              ACE_Time_Value::zero,
00035              ACE_Time_Value::max_time,
00036              data_block_allocator,
00037              message_block_allocator),
00038 #if !defined (ACE_LACKS_CDR_ALIGNMENT)
00039      current_alignment_ (0),
00040 #endif /* ACE_LACKS_CDR_ALIGNMENT */
00041      current_is_writable_ (true),
00042      do_byte_swap_ (byte_order != ACE_CDR_BYTE_ORDER),
00043      good_bit_ (true),
00044      memcpy_tradeoff_ (memcpy_tradeoff),
00045      major_version_ (major_version),
00046      minor_version_ (minor_version),
00047      char_translator_ (0),
00048      wchar_translator_ (0)
00049 
00050 {
00051   ACE_CDR::mb_align (&this->start_);
00052   this->current_ = &this->start_;
00053 }

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

References ACE_CDR_BYTE_ORDER, ACE_CDR::mb_align(), ACE_CDR::Octet, and start_.

00064   :  start_ (size,
00065              ACE_Message_Block::MB_DATA,
00066              0,
00067              data,
00068              buffer_allocator,
00069              0,
00070              0,
00071              ACE_Time_Value::zero,
00072              ACE_Time_Value::max_time,
00073              data_block_allocator,
00074              message_block_allocator),
00075 #if !defined (ACE_LACKS_CDR_ALIGNMENT)
00076      current_alignment_ (0),
00077 #endif /* ACE_LACKS_CDR_ALIGNMENT */
00078      current_is_writable_ (true),
00079      do_byte_swap_ (byte_order != ACE_CDR_BYTE_ORDER),
00080      good_bit_ (true),
00081      memcpy_tradeoff_ (memcpy_tradeoff),
00082      major_version_ (major_version),
00083      minor_version_ (minor_version),
00084      char_translator_ (0),
00085      wchar_translator_ (0)
00086 {
00087   // We cannot trust the buffer to be properly aligned
00088   ACE_CDR::mb_align (&this->start_);
00089   this->current_ = &this->start_;
00090 }

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

References ACE_CDR_BYTE_ORDER, ACE_CDR::mb_align(), ACE_CDR::Octet, and start_.

00098   :  start_ (data_block,
00099              ACE_Message_Block::DONT_DELETE,
00100              message_block_allocator),
00101 #if !defined (ACE_LACKS_CDR_ALIGNMENT)
00102      current_alignment_ (0),
00103 #endif /* ACE_LACKS_CDR_ALIGNMENT */
00104      current_is_writable_ (true),
00105      do_byte_swap_ (byte_order != ACE_CDR_BYTE_ORDER),
00106      good_bit_ (true),
00107      memcpy_tradeoff_ (memcpy_tradeoff),
00108      major_version_ (major_version),
00109      minor_version_ (minor_version),
00110      char_translator_ (0),
00111      wchar_translator_ (0)
00112 {
00113   // We cannot trust the buffer to be properly aligned
00114   ACE_CDR::mb_align (&this->start_);
00115   this->current_ = &this->start_;
00116 }

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

References ACE_CDR_BYTE_ORDER, ACE_CDR::mb_align(), ACE_CDR::Octet, and start_.

00123   :  start_ (data->data_block ()->duplicate ()),
00124 #if !defined (ACE_LACKS_CDR_ALIGNMENT)
00125      current_alignment_ (0),
00126 #endif /* ACE_LACKS_CDR_ALIGNMENT */
00127      current_is_writable_ (true),
00128      do_byte_swap_ (byte_order != ACE_CDR_BYTE_ORDER),
00129      good_bit_ (true),
00130      memcpy_tradeoff_ (memcpy_tradeoff),
00131      major_version_ (major_version),
00132      minor_version_ (minor_version),
00133      char_translator_ (0),
00134      wchar_translator_ (0)
00135 {
00136   // We cannot trust the buffer to be properly aligned
00137   ACE_CDR::mb_align (&this->start_);
00138   this->current_ = &this->start_;
00139 }

ACE_INLINE ACE_OutputCDR::~ACE_OutputCDR void   ) 
 

destructor

Definition at line 142 of file CDR_Stream.inl.

References ACE_Message_Block::cont(), 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   this->current_ = 0;
00150 }

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

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

00436 {
00437   if (!this->current_is_writable_)
00438     return this->grow_and_adjust (size, align, buf);
00439 
00440 #if !defined (ACE_LACKS_CDR_ALIGNMENT)
00441   size_t const offset =
00442     ACE_align_binary (this->current_alignment_, align)
00443     - this->current_alignment_;
00444 
00445   buf = this->current_->wr_ptr () + offset;
00446 #else
00447   buf = this->current_->wr_ptr ();
00448 #endif /* ACE_LACKS_CDR_ALIGNMENT */
00449 
00450   char * const end = buf + size;
00451 
00452   if (end <= this->current_->end () &&
00453       end >= buf)
00454     {
00455 #if !defined (ACE_LACKS_CDR_ALIGNMENT)
00456       this->current_alignment_ += offset + size;
00457 #endif /* ACE_LACKS_CDR_ALIGNMENT */
00458       this->current_->wr_ptr (end);
00459       return 0;
00460     }
00461 
00462   return this->grow_and_adjust (size, align, buf);
00463 }

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

Referenced by ACE_WChar_Codeset_Translator::adjust(), ACE_Char_Codeset_Translator::adjust(), align_write_ptr(), grow_and_adjust(), write_1(), write_16(), write_2(), write_4(), write_8(), write_array(), and write_wchar_array_i().

00467 {
00468   return this->adjust (size, size, buf);
00469 }

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 -byte boundary. Argument MUST be a power of 2. Returns 0 on success and -1 on failure.

Definition at line 555 of file CDR_Stream.inl.

References adjust().

00556 {
00557 #if !defined (ACE_LACKS_CDR_ALIGNMENT)
00558   char *dummy;
00559   return this->adjust (0, alignment, dummy);
00560 #else
00561   ACE_UNUSED_ARG (alignment);
00562   // A return value of -1 from this function is used
00563   // to indicate failure, returning 0
00564   return 0;
00565 #endif /* ACE_LACKS_CDR_ALIGNMENT */
00566 }

ACE_INLINE ACE_CDR::Boolean ACE_OutputCDR::append_boolean ACE_InputCDR  ) 
 

Return 0 on failure and 1 on success.

Definition at line 1335 of file CDR_Stream.inl.

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

01336 {
01337   ACE_CDR::Boolean x;
01338   return stream.read_boolean (x) ? this->write_boolean (x) : false;
01339 }

ACE_INLINE ACE_CDR::Boolean ACE_OutputCDR::append_char ACE_InputCDR  ) 
 

Return 0 on failure and 1 on success.

Definition at line 1342 of file CDR_Stream.inl.

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

01343 {
01344   ACE_CDR::Char x;
01345   return stream.read_char (x) ? this->write_char (x) : false;
01346 }

ACE_INLINE ACE_CDR::Boolean ACE_OutputCDR::append_double ACE_InputCDR  ) 
 

Return 0 on failure and 1 on success.

Definition at line 1412 of file CDR_Stream.inl.

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

01413 {
01414   ACE_CDR::Double x;
01415   return stream.read_double (x) ? this->write_double (x) : false;
01416 }

ACE_INLINE ACE_CDR::Boolean ACE_OutputCDR::append_float ACE_InputCDR  ) 
 

Return 0 on failure and 1 on success.

Definition at line 1405 of file CDR_Stream.inl.

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

01406 {
01407   ACE_CDR::Float x;
01408   return stream.read_float (x) ? this->write_float (x) : false;
01409 }

ACE_INLINE ACE_CDR::Boolean ACE_OutputCDR::append_long ACE_InputCDR  ) 
 

Return 0 on failure and 1 on success.

Definition at line 1377 of file CDR_Stream.inl.

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

01378 {
01379   ACE_CDR::Long x;
01380   return stream.read_long (x) ? this->write_long (x) : false;
01381 }

ACE_INLINE ACE_CDR::Boolean ACE_OutputCDR::append_longdouble ACE_InputCDR  ) 
 

Return 0 on failure and 1 on success.

Definition at line 1419 of file CDR_Stream.inl.

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

01420 {
01421   ACE_CDR::LongDouble x;
01422   return stream.read_longdouble (x) ? this->write_longdouble (x) : false;
01423 }

ACE_INLINE ACE_CDR::Boolean ACE_OutputCDR::append_longlong ACE_InputCDR  ) 
 

Return 0 on failure and 1 on success.

Definition at line 1391 of file CDR_Stream.inl.

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

01392 {
01393   ACE_CDR::LongLong x;
01394   return stream.read_longlong (x) ? this->write_longlong (x) : false;
01395 }

ACE_INLINE ACE_CDR::Boolean ACE_OutputCDR::append_octet ACE_InputCDR  ) 
 

Return 0 on failure and 1 on success.

Definition at line 1356 of file CDR_Stream.inl.

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

01357 {
01358   ACE_CDR::Octet x;
01359   return stream.read_octet (x) ? this->write_octet (x) : false;
01360 }

ACE_INLINE ACE_CDR::Boolean ACE_OutputCDR::append_short ACE_InputCDR  ) 
 

Return 0 on failure and 1 on success.

Definition at line 1363 of file CDR_Stream.inl.

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

01364 {
01365   ACE_CDR::Short x;
01366   return stream.read_short (x) ? this->write_short (x) : false;
01367 }

ACE_INLINE ACE_CDR::Boolean ACE_OutputCDR::append_string ACE_InputCDR  ) 
 

Return 0 on failure and 1 on success.

Definition at line 1426 of file CDR_Stream.inl.

References ACE_CDR::Boolean, ACE_CDR::Char, ACE_InputCDR::read_string(), and write_string().

01427 {
01428   ACE_CDR::Char *x;
01429   const ACE_CDR::Boolean flag =
01430     (stream.read_string (x) ? this->write_string (x) : false);
01431   delete [] x;
01432   return flag;
01433 }

ACE_INLINE ACE_CDR::Boolean ACE_OutputCDR::append_ulong ACE_InputCDR  ) 
 

Return 0 on failure and 1 on success.

Definition at line 1384 of file CDR_Stream.inl.

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

01385 {
01386   ACE_CDR::ULong x;
01387   return stream.read_ulong (x) ? this->write_ulong (x) : false;
01388 }

ACE_INLINE ACE_CDR::Boolean ACE_OutputCDR::append_ulonglong ACE_InputCDR  ) 
 

Return 0 on failure and 1 on success.

Definition at line 1398 of file CDR_Stream.inl.

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

01399 {
01400   ACE_CDR::ULongLong x;
01401   return stream.read_ulonglong (x) ? this->write_ulonglong (x) : false;
01402 }

ACE_INLINE ACE_CDR::Boolean ACE_OutputCDR::append_ushort ACE_InputCDR  ) 
 

Return 0 on failure and 1 on success.

Definition at line 1370 of file CDR_Stream.inl.

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

01371 {
01372   ACE_CDR::UShort x;
01373   return stream.read_ushort (x) ? this->write_ushort (x) : false;
01374 }

ACE_INLINE ACE_CDR::Boolean ACE_OutputCDR::append_wchar ACE_InputCDR  ) 
 

Return 0 on failure and 1 on success.

Definition at line 1349 of file CDR_Stream.inl.

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

01350 {
01351   ACE_CDR::WChar x;
01352   return stream.read_wchar (x) ? this->write_wchar (x) : false;
01353 }

ACE_INLINE ACE_CDR::Boolean ACE_OutputCDR::append_wstring ACE_InputCDR  ) 
 

Return 0 on failure and 1 on success.

Definition at line 1436 of file CDR_Stream.inl.

References ACE_CDR::Boolean, ACE_InputCDR::read_wstring(), ACE_CDR::WChar, and write_wstring().

01437 {
01438   ACE_CDR::WChar *x;
01439   const ACE_CDR::Boolean flag =
01440     (stream.read_wstring (x) ? this->write_wstring (x) : false);
01441   delete [] x;
01442   return flag;
01443 }

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

References start_.

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

00488 {
00489   return &this->start_;
00490 }

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

References ACE_Message_Block::rd_ptr(), and start_.

00512 {
00513   return this->start_.rd_ptr ();
00514 }

ACE_INLINE int ACE_OutputCDR::byte_order void   )  const
 

If returns 0, this returns ACE_CDR_BYTE_ORDER else it returns !ACE_CDR_BYTE_ORDER.

Definition at line 529 of file CDR_Stream.inl.

References ACE_CDR_BYTE_ORDER, and do_byte_swap().

00530 {
00531   if (this->do_byte_swap ())
00532     return !ACE_CDR_BYTE_ORDER;
00533   else
00534     return ACE_CDR_BYTE_ORDER;
00535 }

ACE_INLINE void ACE_OutputCDR::char_translator ACE_Char_Codeset_Translator  ) 
 

Set the char codeset translator.

Definition at line 581 of file CDR_Stream.inl.

References char_translator_.

00582 {
00583   this->char_translator_ = ctran;
00584 }

ACE_INLINE ACE_Char_Codeset_Translator * ACE_OutputCDR::char_translator void   )  const
 

Access the codeset translators. They can be null!

Definition at line 569 of file CDR_Stream.inl.

References char_translator_.

00570 {
00571   return this->char_translator_;
00572 }

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

References ACE_Message_Block::cont(), ACE_Message_Block::copy(), current_is_writable_, ACE_CDR::first_size(), ACE_Message_Block::length(), ACE_Message_Block::rd_ptr(), ACE_Message_Block::release(), ACE_Message_Block::size(), and start_.

00698 {
00699   // Optimize by only doing something if we need to
00700   if (this->current_ != &this->start_)
00701     {
00702       // Set the number of bytes in the top-level block, reallocating
00703       // if necessary.  The rd_ptr and wr_ptr remain at the original offsets
00704       // into the buffer, even if it is reallocated.
00705       // Return an error if the allocation failed.
00706       size_t newsize =
00707         ACE_CDR::first_size (this->total_length ()
00708                              + ACE_CDR::MAX_ALIGNMENT);
00709       if (this->start_.size (newsize) < 0)
00710         {
00711           return -1;
00712         }
00713 
00714       // Consolidate the chain into the first block.  NOTE that
00715       // ACE_CDR::consolidate can not be used since we don't want to
00716       // overwrite what is already in the first block. We just append it since
00717       // the read and write pointers weren't affected by the resizing above.
00718       // We also don't have to worry about alignment since the start block is
00719       // already aligned.
00720       // NOTE also we know there is a continuation since we checked for it
00721       // above.  There is therefore no reason to check for a 0 continuation
00722       // field here.
00723       ACE_Message_Block *cont = this->start_.cont ();
00724       for (const ACE_Message_Block* i = cont; i != 0; i = i->cont ())
00725         {
00726           this->start_.copy (i->rd_ptr (), i->length ());
00727         }
00728 
00729       // Release the old blocks that were consolidated and reset the
00730       // current_ and current_is_writable_ to reflect the single used block.
00731       ACE_Message_Block::release (cont);
00732       this->start_.cont (0);
00733       this->current_ = &this->start_;
00734       this->current_is_writable_ = true;
00735     }
00736 
00737   return 0;
00738 }

ACE_INLINE const ACE_Message_Block * ACE_OutputCDR::current void   )  const
 

Return the message block in chain.

Definition at line 499 of file CDR_Stream.inl.

00500 {
00501   return this->current_;
00502 }

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

References current_alignment_.

00545 {
00546 #if !defined (ACE_LACKS_CDR_ALIGNMENT)
00547   return this->current_alignment_;
00548 #else
00549   // Default value set to 0
00550   return 0;
00551 #endif /* ACE_LACKS_CDR_ALIGNMENT */
00552 }

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

References do_byte_swap_.

Referenced by byte_order().

00524 {
00525   return this->do_byte_swap_;
00526 }

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

References ACE_Message_Block::cont().

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

00494 {
00495   return this->current_->cont ();
00496 }

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

Definition at line 742 of file CDR_Stream.cpp.

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

Referenced by replace().

00743 {
00744   ACE_Message_Block* mb = 0;
00745   for (mb = &this->start_; mb != 0; mb = mb->cont ())
00746   {
00747     if (loc <= mb->wr_ptr () && loc >= mb->rd_ptr ())
00748     {
00749       break;
00750     }
00751   }
00752 
00753   return mb;
00754 }

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

Set the underlying GIOP version..

Definition at line 479 of file CDR_Stream.inl.

References ACE_CDR::Octet.

00480 {
00481   major = this->major_version_;
00482   minor = this->minor_version_;
00483 }

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

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

00428 {
00429   return this->good_bit_;
00430 }

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 boundary. It moved the to <buf + size>.

Definition at line 154 of file CDR_Stream.cpp.

References ACE_NEW_RETURN, adjust(), ACE_Message_Block::cont(), current_alignment_, current_is_writable_, ACE_Message_Block::data_block(), ACE_Data_Block::data_block_allocator(), ACE_CDR::next_size(), ACE_Message_Block::rd_ptr(), ACE_Message_Block::size(), and ACE_Message_Block::wr_ptr().

Referenced by adjust().

00157 {
00158   if (!this->current_is_writable_
00159       || this->current_->cont () == 0
00160       || this->current_->cont ()->size () < size + ACE_CDR::MAX_ALIGNMENT)
00161     {
00162       // Calculate the new buffer's length; if growing for encode, we
00163       // don't grow in "small" chunks because of the cost.
00164       size_t cursize = this->current_->size ();
00165       if (this->current_->cont () != 0)
00166         cursize = this->current_->cont ()->size ();
00167       size_t minsize = size;
00168 
00169 #if !defined (ACE_LACKS_CDR_ALIGNMENT)
00170       minsize += ACE_CDR::MAX_ALIGNMENT;
00171 #endif /* ACE_LACKS_CDR_ALIGNMENT */
00172 
00173       // Make sure that there is enough room for <minsize> bytes, but
00174       // also make it bigger than whatever our current size is.
00175       if (minsize < cursize)
00176         minsize = cursize;
00177 
00178       size_t const newsize = ACE_CDR::next_size (minsize);
00179 
00180       this->good_bit_ = false;
00181       ACE_Message_Block* tmp = 0;
00182       ACE_NEW_RETURN (tmp,
00183                       ACE_Message_Block (newsize,
00184                                          ACE_Message_Block::MB_DATA,
00185                                          0,
00186                                          0,
00187                                          this->current_->data_block ()->allocator_strategy (),
00188                                          0,
00189                                          0,
00190                                          ACE_Time_Value::zero,
00191                                          ACE_Time_Value::max_time,
00192                                          this->current_->data_block ()->data_block_allocator ()),
00193                       -1);
00194 
00195       // Message block initialization may fail while the construction
00196       // succeds.  Since as a matter of policy, ACE may throw no
00197       // exceptions, we have to do a separate check like this.
00198       if (tmp != 0 && tmp->size () < newsize)
00199         {
00200           delete tmp;
00201           errno = ENOMEM;
00202           return -1;
00203         }
00204 
00205       this->good_bit_ = true;
00206 
00207 #if !defined (ACE_LACKS_CDR_ALIGNMENT)
00208       // The new block must start with the same alignment as the
00209       // previous block finished.
00210       ptrdiff_t const tmpalign =
00211         reinterpret_cast<ptrdiff_t> (tmp->rd_ptr ()) % ACE_CDR::MAX_ALIGNMENT;
00212       ptrdiff_t const curalign =
00213         static_cast<ptrdiff_t> (this->current_alignment_) % ACE_CDR::MAX_ALIGNMENT;
00214       ptrdiff_t offset = curalign - tmpalign;
00215       if (offset < 0)
00216         offset += ACE_CDR::MAX_ALIGNMENT;
00217       tmp->rd_ptr (static_cast<size_t> (offset));
00218       tmp->wr_ptr (tmp->rd_ptr ());
00219 #endif /* ACE_LACKS_CDR_ALIGNMENT */
00220 
00221       // grow the chain and set the current block.
00222       tmp->cont (this->current_->cont ());
00223       this->current_->cont (tmp);
00224     }
00225   this->current_ = this->current_->cont ();
00226   this->current_is_writable_ = true;
00227 
00228   return this->adjust (size, align, buf);
00229 }

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

References ACE_Message_Block::length(), and start_.

Referenced by write_octet_array_mb().

00518 {
00519   return this->start_.length ();
00520 }

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

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

Definition at line 654 of file CDR_Stream.cpp.

References do_byte_swap_, find(), ACE_CDR::Long, and ACE_CDR::swap_4().

00655 {
00656   if (this->find (loc) == 0)
00657     return false;
00658 
00659 #if !defined (ACE_ENABLE_SWAP_ON_WRITE)
00660   *reinterpret_cast<ACE_CDR::Long*> (loc) = x;
00661 #else
00662   if (!this->do_byte_swap_)
00663   {
00664     *reinterpret_cast<ACE_CDR::Long *> (loc) = x;
00665   }
00666   else
00667   {
00668     ACE_CDR::swap_4 (reinterpret_cast<const char*> (&x), loc);
00669   }
00670 #endif /* ACE_ENABLE_SWAP_ON_WRITE */
00671 
00672   return true;
00673 }

ACE_INLINE void ACE_OutputCDR::reset void   ) 
 

Reuse the CDR stream to write on the old buffer.

Definition at line 153 of file CDR_Stream.inl.

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

00154 {
00155   this->current_ = &this->start_;
00156   this->current_is_writable_ = true;
00157   ACE_CDR::mb_align (&this->start_);
00158 
00159 #if !defined (ACE_LACKS_CDR_ALIGNMENT)
00160   this->current_alignment_ = 0;
00161 #endif /* ACE_LACKS_CDR_ALIGNMENT */
00162 
00163   // It is tempting not to remove the memory, but we need to do so to
00164   // release any potential user buffers chained in the continuation
00165   // field.
00166 
00167   ACE_Message_Block * const cont = this->start_.cont ();
00168   if (cont)
00169     {
00170       ACE_Message_Block::release (cont);
00171       this->start_.cont (0);
00172     }
00173 }

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

References ACE_CDR_BYTE_ORDER, and do_byte_swap_.

00539 {
00540   this->do_byte_swap_ = (byte_order != ACE_CDR_BYTE_ORDER);
00541 }

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

set GIOP version info

Definition at line 472 of file CDR_Stream.inl.

References ACE_CDR::Octet.

00473 {
00474   this->major_version_ = major;
00475   this->minor_version_ = minor;
00476 }

ACE_INLINE size_t ACE_OutputCDR::total_length void   )  const
 

Add the length of each message block in the chain.

Definition at line 505 of file CDR_Stream.inl.

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

Referenced by ACE_Log_Msg_IPC::log().

00506 {
00507   return ACE_CDR::total_length (this->begin (), this->end ());
00508 }

size_t ACE_OutputCDR::wchar_maxbytes void   )  [static]
 

access the serialized size of wchars.

Definition at line 148 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().

00149 {
00150   return ACE_OutputCDR::wchar_maxbytes_;
00151 }

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

References wchar_maxbytes_.

00143 {
00144   ACE_OutputCDR::wchar_maxbytes_ = maxbytes;
00145 }

ACE_INLINE void ACE_OutputCDR::wchar_translator ACE_WChar_Codeset_Translator  ) 
 

Set the wchar codeset translator.

Definition at line 587 of file CDR_Stream.inl.

References wchar_translator_.

00588 {
00589   this->wchar_translator_ = wctran;
00590 }

ACE_INLINE ACE_WChar_Codeset_Translator * ACE_OutputCDR::wchar_translator void   )  const
 

Definition at line 575 of file CDR_Stream.inl.

References wchar_translator_.

00576 {
00577   return this->wchar_translator_;
00578 }

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

Definition at line 431 of file CDR_Stream.cpp.

References adjust(), and ACE_CDR::Octet.

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

00432 {
00433   char *buf = 0;
00434   if (this->adjust (1, buf) == 0)
00435     {
00436       *reinterpret_cast<ACE_CDR::Octet*> (buf) = *x;
00437       return true;
00438     }
00439 
00440   return false;
00441 }

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

Definition at line 536 of file CDR_Stream.cpp.

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

Referenced by write_longdouble().

00537 {
00538   char* buf = 0;
00539   if (this->adjust (ACE_CDR::LONGDOUBLE_SIZE,
00540                     ACE_CDR::LONGDOUBLE_ALIGN,
00541                     buf) == 0)
00542     {
00543 #if !defined (ACE_ENABLE_SWAP_ON_WRITE)
00544       *reinterpret_cast<ACE_CDR::LongDouble*> (buf) = *x;
00545       return 1;
00546 #else
00547       if (!this->do_byte_swap_)
00548         {
00549           *reinterpret_cast<ACE_CDR::LongDouble *> (buf) = *x;
00550           return true;
00551         }
00552       else
00553         {
00554           ACE_CDR::swap_16 (reinterpret_cast<const char*> (x), buf);
00555           return true;
00556         }
00557 #endif /* ACE_ENABLE_SWAP_ON_WRITE */
00558     }
00559 
00560   return false;
00561 }

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

Definition at line 444 of file CDR_Stream.cpp.

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

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

00445 {
00446   char *buf = 0;
00447   if (this->adjust (ACE_CDR::SHORT_SIZE, buf) == 0)
00448     {
00449 #if !defined (ACE_ENABLE_SWAP_ON_WRITE)
00450       *reinterpret_cast<ACE_CDR::UShort*> (buf) = *x;
00451       return true;
00452 #else
00453       if (!this->do_byte_swap_)
00454         {
00455           *reinterpret_cast<ACE_CDR::UShort *> (buf) = *x;
00456           return true;
00457         }
00458       else
00459         {
00460           ACE_CDR::swap_2 (reinterpret_cast<const char*> (x), buf);
00461           return true;
00462         }
00463 #endif /* ACE_ENABLE_SWAP_ON_WRITE */
00464     }
00465 
00466   return false;
00467 }

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

Definition at line 470 of file CDR_Stream.cpp.

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

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

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

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

Definition at line 496 of file CDR_Stream.cpp.

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

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

00497 {
00498   char *buf = 0;
00499 
00500   if (this->adjust (ACE_CDR::LONGLONG_SIZE, buf) == 0)
00501     {
00502 #if defined (__arm__)
00503       // Convert to Intel format (12345678 => 56781234)
00504       const char *orig = reinterpret_cast<const char *> (x);
00505       char *target = buf;
00506       register ACE_UINT32 x =
00507         *reinterpret_cast<const ACE_UINT32 *> (orig);
00508       register ACE_UINT32 y =
00509         *reinterpret_cast<const ACE_UINT32 *> (orig + 4);
00510       *reinterpret_cast<ACE_UINT32 *> (target) = y;
00511       *reinterpret_cast<ACE_UINT32 *> (target + 4) = x;
00512       return true;
00513 #else
00514 #  if !defined (ACE_ENABLE_SWAP_ON_WRITE)
00515       *reinterpret_cast<ACE_CDR::ULongLong *> (buf) = *x;
00516       return true;
00517 #  else
00518       if (!this->do_byte_swap_)
00519         {
00520           *reinterpret_cast<ACE_CDR::ULongLong *> (buf) = *x;
00521           return true;
00522         }
00523       else
00524         {
00525           ACE_CDR::swap_8 (reinterpret_cast<const char*> (x), buf);
00526           return true;
00527         }
00528 #  endif /* ACE_ENABLE_SWAP_ON_WRITE */
00529 #endif /* !__arm__ */
00530      }
00531 
00532   return false;
00533 }

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 . The elements are assumed to be packed with the right alignment restrictions. It is mostly designed for buffers of the basic types.

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

Definition at line 604 of file CDR_Stream.cpp.

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

Referenced by ACE_WChar_Codeset_Translator::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_octet_array_mb(), write_short_array(), write_ulong_array(), write_ulonglong_array(), write_ushort_array(), and write_wchar_array().

00608 {
00609   if (length == 0)
00610     return true;
00611   char *buf = 0;
00612   if (this->adjust (size * length, align, buf) == 0)
00613     {
00614 #if !defined (ACE_ENABLE_SWAP_ON_WRITE)
00615       ACE_OS::memcpy (buf, x, size*length);
00616       return true;
00617 #else
00618       if (!this->do_byte_swap_ || size == 1)
00619         {
00620           ACE_OS::memcpy (buf, x, size*length);
00621           return true;
00622         }
00623       else
00624         {
00625           const char *source = reinterpret_cast<const char *> (x);
00626           switch (size)
00627             {
00628             case 2:
00629               ACE_CDR::swap_2_array (source, buf, length);
00630               return true;
00631             case 4:
00632               ACE_CDR::swap_4_array (source, buf, length);
00633               return true;
00634             case 8:
00635               ACE_CDR::swap_8_array (source, buf, length);
00636               return true;
00637             case 16:
00638               ACE_CDR::swap_16_array (source, buf, length);
00639               return true;
00640             default:
00641               // TODO: print something?
00642               this->good_bit_ = false;
00643               return false;
00644             }
00645         }
00646 #endif /* ACE_ENABLE_SWAP_ON_WRITE */
00647     }
00648   this->good_bit_ = false;
00649   return false;
00650 }

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

Definition at line 184 of file CDR_Stream.inl.

References ACE_CDR::Boolean, and write_octet().

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

00185 {
00186   return
00187     static_cast<ACE_CDR::Boolean> (
00188       this->write_octet (
00189         x
00190         ? static_cast<ACE_CDR::Octet> (1)
00191         : static_cast<ACE_CDR::Octet> (0)));
00192 }

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

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

Definition at line 677 of file CDR_Stream.cpp.

References ACE_CDR::Boolean, good_bit(), ACE_CDR::ULong, and write_boolean().

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

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

Definition at line 195 of file CDR_Stream.inl.

References ACE_CDR::Char, char_translator_, ACE_CDR::Octet, write_1(), and ACE_Char_Codeset_Translator::write_char().

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

00196 {
00197   if (this->char_translator_ == 0)
00198     {
00199       ACE_CDR::Octet temp = static_cast<ACE_CDR::Octet> (x);
00200       return this->write_1 (&temp);
00201     }
00202   return this->char_translator_->write_char (*this, x);
00203 }

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 and ends at <x + length>. The length is *NOT* stored into the CDR stream.

Definition at line 291 of file CDR_Stream.inl.

References ACE_CDR::Char, char_translator_, ACE_CDR::ULong, write_array(), and ACE_Char_Codeset_Translator::write_char_array().

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

00293 {
00294   if (this->char_translator_ == 0)
00295     return this->write_array (x,
00296                               ACE_CDR::OCTET_SIZE,
00297                               ACE_CDR::OCTET_ALIGN,
00298                               length);
00299   return this->char_translator_->write_char_array (*this, x, length);
00300 }

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

Definition at line 252 of file CDR_Stream.inl.

References write_8().

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

00253 {
00254   void const * const temp = &x;
00255   return this->write_8 (reinterpret_cast<ACE_CDR::ULongLong const *> (temp));
00256 }

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 and ends at <x + length>. The length is *NOT* stored into the CDR stream.

Definition at line 407 of file CDR_Stream.inl.

References ACE_CDR::ULong, and write_array().

00409 {
00410   return this->write_array (x,
00411                             ACE_CDR::LONGLONG_SIZE,
00412                             ACE_CDR::LONGLONG_ALIGN,
00413                             length);
00414 }

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

Definition at line 245 of file CDR_Stream.inl.

References write_4().

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

00246 {
00247   void const * const temp = &x;
00248   return this->write_4 (reinterpret_cast<ACE_CDR::ULong const *> (temp));
00249 }

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 and ends at <x + length>. The length is *NOT* stored into the CDR stream.

Definition at line 396 of file CDR_Stream.inl.

References ACE_CDR::ULong, and write_array().

00398 {
00399   return this->write_array (x,
00400                             ACE_CDR::LONG_SIZE,
00401                             ACE_CDR::LONG_ALIGN,
00402                             length);
00403 }

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

Definition at line 219 of file CDR_Stream.inl.

References ACE_CDR::Long, ACE_CDR::ULong, and write_4().

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

00220 {
00221   ACE_CDR::ULong temp = static_cast<ACE_CDR::ULong> (x);
00222   return this->write_4 (&temp);
00223 }

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 and ends at <x + length>. The length is *NOT* stored into the CDR stream.

Definition at line 356 of file CDR_Stream.inl.

References ACE_CDR::Long, ACE_CDR::ULong, and write_array().

00358 {
00359   return this->write_array (x,
00360                             ACE_CDR::LONG_SIZE,
00361                             ACE_CDR::LONG_ALIGN,
00362                             length);
00363 }

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

Definition at line 259 of file CDR_Stream.inl.

References write_16().

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

00260 {
00261   return this->write_16 (&x);
00262 }

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 and ends at <x + length>. The length is *NOT* stored into the CDR stream.

Definition at line 417 of file CDR_Stream.inl.

References ACE_CDR::ULong, and write_array().

00419 {
00420   return this->write_array (x,
00421                             ACE_CDR::LONGDOUBLE_SIZE,
00422                             ACE_CDR::LONGDOUBLE_ALIGN,
00423                             length);
00424 }

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

Definition at line 232 of file CDR_Stream.inl.

References ACE_CDR::LongLong, and write_8().

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

00233 {
00234   void const * const temp = &x;
00235   return this->write_8 (reinterpret_cast<ACE_CDR::ULongLong const *> (temp));
00236 }

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 and ends at <x + length>. The length is *NOT* stored into the CDR stream.

Definition at line 376 of file CDR_Stream.inl.

References ACE_CDR::LongLong, ACE_CDR::ULong, and write_array().

00378 {
00379   return this->write_array (x,
00380                             ACE_CDR::LONGLONG_SIZE,
00381                             ACE_CDR::LONGLONG_ALIGN,
00382                             length);
00383 }

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

Definition at line 178 of file CDR_Stream.inl.

References ACE_CDR::Octet, and write_1().

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

00179 {
00180   return this->write_1 (&x);
00181 }

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 and ends at <x + length>. The length is *NOT* stored into the CDR stream.

Definition at line 326 of file CDR_Stream.inl.

References ACE_CDR::Octet, ACE_CDR::ULong, and write_array().

Referenced by write_wchar().

00328 {
00329   return this->write_array (x,
00330                             ACE_CDR::OCTET_SIZE,
00331                             ACE_CDR::OCTET_ALIGN,
00332                             length);
00333 }

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

References ACE_BIT_ENABLED, ACE_NEW_RETURN, ACE_Message_Block::cont(), current_alignment_, current_is_writable_, ACE_Message_Block::data_block(), ACE_Data_Block::duplicate(), ACE_Message_Block::end(), ACE_Message_Block::flags(), ACE_Message_Block::length(), length(), memcpy_tradeoff_, ACE_Message_Block::rd_ptr(), ACE_Message_Block::release(), ACE_Message_Block::wr_ptr(), and write_array().

00374 {
00375   // If the buffer is small and it fits in the current message
00376   // block it is be cheaper just to copy the buffer.
00377   for (const ACE_Message_Block* i = mb;
00378        i != 0;
00379        i = i->cont ())
00380     {
00381       size_t const length = i->length ();
00382 
00383       // If the mb does not own its data we are forced to make a copy.
00384       if (ACE_BIT_ENABLED (i->flags (),
00385                            ACE_Message_Block::DONT_DELETE))
00386         {
00387           if (! this->write_array (i->rd_ptr (),
00388                                    ACE_CDR::OCTET_SIZE,
00389                                    ACE_CDR::OCTET_ALIGN,
00390                                    static_cast<ACE_CDR::ULong> (length)))
00391             return (this->good_bit_ = false);
00392           continue;
00393         }
00394 
00395       if (length < this->memcpy_tradeoff_
00396           && this->current_->wr_ptr () + length < this->current_->end ())
00397         {
00398           if (! this->write_array (i->rd_ptr (),
00399                                    ACE_CDR::OCTET_SIZE,
00400                                    ACE_CDR::OCTET_ALIGN,
00401                                    static_cast<ACE_CDR::ULong> (length)))
00402             return (this->good_bit_ = false);
00403           continue;
00404         }
00405 
00406       ACE_Message_Block* cont = 0;
00407       this->good_bit_ = false;
00408       ACE_NEW_RETURN (cont,
00409                       ACE_Message_Block (i->data_block ()->duplicate ()),
00410                       false);
00411       this->good_bit_ = true;
00412 
00413       if (this->current_->cont () != 0)
00414         ACE_Message_Block::release (this->current_->cont ());
00415       cont->rd_ptr (i->rd_ptr ());
00416       cont->wr_ptr (i->wr_ptr ());
00417 
00418       this->current_->cont (cont);
00419       this->current_ = cont;
00420       this->current_is_writable_ = false;
00421 #if !defined (ACE_LACKS_CDR_ALIGNMENT)
00422       this->current_alignment_ =
00423         (this->current_alignment_ + cont->length ()) % ACE_CDR::MAX_ALIGNMENT;
00424 #endif /* ACE_LACKS_CDR_ALIGNMENT */
00425     }
00426 
00427   return true;
00428 }

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

Definition at line 206 of file CDR_Stream.inl.

References ACE_CDR::Short, ACE_CDR::UShort, and write_2().

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

00207 {
00208   ACE_CDR::UShort temp = static_cast<ACE_CDR::UShort> (x);
00209   return this->write_2 (&temp);
00210 }

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 and ends at <x + length>. The length is *NOT* stored into the CDR stream.

Definition at line 336 of file CDR_Stream.inl.

References ACE_CDR::Short, ACE_CDR::ULong, and write_array().

00338 {
00339   return this->write_array (x,
00340                             ACE_CDR::SHORT_SIZE,
00341                             ACE_CDR::SHORT_ALIGN,
00342                             length);
00343 }

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

Definition at line 321 of file CDR_Stream.cpp.

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

00322 {
00323   // @@ Leave this method in here, not the `.i' file so that we don't
00324   //    have to unnecessarily pull in the `ace/SString.h' header.
00325   return this->write_string (static_cast<ACE_CDR::ULong> (x.length ()),
00326                              x.c_str());
00327 }

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

Definition at line 293 of file CDR_Stream.cpp.

References ACE_CDR::Char, char_translator_, ACE_CDR::ULong, write_char(), write_char_array(), ACE_Char_Codeset_Translator::write_string(), and write_ulong().

00295 {
00296   // @@ This is a slight violation of "Optimize for the common case",
00297   // i.e. normally the translator will be 0, but OTOH the code is
00298   // smaller and should be better for the cache ;-) ;-)
00299   if (this->char_translator_ != 0)
00300     return this->char_translator_->write_string (*this, len, x);
00301 
00302   if (len != 0)
00303     {
00304       if (this->write_ulong (len + 1))
00305         return this->write_char_array (x, len + 1);
00306     }
00307   else
00308     {
00309       // Be nice to programmers: treat nulls as empty strings not
00310       // errors. (OMG-IDL supports languages that don't use the C/C++
00311       // notion of null v. empty strings; nulls aren't part of the OMG-IDL
00312       // string model.)
00313       if (this->write_ulong (1))
00314         return this->write_char (0);
00315     }
00316 
00317   return (this->good_bit_ = false);
00318 }

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

References ACE_CDR::Char, ACE_OS::strlen(), and ACE_CDR::ULong.

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

00266 {
00267   if (x)
00268     {
00269       const ACE_CDR::ULong len =
00270         static_cast<ACE_CDR::ULong> (ACE_OS::strlen (x));
00271       return this->write_string (len, x);
00272     }
00273 
00274   return this->write_string (0, 0);
00275 }

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

Definition at line 226 of file CDR_Stream.inl.

References ACE_CDR::ULong, and write_4().

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

00227 {
00228   return this->write_4 (&x);
00229 }

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 and ends at <x + length>. The length is *NOT* stored into the CDR stream.

Definition at line 366 of file CDR_Stream.inl.

References ACE_CDR::ULong, and write_array().

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

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

Definition at line 239 of file CDR_Stream.inl.

References ACE_CDR::ULongLong, and write_8().

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

00240 {
00241   return this->write_8 (&x);
00242 }

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 and ends at <x + length>. The length is *NOT* stored into the CDR stream.

Definition at line 386 of file CDR_Stream.inl.

References ACE_CDR::ULong, ACE_CDR::ULongLong, and write_array().

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

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

Definition at line 213 of file CDR_Stream.inl.

References ACE_CDR::UShort, and write_2().

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

00214 {
00215   return this->write_2 (&x);
00216 }

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 and ends at <x + length>. The length is *NOT* stored into the CDR stream.

Definition at line 346 of file CDR_Stream.inl.

References ACE_CDR::ULong, ACE_CDR::UShort, and write_array().

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

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

Definition at line 232 of file CDR_Stream.cpp.

References ACE_CDR::Octet, ACE_CDR::Short, ACE_CDR::WChar, wchar_maxbytes_, wchar_translator_, write_1(), write_2(), write_4(), write_octet_array(), and ACE_WChar_Codeset_Translator::write_wchar().

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

00233 {
00234   if (this->wchar_translator_ != 0)
00235     return (this->good_bit_ = this->wchar_translator_->write_wchar (*this, x));
00236   if (ACE_OutputCDR::wchar_maxbytes_ == 0)
00237     {
00238       errno = EACCES;
00239       return (this->good_bit_ = false);
00240     }
00241   if (static_cast<ACE_CDR::Short> (major_version_) == 1
00242       && static_cast<ACE_CDR::Short> (minor_version_) == 2)
00243     {
00244       ACE_CDR::Octet len =
00245         static_cast<ACE_CDR::Octet> (ACE_OutputCDR::wchar_maxbytes_);
00246       if (this->write_1 (&len))
00247         {
00248           if (ACE_OutputCDR::wchar_maxbytes_ == sizeof(ACE_CDR::WChar))
00249             return
00250               this->write_octet_array (
00251                                        reinterpret_cast<const ACE_CDR::Octet*> (&x),
00252                                        static_cast<ACE_CDR::ULong> (len));
00253           else
00254             if (ACE_OutputCDR::wchar_maxbytes_ == 2)
00255               {
00256                 ACE_CDR::Short sx = static_cast<ACE_CDR::Short> (x);
00257                 return
00258                   this->write_octet_array (
00259                                            reinterpret_cast<const ACE_CDR::Octet*> (&sx),
00260                                            static_cast<ACE_CDR::ULong> (len));
00261               }
00262             else
00263               {
00264                 ACE_CDR::Octet ox = static_cast<ACE_CDR::Octet> (x);
00265                 return
00266                   this->write_octet_array (
00267                                            reinterpret_cast<const ACE_CDR::Octet*> (&ox),
00268                                            static_cast<ACE_CDR::ULong> (len));
00269               }
00270         }
00271     }
00272   else if (static_cast<ACE_CDR::Short> (minor_version_) == 0)
00273     { // wchar is not allowed with GIOP 1.0.
00274       errno = EINVAL;
00275       return (this->good_bit_ = false);
00276     }
00277   if (ACE_OutputCDR::wchar_maxbytes_ == sizeof (ACE_CDR::WChar))
00278     {
00279       void const * const temp = &x;
00280       return
00281         this->write_4 (reinterpret_cast<const ACE_CDR::ULong *> (temp));
00282     }
00283   else if (ACE_OutputCDR::wchar_maxbytes_ == 2)
00284     {
00285       ACE_CDR::Short sx = static_cast<ACE_CDR::Short> (x);
00286       return this->write_2 (reinterpret_cast<const ACE_CDR::UShort *> (&sx));
00287     }
00288   ACE_CDR::Octet ox = static_cast<ACE_CDR::Octet> (x);
00289   return this->write_1 (reinterpret_cast<const ACE_CDR::Octet *> (&ox));
00290 }

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 and ends at <x + length>. The length is *NOT* stored into the CDR stream.

Definition at line 303 of file CDR_Stream.inl.

References ACE_CDR::Boolean, ACE_CDR::ULong, ACE_CDR::WChar, wchar_maxbytes_, wchar_translator_, write_array(), ACE_WChar_Codeset_Translator::write_wchar_array(), and write_wchar_array_i().

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

00305 {
00306   if (this->wchar_translator_)
00307     return this->wchar_translator_->write_wchar_array (*this, x, length);
00308 
00309   if (ACE_OutputCDR::wchar_maxbytes_ == 0)
00310     {
00311       errno = EACCES;
00312       return (ACE_CDR::Boolean) (this->good_bit_ = false);
00313     }
00314 
00315   if (ACE_OutputCDR::wchar_maxbytes_ == sizeof (ACE_CDR::WChar))
00316     return this->write_array (x,
00317                               sizeof (ACE_CDR::WChar),
00318                               sizeof (ACE_CDR::WChar) == 2
00319                               ? ACE_CDR::SHORT_ALIGN
00320                               : ACE_CDR::LONG_ALIGN,
00321                               length);
00322   return this->write_wchar_array_i (x,length);
00323 }

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

Definition at line 564 of file CDR_Stream.cpp.

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

Referenced by write_wchar_array().

00566 {
00567   if (length == 0)
00568     return true;
00569   char* buf = 0;
00570   size_t const align = (ACE_OutputCDR::wchar_maxbytes_ == 2) ?
00571     ACE_CDR::SHORT_ALIGN :
00572     ACE_CDR::OCTET_ALIGN;
00573 
00574   if (this->adjust (ACE_OutputCDR::wchar_maxbytes_ * length, align, buf) == 0)
00575     {
00576       if (ACE_OutputCDR::wchar_maxbytes_ == 2)
00577         {
00578           ACE_CDR::UShort *sb = reinterpret_cast<ACE_CDR::UShort *> (buf);
00579           for (size_t i = 0; i < length; ++i)
00580 #if !defined (ACE_ENABLE_SWAP_ON_WRITE)
00581             sb[i] = static_cast<ACE_CDR::UShort> (x[i]);
00582 #else
00583               if (!this->do_byte_swap_)
00584               sb[i] = static_cast<ACE_CDR::UShort> (x[i]);
00585             else
00586               {
00587                 ACE_CDR::UShort sx = static_cast<ACE_CDR::UShort> (x[i]);
00588                 ACE_CDR::swap_2 (reinterpret_cast<char *> (&sx), &buf[i * 2]);
00589               }
00590 #endif /* ACE_ENABLE_SWAP_ON_WRITE */
00591         }
00592       else
00593         {
00594           for (size_t i = 0; i < length; ++i)
00595             buf[i] = static_cast<char> (x[i]);
00596         }
00597       return this->good_bit_;
00598     }
00599   return false;
00600 }

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

Definition at line 330 of file CDR_Stream.cpp.

References ACE_CDR::ULong, ACE_CDR::WChar, wchar_maxbytes_, wchar_translator_, write_ulong(), write_wchar(), write_wchar_array(), and ACE_WChar_Codeset_Translator::write_wstring().

00332 {
00333   // @@ This is a slight violation of "Optimize for the common case",
00334   // i.e. normally the translator will be 0, but OTOH the code is
00335   // smaller and should be better for the cache ;-) ;-)
00336   // What do we do for GIOP 1.2???
00337   if (this->wchar_translator_ != 0)
00338     return this->wchar_translator_->write_wstring (*this, len, x);
00339   if (ACE_OutputCDR::wchar_maxbytes_ == 0)
00340     {
00341       errno = EACCES;
00342       return (this->good_bit_ = false);
00343     }
00344 
00345   if (static_cast<ACE_CDR::Short> (this->major_version_) == 1
00346       && static_cast<ACE_CDR::Short> (this->minor_version_) == 2)
00347     {
00348       if (x != 0)
00349         {
00350           //In GIOP 1.2 the length field contains the number of bytes
00351           //the wstring occupies rather than number of wchars
00352           //Taking sizeof might not be a good way! This is a temporary fix.
00353           if (this->write_ulong (ACE_OutputCDR::wchar_maxbytes_ * len))
00354             return this->write_wchar_array (x, len);
00355         }
00356       else
00357         //In GIOP 1.2 zero length wstrings are legal
00358         return this->write_ulong (0);
00359     }
00360 
00361   else
00362     if (x != 0)
00363       {
00364         if (this->write_ulong (len + 1))
00365           return this->write_wchar_array (x, len + 1);
00366       }
00367     else if (this->write_ulong (1))
00368       return this->write_wchar (0);
00369   return (this->good_bit_ = false);
00370 }

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

Definition at line 278 of file CDR_Stream.inl.

References ACE_OS::strlen(), ACE_CDR::ULong, and ACE_CDR::WChar.

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

00279 {
00280   if (x)
00281     {
00282       ACE_CDR::ULong len =
00283         static_cast<ACE_CDR::ULong> (ACE_OS::strlen (x));
00284       return this->write_wstring (len, x);
00285     }
00286 
00287   return this->write_wstring (0, 0);
00288 }


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

friend class ACE_InputCDR [friend]
 

Definition at line 98 of file CDR_Stream.h.

friend class ACE_WChar_Codeset_Translator [friend]
 

Definition at line 97 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 519 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 474 of file CDR_Stream.h.

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

Referenced by adjust(), 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 505 of file CDR_Stream.h.

Referenced by do_byte_swap(), replace(), reset_byte_order(), write_16(), write_2(), write_4(), write_8(), write_array(), and write_wchar_array_i().

bool ACE_OutputCDR::good_bit_ [private]
 

Set to false when an error ocurrs.

Definition at line 508 of file CDR_Stream.h.

Referenced by ACE_WChar_Codeset_Translator::good_bit(), and ACE_Char_Codeset_Translator::good_bit().

ACE_CDR::Octet ACE_OutputCDR::major_version_ [protected]
 

GIOP version information.

Definition at line 515 of file CDR_Stream.h.

Referenced by ACE_WChar_Codeset_Translator::major_version(), and ACE_Char_Codeset_Translator::major_version().

size_t const ACE_OutputCDR::memcpy_tradeoff_ [private]
 

Break-even point for copying.

Definition at line 511 of file CDR_Stream.h.

Referenced by write_octet_array_mb().

ACE_CDR::Octet ACE_OutputCDR::minor_version_ [protected]
 

Definition at line 516 of file CDR_Stream.h.

Referenced by ACE_WChar_Codeset_Translator::minor_version(), and ACE_Char_Codeset_Translator::minor_version().

ACE_Message_Block ACE_OutputCDR::start_ [private]
 

The start of the chain of message blocks.

Definition at line 471 of file CDR_Stream.h.

Referenced by ACE_OutputCDR(), begin(), buffer(), consolidate(), find(), 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 17 of file CDR_Stream.cpp.

Referenced by 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 520 of file CDR_Stream.h.

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


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