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>
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_Block * | begin (void) const |
const ACE_Message_Block * | end (void) const |
Return the last message in the chain that is is use. | |
const ACE_Message_Block * | current (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_Translator * | char_translator (void) const |
Access the codeset translators. They can be null! | |
ACE_WChar_Codeset_Translator * | wchar_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 | |
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) |
Placeholder/replace operations | |
Facilitates writing a placeholder into a CDR stream to be replaced later with a different value.
| |
char * | write_long_placeholder (void) |
char * | write_short_placeholder (void) |
ACE_CDR::Boolean | replace (ACE_CDR::Long x, char *loc) |
ACE_CDR::Boolean | replace (ACE_CDR::Short x, char *loc) |
ACE_CDR::Boolean | append_boolean (ACE_InputCDR &) |
ACE_CDR::Boolean | append_char (ACE_InputCDR &) |
ACE_CDR::Boolean | append_wchar (ACE_InputCDR &) |
ACE_CDR::Boolean | append_octet (ACE_InputCDR &) |
ACE_CDR::Boolean | append_short (ACE_InputCDR &) |
ACE_CDR::Boolean | append_ushort (ACE_InputCDR &) |
ACE_CDR::Boolean | append_long (ACE_InputCDR &) |
ACE_CDR::Boolean | append_ulong (ACE_InputCDR &) |
ACE_CDR::Boolean | append_longlong (ACE_InputCDR &) |
ACE_CDR::Boolean | append_ulonglong (ACE_InputCDR &) |
ACE_CDR::Boolean | append_float (ACE_InputCDR &) |
ACE_CDR::Boolean | append_double (ACE_InputCDR &) |
ACE_CDR::Boolean | append_longdouble (ACE_InputCDR &) |
ACE_CDR::Boolean | append_wstring (ACE_InputCDR &) |
ACE_CDR::Boolean | append_string (ACE_InputCDR &) |
Static Public Member Functions | |
static void | wchar_maxbytes (size_t max_bytes) |
static size_t | wchar_maxbytes (void) |
access the serialized size of wchars. | |
Protected Attributes | |
ACE_CDR::Octet | major_version_ |
GIOP version information. | |
ACE_CDR::Octet | minor_version_ |
ACE_Char_Codeset_Translator * | char_translator_ |
If not nil, invoke for translation of character and string data. | |
ACE_WChar_Codeset_Translator * | wchar_translator_ |
Static Protected Attributes | |
static size_t | wchar_maxbytes_ |
Private Member Functions | |
ACE_Message_Block * | find (char *loc) |
ACE_OutputCDR (const ACE_OutputCDR &rhs) | |
disallow copying... | |
ACE_OutputCDR & | operator= (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_Block * | current_ |
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 |
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.
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.
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. |
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.
: start_ (size, ACE_Message_Block::MB_DATA, 0, data, buffer_allocator, 0, 0, ACE_Time_Value::zero, ACE_Time_Value::max_time, data_block_allocator, message_block_allocator), #if !defined (ACE_LACKS_CDR_ALIGNMENT) current_alignment_ (0), #endif /* ACE_LACKS_CDR_ALIGNMENT */ current_is_writable_ (true), do_byte_swap_ (byte_order != ACE_CDR_BYTE_ORDER), good_bit_ (true), memcpy_tradeoff_ (memcpy_tradeoff), major_version_ (major_version), minor_version_ (minor_version), char_translator_ (0), wchar_translator_ (0) { // We cannot trust the buffer to be properly aligned ACE_CDR::mb_align (&this->start_); this->current_ = &this->start_; #if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1) ACE_NEW (this->monitor_, ACE::Monitor_Control::Size_Monitor); this->monitor_->receive (this->total_length ()); #endif /* ACE_HAS_MONITOR_POINTS==1 */ }
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.
: start_ (data_block, ACE_Message_Block::DONT_DELETE, message_block_allocator), #if !defined (ACE_LACKS_CDR_ALIGNMENT) current_alignment_ (0), #endif /* ACE_LACKS_CDR_ALIGNMENT */ current_is_writable_ (true), do_byte_swap_ (byte_order != ACE_CDR_BYTE_ORDER), good_bit_ (true), memcpy_tradeoff_ (memcpy_tradeoff), major_version_ (major_version), minor_version_ (minor_version), char_translator_ (0), wchar_translator_ (0) { // We cannot trust the buffer to be properly aligned ACE_CDR::mb_align (&this->start_); this->current_ = &this->start_; #if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1) ACE_NEW (this->monitor_, ACE::Monitor_Control::Size_Monitor); this->monitor_->receive (this->total_length ()); #endif /* ACE_HAS_MONITOR_POINTS==1 */ }
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.
: start_ (data->data_block ()->duplicate ()), #if !defined (ACE_LACKS_CDR_ALIGNMENT) current_alignment_ (0), #endif /* ACE_LACKS_CDR_ALIGNMENT */ current_is_writable_ (true), do_byte_swap_ (byte_order != ACE_CDR_BYTE_ORDER), good_bit_ (true), memcpy_tradeoff_ (memcpy_tradeoff), major_version_ (major_version), minor_version_ (minor_version), char_translator_ (0), wchar_translator_ (0) { // We cannot trust the buffer to be properly aligned ACE_CDR::mb_align (&this->start_); this->current_ = &this->start_; #if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1) ACE_NEW (this->monitor_, ACE::Monitor_Control::Size_Monitor); this->monitor_->receive (this->total_length ()); #endif /* ACE_HAS_MONITOR_POINTS==1 */ }
ACE_OutputCDR::~ACE_OutputCDR | ( | void | ) | [inline] |
destructor
Definition at line 142 of file CDR_Stream.inl.
ACE_OutputCDR::ACE_OutputCDR | ( | const ACE_OutputCDR & | rhs | ) | [private] |
disallow copying...
int ACE_OutputCDR::adjust | ( | size_t | size, | |
char *& | buf | |||
) | [inline] |
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.
int ACE_OutputCDR::adjust | ( | size_t | size, | |
size_t | align, | |||
char *& | buf | |||
) | [inline] |
As above, but now the size and alignment requirements may be different.
Definition at line 442 of file CDR_Stream.inl.
{ if (!this->current_is_writable_) return this->grow_and_adjust (size, align, buf); #if !defined (ACE_LACKS_CDR_ALIGNMENT) size_t const offset = ACE_align_binary (this->current_alignment_, align) - this->current_alignment_; buf = this->current_->wr_ptr () + offset; #else buf = this->current_->wr_ptr (); #endif /* ACE_LACKS_CDR_ALIGNMENT */ char * const end = buf + size; if (end <= this->current_->end () && end >= buf) { #if !defined (ACE_LACKS_CDR_ALIGNMENT) this->current_alignment_ += offset + size; #endif /* ACE_LACKS_CDR_ALIGNMENT */ this->current_->wr_ptr (end); #if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1) this->monitor_->receive (this->total_length ()); #endif /* ACE_HAS_MONITOR_POINTS==1 */ return 0; } return this->grow_and_adjust (size, align, buf); }
int ACE_OutputCDR::align_write_ptr | ( | size_t | alignment | ) | [inline] |
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.
{ #if !defined (ACE_LACKS_CDR_ALIGNMENT) char *dummy; return this->adjust (0, alignment, dummy); #else ACE_UNUSED_ARG (alignment); // A return value of -1 from this function is used // to indicate failure, returning 0 return 0; #endif /* ACE_LACKS_CDR_ALIGNMENT */ }
ACE_CDR::Boolean ACE_OutputCDR::append_boolean | ( | ACE_InputCDR & | stream | ) | [inline] |
Return 0 on failure and 1 on success.
Definition at line 1362 of file CDR_Stream.inl.
{ ACE_CDR::Boolean x; return stream.read_boolean (x) ? this->write_boolean (x) : false; }
ACE_CDR::Boolean ACE_OutputCDR::append_char | ( | ACE_InputCDR & | stream | ) | [inline] |
Return 0 on failure and 1 on success.
Definition at line 1369 of file CDR_Stream.inl.
{ ACE_CDR::Char x; return stream.read_char (x) ? this->write_char (x) : false; }
ACE_CDR::Boolean ACE_OutputCDR::append_double | ( | ACE_InputCDR & | stream | ) | [inline] |
Return 0 on failure and 1 on success.
Definition at line 1439 of file CDR_Stream.inl.
{ ACE_CDR::Double x; return stream.read_double (x) ? this->write_double (x) : false; }
ACE_CDR::Boolean ACE_OutputCDR::append_float | ( | ACE_InputCDR & | stream | ) | [inline] |
Return 0 on failure and 1 on success.
Definition at line 1432 of file CDR_Stream.inl.
{ ACE_CDR::Float x; return stream.read_float (x) ? this->write_float (x) : false; }
ACE_CDR::Boolean ACE_OutputCDR::append_long | ( | ACE_InputCDR & | stream | ) | [inline] |
Return 0 on failure and 1 on success.
Definition at line 1404 of file CDR_Stream.inl.
{ ACE_CDR::Long x; return stream.read_long (x) ? this->write_long (x) : false; }
ACE_CDR::Boolean ACE_OutputCDR::append_longdouble | ( | ACE_InputCDR & | stream | ) | [inline] |
Return 0 on failure and 1 on success.
Definition at line 1446 of file CDR_Stream.inl.
{ ACE_CDR::LongDouble x; return stream.read_longdouble (x) ? this->write_longdouble (x) : false; }
ACE_CDR::Boolean ACE_OutputCDR::append_longlong | ( | ACE_InputCDR & | stream | ) | [inline] |
Return 0 on failure and 1 on success.
Definition at line 1418 of file CDR_Stream.inl.
{ ACE_CDR::LongLong x; return stream.read_longlong (x) ? this->write_longlong (x) : false; }
ACE_CDR::Boolean ACE_OutputCDR::append_octet | ( | ACE_InputCDR & | stream | ) | [inline] |
Return 0 on failure and 1 on success.
Definition at line 1383 of file CDR_Stream.inl.
{ ACE_CDR::Octet x; return stream.read_octet (x) ? this->write_octet (x) : false; }
ACE_CDR::Boolean ACE_OutputCDR::append_short | ( | ACE_InputCDR & | stream | ) | [inline] |
Return 0 on failure and 1 on success.
Definition at line 1390 of file CDR_Stream.inl.
{ ACE_CDR::Short x; return stream.read_short (x) ? this->write_short (x) : false; }
ACE_CDR::Boolean ACE_OutputCDR::append_string | ( | ACE_InputCDR & | stream | ) | [inline] |
Return 0 on failure and 1 on success.
Definition at line 1453 of file CDR_Stream.inl.
{ ACE_CDR::Char *x = 0; ACE_CDR::Boolean const flag = (stream.read_string (x) ? this->write_string (x) : false); delete [] x; return flag; }
ACE_CDR::Boolean ACE_OutputCDR::append_ulong | ( | ACE_InputCDR & | stream | ) | [inline] |
Return 0 on failure and 1 on success.
Definition at line 1411 of file CDR_Stream.inl.
{ ACE_CDR::ULong x; return stream.read_ulong (x) ? this->write_ulong (x) : false; }
ACE_CDR::Boolean ACE_OutputCDR::append_ulonglong | ( | ACE_InputCDR & | stream | ) | [inline] |
Return 0 on failure and 1 on success.
Definition at line 1425 of file CDR_Stream.inl.
{ ACE_CDR::ULongLong x; return stream.read_ulonglong (x) ? this->write_ulonglong (x) : false; }
ACE_CDR::Boolean ACE_OutputCDR::append_ushort | ( | ACE_InputCDR & | stream | ) | [inline] |
Return 0 on failure and 1 on success.
Definition at line 1397 of file CDR_Stream.inl.
{ ACE_CDR::UShort x; return stream.read_ushort (x) ? this->write_ushort (x) : false; }
ACE_CDR::Boolean ACE_OutputCDR::append_wchar | ( | ACE_InputCDR & | stream | ) | [inline] |
Return 0 on failure and 1 on success.
Definition at line 1376 of file CDR_Stream.inl.
{ ACE_CDR::WChar x; return stream.read_wchar (x) ? this->write_wchar (x) : false; }
ACE_CDR::Boolean ACE_OutputCDR::append_wstring | ( | ACE_InputCDR & | stream | ) | [inline] |
Return 0 on failure and 1 on success.
Definition at line 1463 of file CDR_Stream.inl.
{ ACE_CDR::WChar *x = 0; ACE_CDR::Boolean const flag = (stream.read_wstring (x) ? this->write_wstring (x) : false); delete [] x; return flag; }
const ACE_Message_Block * ACE_OutputCDR::begin | ( | void | ) | const [inline] |
Return the start of the message block chain for this CDR stream.
Definition at line 501 of file CDR_Stream.inl.
{ return &this->start_; }
const char * ACE_OutputCDR::buffer | ( | void | ) | const [inline] |
Access the underlying buffer (read only).
Definition at line 525 of file CDR_Stream.inl.
int ACE_OutputCDR::byte_order | ( | void | ) | const [inline] |
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.
{ if (this->do_byte_swap ()) return !ACE_CDR_BYTE_ORDER; else return ACE_CDR_BYTE_ORDER; }
void ACE_OutputCDR::char_translator | ( | ACE_Char_Codeset_Translator * | ctran | ) | [inline] |
Set the char codeset translator.
Definition at line 605 of file CDR_Stream.inl.
{ this->char_translator_ = ctran; }
ACE_Char_Codeset_Translator * ACE_OutputCDR::char_translator | ( | void | ) | const [inline] |
Access the codeset translators. They can be null!
Definition at line 593 of file CDR_Stream.inl.
{ return this->char_translator_; }
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.
Definition at line 775 of file CDR_Stream.cpp.
{ // Optimize by only doing something if we need to if (this->current_ != &this->start_) { // Set the number of bytes in the top-level block, reallocating // if necessary. The rd_ptr and wr_ptr remain at the original offsets // into the buffer, even if it is reallocated. // Return an error if the allocation failed. size_t const newsize = ACE_CDR::first_size (this->total_length () + ACE_CDR::MAX_ALIGNMENT); if (this->start_.size (newsize) < 0) { return -1; } // Consolidate the chain into the first block. NOTE that // ACE_CDR::consolidate can not be used since we don't want to // overwrite what is already in the first block. We just append it since // the read and write pointers weren't affected by the resizing above. // We also don't have to worry about alignment since the start block is // already aligned. // NOTE also we know there is a continuation since we checked for it // above. There is therefore no reason to check for a 0 continuation // field here. ACE_Message_Block *cont = this->start_.cont (); for (const ACE_Message_Block* i = cont; i != 0; i = i->cont ()) { this->start_.copy (i->rd_ptr (), i->length ()); } // Release the old blocks that were consolidated and reset the // current_ and current_is_writable_ to reflect the single used block. ACE_Message_Block::release (cont); this->start_.cont (0); this->current_ = &this->start_; this->current_is_writable_ = true; } return 0; }
const ACE_Message_Block * ACE_OutputCDR::current | ( | void | ) | const [inline] |
Return the <current_> message block in chain.
Definition at line 513 of file CDR_Stream.inl.
{ return this->current_; }
void ACE_OutputCDR::current_alignment | ( | size_t | current_alignment | ) | [inline] |
Definition at line 569 of file CDR_Stream.inl.
{ #if !defined (ACE_LACKS_CDR_ALIGNMENT) this->current_alignment_ = current_alignment; #else ACE_UNUSED_ARG (current_alignment); #endif /* ACE_LACKS_CDR_ALIGNMENT */ }
size_t ACE_OutputCDR::current_alignment | ( | void | ) | const [inline] |
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.
{ #if !defined (ACE_LACKS_CDR_ALIGNMENT) return this->current_alignment_; #else // Default value set to 0 return 0; #endif /* ACE_LACKS_CDR_ALIGNMENT */ }
bool ACE_OutputCDR::do_byte_swap | ( | void | ) | const [inline] |
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.
{ return this->do_byte_swap_; }
const ACE_Message_Block * ACE_OutputCDR::end | ( | void | ) | const [inline] |
Return the last message in the chain that is is use.
Definition at line 507 of file CDR_Stream.inl.
ACE_Message_Block * ACE_OutputCDR::find | ( | char * | loc | ) | [private] |
Definition at line 820 of file CDR_Stream.cpp.
{ ACE_Message_Block* mb = 0; for (mb = &this->start_; mb != 0; mb = mb->cont ()) { if (loc <= mb->wr_ptr () && loc >= mb->rd_ptr ()) { break; } } return mb; }
void ACE_OutputCDR::get_version | ( | ACE_CDR::Octet & | major, | |
ACE_CDR::Octet & | minor | |||
) | [inline] |
Set the underlying GIOP version..
Definition at line 493 of file CDR_Stream.inl.
{ major = this->major_version_; minor = this->minor_version_; }
bool ACE_OutputCDR::good_bit | ( | void | ) | const [inline] |
Returns false
if an error has ocurred.
Definition at line 436 of file CDR_Stream.inl.
{ return this->good_bit_; }
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.
{ if (!this->current_is_writable_ || this->current_->cont () == 0 || this->current_->cont ()->size () < size + ACE_CDR::MAX_ALIGNMENT) { // Calculate the new buffer's length; if growing for encode, we // don't grow in "small" chunks because of the cost. size_t cursize = this->current_->size (); if (this->current_->cont () != 0) cursize = this->current_->cont ()->size (); size_t minsize = size; #if !defined (ACE_LACKS_CDR_ALIGNMENT) minsize += ACE_CDR::MAX_ALIGNMENT; #endif /* ACE_LACKS_CDR_ALIGNMENT */ // Make sure that there is enough room for <minsize> bytes, but // also make it bigger than whatever our current size is. if (minsize < cursize) minsize = cursize; size_t const newsize = ACE_CDR::next_size (minsize); this->good_bit_ = false; ACE_Message_Block* tmp = 0; ACE_NEW_RETURN (tmp, ACE_Message_Block (newsize, ACE_Message_Block::MB_DATA, 0, 0, this->current_->data_block ()->allocator_strategy (), 0, 0, ACE_Time_Value::zero, ACE_Time_Value::max_time, this->current_->data_block ()->data_block_allocator ()), -1); // Message block initialization may fail while the construction // succeds. Since as a matter of policy, ACE may throw no // exceptions, we have to do a separate check like this. if (tmp != 0 && tmp->size () < newsize) { delete tmp; errno = ENOMEM; return -1; } this->good_bit_ = true; #if !defined (ACE_LACKS_CDR_ALIGNMENT) // The new block must start with the same alignment as the // previous block finished. ptrdiff_t const tmpalign = reinterpret_cast<ptrdiff_t> (tmp->rd_ptr ()) % ACE_CDR::MAX_ALIGNMENT; ptrdiff_t const curalign = static_cast<ptrdiff_t> (this->current_alignment_) % ACE_CDR::MAX_ALIGNMENT; ptrdiff_t offset = curalign - tmpalign; if (offset < 0) offset += ACE_CDR::MAX_ALIGNMENT; tmp->rd_ptr (static_cast<size_t> (offset)); tmp->wr_ptr (tmp->rd_ptr ()); #endif /* ACE_LACKS_CDR_ALIGNMENT */ // grow the chain and set the current block. tmp->cont (this->current_->cont ()); this->current_->cont (tmp); } this->current_ = this->current_->cont (); this->current_is_writable_ = true; return this->adjust (size, align, buf); }
size_t ACE_OutputCDR::length | ( | void | ) | const [inline] |
Return the size of first message block in the block chain.
Definition at line 531 of file CDR_Stream.inl.
ACE_OutputCDR& ACE_OutputCDR::operator= | ( | const ACE_OutputCDR & | rhs | ) | [private] |
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.
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. |
Definition at line 729 of file CDR_Stream.cpp.
{ if (this->find (loc) == 0) return false; #if !defined (ACE_ENABLE_SWAP_ON_WRITE) *reinterpret_cast<ACE_CDR::Long*> (loc) = x; #else if (!this->do_byte_swap_) { *reinterpret_cast<ACE_CDR::Long *> (loc) = x; } else { ACE_CDR::swap_4 (reinterpret_cast<const char*> (&x), loc); } #endif /* ACE_ENABLE_SWAP_ON_WRITE */ return true; }
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.
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.
{ if (this->find (loc) == 0) return false; #if !defined (ACE_ENABLE_SWAP_ON_WRITE) *reinterpret_cast<ACE_CDR::Short*> (loc) = x; #else if (!this->do_byte_swap_) { *reinterpret_cast<ACE_CDR::Short *> (loc) = x; } else { ACE_CDR::swap_2 (reinterpret_cast<const char*> (&x), loc); } #endif /* ACE_ENABLE_SWAP_ON_WRITE */ return true; }
void ACE_OutputCDR::reset | ( | void | ) | [inline] |
Reuse the CDR stream to write on the old buffer.
Definition at line 158 of file CDR_Stream.inl.
{ this->current_ = &this->start_; this->current_is_writable_ = true; ACE_CDR::mb_align (&this->start_); #if !defined (ACE_LACKS_CDR_ALIGNMENT) this->current_alignment_ = 0; #endif /* ACE_LACKS_CDR_ALIGNMENT */ // It is tempting not to remove the memory, but we need to do so to // release any potential user buffers chained in the continuation // field. ACE_Message_Block * const cont = this->start_.cont (); if (cont) { ACE_Message_Block::release (cont); this->start_.cont (0); } #if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1) this->monitor_->receive (this->start_.total_size ()); #endif /* ACE_HAS_MONITOR_POINTS==1 */ }
void ACE_OutputCDR::reset_byte_order | ( | int | byte_order | ) | [inline] |
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.
{ this->do_byte_swap_ = (byte_order != ACE_CDR_BYTE_ORDER); }
void ACE_OutputCDR::set_version | ( | ACE_CDR::Octet | major, | |
ACE_CDR::Octet | minor | |||
) | [inline] |
set GIOP version info
Definition at line 486 of file CDR_Stream.inl.
{ this->major_version_ = major; this->minor_version_ = minor; }
size_t ACE_OutputCDR::total_length | ( | void | ) | const [inline] |
Add the length of each message block in the chain.
Definition at line 519 of file CDR_Stream.inl.
{ return ACE_CDR::total_length (this->begin (), this->end ()); }
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.
{ ACE_OutputCDR::wchar_maxbytes_ = maxbytes; }
size_t ACE_OutputCDR::wchar_maxbytes | ( | void | ) | [static] |
access the serialized size of wchars.
Definition at line 173 of file CDR_Stream.cpp.
{ return ACE_OutputCDR::wchar_maxbytes_; }
void ACE_OutputCDR::wchar_translator | ( | ACE_WChar_Codeset_Translator * | wctran | ) | [inline] |
Set the wchar codeset translator.
Definition at line 611 of file CDR_Stream.inl.
{ this->wchar_translator_ = wctran; }
ACE_WChar_Codeset_Translator * ACE_OutputCDR::wchar_translator | ( | void | ) | const [inline] |
Definition at line 599 of file CDR_Stream.inl.
{ return this->wchar_translator_; }
ACE_CDR::Boolean ACE_OutputCDR::write_1 | ( | const ACE_CDR::Octet * | x | ) | [private] |
Definition at line 465 of file CDR_Stream.cpp.
{ char *buf = 0; if (this->adjust (1, buf) == 0) { *reinterpret_cast<ACE_CDR::Octet*> (buf) = *x; return true; } return false; }
ACE_CDR::Boolean ACE_OutputCDR::write_16 | ( | const ACE_CDR::LongDouble * | x | ) | [private] |
Definition at line 570 of file CDR_Stream.cpp.
{ char* buf = 0; if (this->adjust (ACE_CDR::LONGDOUBLE_SIZE, ACE_CDR::LONGDOUBLE_ALIGN, buf) == 0) { #if !defined (ACE_ENABLE_SWAP_ON_WRITE) *reinterpret_cast<ACE_CDR::LongDouble*> (buf) = *x; return 1; #else if (!this->do_byte_swap_) { *reinterpret_cast<ACE_CDR::LongDouble *> (buf) = *x; return true; } else { ACE_CDR::swap_16 (reinterpret_cast<const char*> (x), buf); return true; } #endif /* ACE_ENABLE_SWAP_ON_WRITE */ } return false; }
ACE_CDR::Boolean ACE_OutputCDR::write_2 | ( | const ACE_CDR::UShort * | x | ) | [private] |
Definition at line 478 of file CDR_Stream.cpp.
{ char *buf = 0; if (this->adjust (ACE_CDR::SHORT_SIZE, buf) == 0) { #if !defined (ACE_ENABLE_SWAP_ON_WRITE) *reinterpret_cast<ACE_CDR::UShort*> (buf) = *x; return true; #else if (!this->do_byte_swap_) { *reinterpret_cast<ACE_CDR::UShort *> (buf) = *x; return true; } else { ACE_CDR::swap_2 (reinterpret_cast<const char*> (x), buf); return true; } #endif /* ACE_ENABLE_SWAP_ON_WRITE */ } return false; }
ACE_CDR::Boolean ACE_OutputCDR::write_4 | ( | const ACE_CDR::ULong * | x | ) | [private] |
Definition at line 504 of file CDR_Stream.cpp.
{ char *buf = 0; if (this->adjust (ACE_CDR::LONG_SIZE, buf) == 0) { #if !defined (ACE_ENABLE_SWAP_ON_WRITE) *reinterpret_cast<ACE_CDR::ULong*> (buf) = *x; return true; #else if (!this->do_byte_swap_) { *reinterpret_cast<ACE_CDR::ULong *> (buf) = *x; return true; } else { ACE_CDR::swap_4 (reinterpret_cast<const char*> (x), buf); return true; } #endif /* ACE_ENABLE_SWAP_ON_WRITE */ } return false; }
ACE_CDR::Boolean ACE_OutputCDR::write_8 | ( | const ACE_CDR::ULongLong * | x | ) | [private] |
Definition at line 530 of file CDR_Stream.cpp.
{ char *buf = 0; if (this->adjust (ACE_CDR::LONGLONG_SIZE, buf) == 0) { #if defined (__arm__) && !defined (ACE_HAS_IPHONE) // Convert to Intel format (12345678 => 56781234) const char *orig = reinterpret_cast<const char *> (x); char *target = buf; register ACE_UINT32 x = *reinterpret_cast<const ACE_UINT32 *> (orig); register ACE_UINT32 y = *reinterpret_cast<const ACE_UINT32 *> (orig + 4); *reinterpret_cast<ACE_UINT32 *> (target) = y; *reinterpret_cast<ACE_UINT32 *> (target + 4) = x; return true; #else # if !defined (ACE_ENABLE_SWAP_ON_WRITE) *reinterpret_cast<ACE_CDR::ULongLong *> (buf) = *x; return true; # else if (!this->do_byte_swap_) { *reinterpret_cast<ACE_CDR::ULongLong *> (buf) = *x; return true; } else { ACE_CDR::swap_8 (reinterpret_cast<const char*> (x), buf); return true; } # endif /* ACE_ENABLE_SWAP_ON_WRITE */ #endif /* !__arm__ */ } return false; }
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.
{ if (length == 0) return true; char *buf = 0; if (this->adjust (size * length, align, buf) == 0) { #if !defined (ACE_ENABLE_SWAP_ON_WRITE) ACE_OS::memcpy (buf, x, size*length); return true; #else if (!this->do_byte_swap_ || size == 1) { ACE_OS::memcpy (buf, x, size*length); return true; } else { const char *source = reinterpret_cast<const char *> (x); switch (size) { case 2: ACE_CDR::swap_2_array (source, buf, length); return true; case 4: ACE_CDR::swap_4_array (source, buf, length); return true; case 8: ACE_CDR::swap_8_array (source, buf, length); return true; case 16: ACE_CDR::swap_16_array (source, buf, length); return true; default: // TODO: print something? this->good_bit_ = false; return false; } } #endif /* ACE_ENABLE_SWAP_ON_WRITE */ } this->good_bit_ = false; return false; }
ACE_CDR::Boolean ACE_OutputCDR::write_boolean | ( | ACE_CDR::Boolean | x | ) | [inline] |
For string we offer methods that accept a precomputed length.
Definition at line 193 of file CDR_Stream.inl.
{ return static_cast<ACE_CDR::Boolean> ( this->write_octet ( x ? static_cast<ACE_CDR::Octet> (1) : static_cast<ACE_CDR::Octet> (0))); }
ACE_CDR::Boolean ACE_OutputCDR::write_boolean_array | ( | const ACE_CDR::Boolean * | x, | |
ACE_CDR::ULong | length | |||
) |
Definition at line 688 of file CDR_Stream.cpp.
{ // It is hard to optimize this, the spec requires that on the wire // booleans be represented as a byte with value 0 or 1, but in // memory it is possible (though very unlikely) that a boolean has // a non-zero value (different from 1). // We resort to a simple loop. ACE_CDR::Boolean const * const end = x + length; for (ACE_CDR::Boolean const * i = x; i != end && this->good_bit (); ++i) (void) this->write_boolean (*i); return this->good_bit (); }
ACE_CDR::Boolean ACE_OutputCDR::write_char | ( | ACE_CDR::Char | x | ) | [inline] |
For string we offer methods that accept a precomputed length.
Definition at line 204 of file CDR_Stream.inl.
{ if (this->char_translator_ == 0) { ACE_CDR::Octet temp = static_cast<ACE_CDR::Octet> (x); return this->write_1 (&temp); } return this->char_translator_->write_char (*this, x); }
ACE_CDR::Boolean ACE_OutputCDR::write_char_array | ( | const ACE_CDR::Char * | x, | |
ACE_CDR::ULong | length | |||
) | [inline] |
Definition at line 300 of file CDR_Stream.inl.
{ if (this->char_translator_ == 0) return this->write_array (x, ACE_CDR::OCTET_SIZE, ACE_CDR::OCTET_ALIGN, length); return this->char_translator_->write_char_array (*this, x, length); }
ACE_CDR::Boolean ACE_OutputCDR::write_double | ( | const ACE_CDR::Double & | x | ) | [inline] |
For string we offer methods that accept a precomputed length.
Definition at line 261 of file CDR_Stream.inl.
{ void const * const temp = &x; return this->write_8 (reinterpret_cast<ACE_CDR::ULongLong const *> (temp)); }
ACE_CDR::Boolean ACE_OutputCDR::write_double_array | ( | const ACE_CDR::Double * | x, | |
ACE_CDR::ULong | length | |||
) | [inline] |
Definition at line 416 of file CDR_Stream.inl.
{ return this->write_array (x, ACE_CDR::LONGLONG_SIZE, ACE_CDR::LONGLONG_ALIGN, length); }
ACE_CDR::Boolean ACE_OutputCDR::write_float | ( | ACE_CDR::Float | x | ) | [inline] |
For string we offer methods that accept a precomputed length.
Definition at line 254 of file CDR_Stream.inl.
{ void const * const temp = &x; return this->write_4 (reinterpret_cast<ACE_CDR::ULong const *> (temp)); }
ACE_CDR::Boolean ACE_OutputCDR::write_float_array | ( | const ACE_CDR::Float * | x, | |
ACE_CDR::ULong | length | |||
) | [inline] |
Definition at line 405 of file CDR_Stream.inl.
{ return this->write_array (x, ACE_CDR::LONG_SIZE, ACE_CDR::LONG_ALIGN, length); }
ACE_CDR::Boolean ACE_OutputCDR::write_long | ( | ACE_CDR::Long | x | ) | [inline] |
For string we offer methods that accept a precomputed length.
Definition at line 228 of file CDR_Stream.inl.
{ ACE_CDR::ULong temp = static_cast<ACE_CDR::ULong> (x); return this->write_4 (&temp); }
ACE_CDR::Boolean ACE_OutputCDR::write_long_array | ( | const ACE_CDR::Long * | x, | |
ACE_CDR::ULong | length | |||
) | [inline] |
Definition at line 365 of file CDR_Stream.inl.
{ return this->write_array (x, ACE_CDR::LONG_SIZE, ACE_CDR::LONG_ALIGN, length); }
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.
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.
{ char *buf = 0; if (this->adjust (ACE_CDR::LONG_SIZE, buf) == 0) *reinterpret_cast<ACE_CDR::ULong*> (buf) = 0; else buf = 0; return buf; }
ACE_CDR::Boolean ACE_OutputCDR::write_longdouble | ( | const ACE_CDR::LongDouble & | x | ) | [inline] |
For string we offer methods that accept a precomputed length.
Definition at line 268 of file CDR_Stream.inl.
{ return this->write_16 (&x); }
ACE_CDR::Boolean ACE_OutputCDR::write_longdouble_array | ( | const ACE_CDR::LongDouble * | x, | |
ACE_CDR::ULong | length | |||
) | [inline] |
Definition at line 426 of file CDR_Stream.inl.
{ return this->write_array (x, ACE_CDR::LONGDOUBLE_SIZE, ACE_CDR::LONGDOUBLE_ALIGN, length); }
ACE_CDR::Boolean ACE_OutputCDR::write_longlong | ( | const ACE_CDR::LongLong & | x | ) | [inline] |
For string we offer methods that accept a precomputed length.
Definition at line 241 of file CDR_Stream.inl.
{ void const * const temp = &x; return this->write_8 (reinterpret_cast<ACE_CDR::ULongLong const *> (temp)); }
ACE_CDR::Boolean ACE_OutputCDR::write_longlong_array | ( | const ACE_CDR::LongLong * | x, | |
ACE_CDR::ULong | length | |||
) | [inline] |
Definition at line 385 of file CDR_Stream.inl.
{ return this->write_array (x, ACE_CDR::LONGLONG_SIZE, ACE_CDR::LONGLONG_ALIGN, length); }
ACE_CDR::Boolean ACE_OutputCDR::write_octet | ( | ACE_CDR::Octet | x | ) | [inline] |
For string we offer methods that accept a precomputed length.
Definition at line 187 of file CDR_Stream.inl.
{ return this->write_1 (&x); }
ACE_CDR::Boolean ACE_OutputCDR::write_octet_array | ( | const ACE_CDR::Octet * | x, | |
ACE_CDR::ULong | length | |||
) | [inline] |
Definition at line 335 of file CDR_Stream.inl.
{ return this->write_array (x, ACE_CDR::OCTET_SIZE, ACE_CDR::OCTET_ALIGN, length); }
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.
{ // If the buffer is small and it fits in the current message // block it is be cheaper just to copy the buffer. for (const ACE_Message_Block* i = mb; i != 0; i = i->cont ()) { size_t const length = i->length (); // If the mb does not own its data we are forced to make a copy. if (ACE_BIT_ENABLED (i->flags (), ACE_Message_Block::DONT_DELETE)) { if (! this->write_array (i->rd_ptr (), ACE_CDR::OCTET_SIZE, ACE_CDR::OCTET_ALIGN, static_cast<ACE_CDR::ULong> (length))) return (this->good_bit_ = false); continue; } if (length < this->memcpy_tradeoff_ && this->current_->wr_ptr () + length < this->current_->end ()) { if (! this->write_array (i->rd_ptr (), ACE_CDR::OCTET_SIZE, ACE_CDR::OCTET_ALIGN, static_cast<ACE_CDR::ULong> (length))) return (this->good_bit_ = false); continue; } ACE_Message_Block* cont = 0; this->good_bit_ = false; ACE_NEW_RETURN (cont, ACE_Message_Block (i->data_block ()->duplicate ()), false); this->good_bit_ = true; if (this->current_->cont () != 0) ACE_Message_Block::release (this->current_->cont ()); cont->rd_ptr (i->rd_ptr ()); cont->wr_ptr (i->wr_ptr ()); this->current_->cont (cont); this->current_ = cont; this->current_is_writable_ = false; #if !defined (ACE_LACKS_CDR_ALIGNMENT) this->current_alignment_ = (this->current_alignment_ + cont->length ()) % ACE_CDR::MAX_ALIGNMENT; #endif /* ACE_LACKS_CDR_ALIGNMENT */ } return true; }
ACE_CDR::Boolean ACE_OutputCDR::write_short | ( | ACE_CDR::Short | x | ) | [inline] |
For string we offer methods that accept a precomputed length.
Definition at line 215 of file CDR_Stream.inl.
{ ACE_CDR::UShort temp = static_cast<ACE_CDR::UShort> (x); return this->write_2 (&temp); }
ACE_CDR::Boolean ACE_OutputCDR::write_short_array | ( | const ACE_CDR::Short * | x, | |
ACE_CDR::ULong | length | |||
) | [inline] |
Definition at line 345 of file CDR_Stream.inl.
{ return this->write_array (x, ACE_CDR::SHORT_SIZE, ACE_CDR::SHORT_ALIGN, length); }
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.
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.
{ char *buf = 0; if (this->adjust (ACE_CDR::SHORT_SIZE, buf) == 0) *reinterpret_cast<ACE_CDR::UShort*> (buf) = 0; else buf = 0; return buf; }
ACE_CDR::Boolean ACE_OutputCDR::write_string | ( | const ACE_CDR::Char * | x | ) | [inline] |
For string we offer methods that accept a precomputed length.
Definition at line 274 of file CDR_Stream.inl.
{ if (x) { ACE_CDR::ULong const len = static_cast<ACE_CDR::ULong> (ACE_OS::strlen (x)); return this->write_string (len, x); } return this->write_string (0, 0); }
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.
{ // @@ This is a slight violation of "Optimize for the common case", // i.e. normally the translator will be 0, but OTOH the code is // smaller and should be better for the cache ;-) ;-) if (this->char_translator_ != 0) return this->char_translator_->write_string (*this, len, x); if (len != 0) { if (this->write_ulong (len + 1)) return this->write_char_array (x, len + 1); } else { // Be nice to programmers: treat nulls as empty strings not // errors. (OMG-IDL supports languages that don't use the C/C++ // notion of null v. empty strings; nulls aren't part of the OMG-IDL // string model.) if (this->write_ulong (1)) return this->write_char (0); } return (this->good_bit_ = false); }
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.
{ // @@ Leave this method in here, not the `.i' file so that we don't // have to unnecessarily pull in the `ace/SString.h' header. return this->write_string (static_cast<ACE_CDR::ULong> (x.length ()), x.c_str()); }
ACE_CDR::Boolean ACE_OutputCDR::write_ulong | ( | ACE_CDR::ULong | x | ) | [inline] |
For string we offer methods that accept a precomputed length.
Definition at line 235 of file CDR_Stream.inl.
{ return this->write_4 (&x); }
ACE_CDR::Boolean ACE_OutputCDR::write_ulong_array | ( | const ACE_CDR::ULong * | x, | |
ACE_CDR::ULong | length | |||
) | [inline] |
Definition at line 375 of file CDR_Stream.inl.
{ return this->write_array (x, ACE_CDR::LONG_SIZE, ACE_CDR::LONG_ALIGN, length); }
ACE_CDR::Boolean ACE_OutputCDR::write_ulonglong | ( | const ACE_CDR::ULongLong & | x | ) | [inline] |
For string we offer methods that accept a precomputed length.
Definition at line 248 of file CDR_Stream.inl.
{ return this->write_8 (&x); }
ACE_CDR::Boolean ACE_OutputCDR::write_ulonglong_array | ( | const ACE_CDR::ULongLong * | x, | |
ACE_CDR::ULong | length | |||
) | [inline] |
Definition at line 395 of file CDR_Stream.inl.
{ return this->write_array (x, ACE_CDR::LONGLONG_SIZE, ACE_CDR::LONGLONG_ALIGN, length); }
ACE_CDR::Boolean ACE_OutputCDR::write_ushort | ( | ACE_CDR::UShort | x | ) | [inline] |
For string we offer methods that accept a precomputed length.
Definition at line 222 of file CDR_Stream.inl.
{ return this->write_2 (&x); }
ACE_CDR::Boolean ACE_OutputCDR::write_ushort_array | ( | const ACE_CDR::UShort * | x, | |
ACE_CDR::ULong | length | |||
) | [inline] |
Definition at line 355 of file CDR_Stream.inl.
{ return this->write_array (x, ACE_CDR::SHORT_SIZE, ACE_CDR::SHORT_ALIGN, length); }
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.
{ if (this->wchar_translator_ != 0) return (this->good_bit_ = this->wchar_translator_->write_wchar (*this, x)); if (ACE_OutputCDR::wchar_maxbytes_ == 0) { errno = EACCES; return (this->good_bit_ = false); } if (static_cast<ACE_CDR::Short> (major_version_) == 1 && static_cast<ACE_CDR::Short> (minor_version_) == 2) { ACE_CDR::Octet len = static_cast<ACE_CDR::Octet> (ACE_OutputCDR::wchar_maxbytes_); if (this->write_1 (&len)) { if (ACE_OutputCDR::wchar_maxbytes_ == sizeof(ACE_CDR::WChar)) return this->write_octet_array ( reinterpret_cast<const ACE_CDR::Octet*> (&x), static_cast<ACE_CDR::ULong> (len)); else if (ACE_OutputCDR::wchar_maxbytes_ == 2) { ACE_CDR::Short sx = static_cast<ACE_CDR::Short> (x); return this->write_octet_array ( reinterpret_cast<const ACE_CDR::Octet*> (&sx), static_cast<ACE_CDR::ULong> (len)); } else { ACE_CDR::Octet ox = static_cast<ACE_CDR::Octet> (x); return this->write_octet_array ( reinterpret_cast<const ACE_CDR::Octet*> (&ox), static_cast<ACE_CDR::ULong> (len)); } } } else if (static_cast<ACE_CDR::Short> (minor_version_) == 0) { // wchar is not allowed with GIOP 1.0. errno = EINVAL; return (this->good_bit_ = false); } if (ACE_OutputCDR::wchar_maxbytes_ == sizeof (ACE_CDR::WChar)) { void const * const temp = &x; return this->write_4 (reinterpret_cast<const ACE_CDR::ULong *> (temp)); } else if (ACE_OutputCDR::wchar_maxbytes_ == 2) { ACE_CDR::Short sx = static_cast<ACE_CDR::Short> (x); return this->write_2 (reinterpret_cast<const ACE_CDR::UShort *> (&sx)); } ACE_CDR::Octet ox = static_cast<ACE_CDR::Octet> (x); return this->write_1 (reinterpret_cast<const ACE_CDR::Octet *> (&ox)); }
ACE_CDR::Boolean ACE_OutputCDR::write_wchar_array | ( | const ACE_CDR::WChar * | x, | |
ACE_CDR::ULong | length | |||
) | [inline] |
Definition at line 312 of file CDR_Stream.inl.
{ if (this->wchar_translator_) return this->wchar_translator_->write_wchar_array (*this, x, length); if (ACE_OutputCDR::wchar_maxbytes_ == 0) { errno = EACCES; return (ACE_CDR::Boolean) (this->good_bit_ = false); } if (ACE_OutputCDR::wchar_maxbytes_ == sizeof (ACE_CDR::WChar)) return this->write_array (x, sizeof (ACE_CDR::WChar), sizeof (ACE_CDR::WChar) == 2 ? ACE_CDR::SHORT_ALIGN : ACE_CDR::LONG_ALIGN, length); return this->write_wchar_array_i (x,length); }
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.
{ if (length == 0) return true; char* buf = 0; size_t const align = (ACE_OutputCDR::wchar_maxbytes_ == 2) ? ACE_CDR::SHORT_ALIGN : ACE_CDR::OCTET_ALIGN; if (this->adjust (ACE_OutputCDR::wchar_maxbytes_ * length, align, buf) == 0) { if (ACE_OutputCDR::wchar_maxbytes_ == 2) { ACE_CDR::UShort *sb = reinterpret_cast<ACE_CDR::UShort *> (buf); for (size_t i = 0; i < length; ++i) #if !defined (ACE_ENABLE_SWAP_ON_WRITE) sb[i] = static_cast<ACE_CDR::UShort> (x[i]); #else if (!this->do_byte_swap_) sb[i] = static_cast<ACE_CDR::UShort> (x[i]); else { ACE_CDR::UShort sx = static_cast<ACE_CDR::UShort> (x[i]); ACE_CDR::swap_2 (reinterpret_cast<char *> (&sx), &buf[i * 2]); } #endif /* ACE_ENABLE_SWAP_ON_WRITE */ } else { for (size_t i = 0; i < length; ++i) buf[i] = static_cast<char> (x[i]); } return this->good_bit_; } return false; }
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.
{ // @@ This is a slight violation of "Optimize for the common case", // i.e. normally the translator will be 0, but OTOH the code is // smaller and should be better for the cache ;-) ;-) // What do we do for GIOP 1.2??? if (this->wchar_translator_ != 0) return this->wchar_translator_->write_wstring (*this, len, x); if (ACE_OutputCDR::wchar_maxbytes_ == 0) { errno = EACCES; return (this->good_bit_ = false); } if (static_cast<ACE_CDR::Short> (this->major_version_) == 1 && static_cast<ACE_CDR::Short> (this->minor_version_) == 2) { if (x != 0) { //In GIOP 1.2 the length field contains the number of bytes //the wstring occupies rather than number of wchars //Taking sizeof might not be a good way! This is a temporary fix. ACE_CDR::Boolean good_ulong = this->write_ulong ( ACE_Utils::truncate_cast<ACE_CDR::ULong> ( ACE_OutputCDR::wchar_maxbytes_ * len)); if (good_ulong) { return this->write_wchar_array (x, len); } } else { //In GIOP 1.2 zero length wstrings are legal return this->write_ulong (0); } } else if (x != 0) { if (this->write_ulong (len + 1)) return this->write_wchar_array (x, len + 1); } else if (this->write_ulong (1)) return this->write_wchar (0); return (this->good_bit_ = false); }
ACE_CDR::Boolean ACE_OutputCDR::write_wstring | ( | const ACE_CDR::WChar * | x | ) | [inline] |
For string we offer methods that accept a precomputed length.
Definition at line 287 of file CDR_Stream.inl.
{ if (x) { ACE_CDR::ULong const len = static_cast<ACE_CDR::ULong> (ACE_OS::strlen (x)); return this->write_wstring (len, x); } return this->write_wstring (0, 0); }
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.
If not nil, invoke for translation of character and string data.
Definition at line 590 of file CDR_Stream.h.
ACE_Message_Block* ACE_OutputCDR::current_ [private] |
The current block in the chain where we are writing.
Definition at line 541 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 552 of file CDR_Stream.h.
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 561 of file CDR_Stream.h.
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 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.
ACE_CDR::Octet ACE_OutputCDR::major_version_ [protected] |
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.
ACE_CDR::Octet ACE_OutputCDR::minor_version_ [protected] |
Definition at line 587 of file CDR_Stream.h.
ACE_Message_Block ACE_OutputCDR::start_ [private] |
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.