Class to serialize and deserialize data for DDS. More...
#include <Serializer.h>
Public Types | |
enum | Alignment { ALIGN_NONE, ALIGN_INITIALIZE, ALIGN_CDR } |
Public Member Functions | |
Serializer (ACE_Message_Block *chain, bool swap_bytes=false, Alignment align=ALIGN_NONE) | |
virtual | ~Serializer () |
void | swap_bytes (bool do_swap) |
Establish byte swapping behavior. | |
bool | swap_bytes () const |
Examine byte swapping behavior. | |
Alignment | alignment () const |
Examine alignment behavior. | |
void | reset_alignment () |
Reset alignment as if a new instance were created. | |
bool | good_bit () const |
Examine the state of the stream abstraction. | |
size_t | length () const |
Number of bytes left to read in message block chain. | |
size_t | read_string (ACE_CDR::Char *&dest, ACE_CDR::Char *str_alloc(ACE_CDR::ULong)=CORBA::string_alloc, void str_free(ACE_CDR::Char *)=CORBA::string_free) |
Read a narrow string. | |
size_t | read_string (ACE_CDR::WChar *&dest, ACE_CDR::WChar *str_alloc(ACE_CDR::ULong)=CORBA::wstring_alloc, void str_free(ACE_CDR::WChar *)=CORBA::wstring_free) |
Read a wide string. | |
bool | skip (ACE_CDR::UShort n, int size=1) |
size_t | available_r () const |
void | buffer_read (char *dest, size_t size, bool swap) |
Read from the chain into a destination buffer. | |
int | align_r (size_t alignment) |
int | align_w (size_t alignment) |
bool | read_boolean_array (ACE_CDR::Boolean *x, ACE_CDR::ULong length) |
bool | read_char_array (ACE_CDR::Char *x, ACE_CDR::ULong length) |
bool | read_wchar_array (ACE_CDR::WChar *x, ACE_CDR::ULong length) |
bool | read_octet_array (ACE_CDR::Octet *x, ACE_CDR::ULong length) |
bool | read_short_array (ACE_CDR::Short *x, ACE_CDR::ULong length) |
bool | read_ushort_array (ACE_CDR::UShort *x, ACE_CDR::ULong length) |
bool | read_long_array (ACE_CDR::Long *x, ACE_CDR::ULong length) |
bool | read_ulong_array (ACE_CDR::ULong *x, ACE_CDR::ULong length) |
bool | read_longlong_array (ACE_CDR::LongLong *x, ACE_CDR::ULong length) |
bool | read_ulonglong_array (ACE_CDR::ULongLong *x, ACE_CDR::ULong length) |
bool | read_float_array (ACE_CDR::Float *x, ACE_CDR::ULong length) |
bool | read_double_array (ACE_CDR::Double *x, ACE_CDR::ULong length) |
bool | read_longdouble_array (ACE_CDR::LongDouble *x, ACE_CDR::ULong length) |
bool | write_boolean_array (const ACE_CDR::Boolean *x, ACE_CDR::ULong length) |
bool | write_char_array (const ACE_CDR::Char *x, ACE_CDR::ULong length) |
bool | write_wchar_array (const ACE_CDR::WChar *x, ACE_CDR::ULong length) |
bool | write_octet_array (const ACE_CDR::Octet *x, ACE_CDR::ULong length) |
bool | write_short_array (const ACE_CDR::Short *x, ACE_CDR::ULong length) |
bool | write_ushort_array (const ACE_CDR::UShort *x, ACE_CDR::ULong length) |
bool | write_long_array (const ACE_CDR::Long *x, ACE_CDR::ULong length) |
bool | write_ulong_array (const ACE_CDR::ULong *x, ACE_CDR::ULong length) |
bool | write_longlong_array (const ACE_CDR::LongLong *x, ACE_CDR::ULong length) |
bool | write_ulonglong_array (const ACE_CDR::ULongLong *x, ACE_CDR::ULong length) |
bool | write_float_array (const ACE_CDR::Float *x, ACE_CDR::ULong length) |
bool | write_double_array (const ACE_CDR::Double *x, ACE_CDR::ULong length) |
bool | write_longdouble_array (const ACE_CDR::LongDouble *x, ACE_CDR::ULong length) |
Static Public Member Functions | |
static bool | use_rti_serialization () |
static void | set_use_rti_serialization (bool should_use) |
Static Public Attributes | |
static const size_t | WCHAR_SIZE = 2 |
static const bool | SWAP_BE = false |
Private Member Functions | |
void | read_array (char *x, size_t size, ACE_CDR::ULong length) |
void | read_array (char *x, size_t size, ACE_CDR::ULong length, bool swap) |
void | buffer_write (const char *src, size_t size, bool swap) |
Write to the chain from a source buffer. | |
void | write_array (const char *x, size_t size, ACE_CDR::ULong length) |
void | write_array (const char *x, size_t size, ACE_CDR::ULong length, bool swap) |
void | smemcpy (char *to, const char *from, size_t n) |
void | swapcpy (char *to, const char *from, size_t n) |
size_t | doread (char *dest, size_t size, bool swap, size_t offset) |
Implementation of the actual read from the chain. | |
size_t | dowrite (const char *dest, size_t size, bool swap, size_t offset) |
Implementation of the actual write to the chain. | |
void | align_cont_r () |
Update alignment state when a cont() chain is followed during a read. | |
void | align_cont_w () |
Update alignment state when a cont() chain is followed during a write. | |
Private Attributes | |
ACE_Message_Block * | current_ |
Currently active message block in chain. | |
bool | swap_bytes_ |
Indicates whether bytes will be swapped for this stream. | |
bool | good_bit_ |
Indicates the current state of the stream abstraction. | |
Alignment | alignment_ |
Current alignment mode, see Alignment enum above. | |
unsigned char | align_rshift_ |
unsigned char | align_wshift_ |
Static Private Attributes | |
static const size_t | MAX_ALIGN = 8 |
static const char | ALIGN_PAD [MAX_ALIGN] = {0} |
static bool | use_rti_serialization_ |
Friends | |
OpenDDS_Dcps_Export bool | operator<< (Serializer &s, ACE_CDR::Char x) |
OpenDDS_Dcps_Export bool | operator<< (Serializer &s, ACE_CDR::Short x) |
OpenDDS_Dcps_Export bool | operator<< (Serializer &s, ACE_CDR::UShort x) |
OpenDDS_Dcps_Export bool | operator<< (Serializer &s, ACE_CDR::Long x) |
OpenDDS_Dcps_Export bool | operator<< (Serializer &s, ACE_CDR::ULong x) |
OpenDDS_Dcps_Export bool | operator<< (Serializer &s, ACE_CDR::LongLong x) |
OpenDDS_Dcps_Export bool | operator<< (Serializer &s, ACE_CDR::ULongLong x) |
OpenDDS_Dcps_Export bool | operator<< (Serializer &s, ACE_CDR::LongDouble x) |
OpenDDS_Dcps_Export bool | operator<< (Serializer &s, ACE_CDR::Float x) |
OpenDDS_Dcps_Export bool | operator<< (Serializer &s, ACE_CDR::Double x) |
OpenDDS_Dcps_Export bool | operator<< (Serializer &s, const ACE_CDR::Char *x) |
OpenDDS_Dcps_Export bool | operator<< (Serializer &s, const ACE_CDR::WChar *x) |
OpenDDS_Dcps_Export bool | operator<< (Serializer &s, ACE_OutputCDR::from_boolean x) |
OpenDDS_Dcps_Export bool | operator<< (Serializer &s, ACE_OutputCDR::from_char x) |
OpenDDS_Dcps_Export bool | operator<< (Serializer &s, ACE_OutputCDR::from_wchar x) |
OpenDDS_Dcps_Export bool | operator<< (Serializer &s, ACE_OutputCDR::from_octet x) |
OpenDDS_Dcps_Export bool | operator<< (Serializer &s, ACE_OutputCDR::from_string x) |
OpenDDS_Dcps_Export bool | operator<< (Serializer &s, ACE_OutputCDR::from_wstring x) |
OpenDDS_Dcps_Export bool | operator<< (Serializer &s, const std::string &x) |
OpenDDS_Dcps_Export bool | operator>> (Serializer &s, ACE_CDR::Char &x) |
OpenDDS_Dcps_Export bool | operator>> (Serializer &s, ACE_CDR::Short &x) |
OpenDDS_Dcps_Export bool | operator>> (Serializer &s, ACE_CDR::UShort &x) |
OpenDDS_Dcps_Export bool | operator>> (Serializer &s, ACE_CDR::Long &x) |
OpenDDS_Dcps_Export bool | operator>> (Serializer &s, ACE_CDR::ULong &x) |
OpenDDS_Dcps_Export bool | operator>> (Serializer &s, ACE_CDR::LongLong &x) |
OpenDDS_Dcps_Export bool | operator>> (Serializer &s, ACE_CDR::ULongLong &x) |
OpenDDS_Dcps_Export bool | operator>> (Serializer &s, ACE_CDR::LongDouble &x) |
OpenDDS_Dcps_Export bool | operator>> (Serializer &s, ACE_CDR::Float &x) |
OpenDDS_Dcps_Export bool | operator>> (Serializer &s, ACE_CDR::Double &x) |
OpenDDS_Dcps_Export bool | operator>> (Serializer &s, ACE_CDR::Char *&x) |
OpenDDS_Dcps_Export bool | operator>> (Serializer &s, ACE_CDR::WChar *&x) |
OpenDDS_Dcps_Export bool | operator>> (Serializer &s, ACE_InputCDR::to_boolean x) |
OpenDDS_Dcps_Export bool | operator>> (Serializer &s, ACE_InputCDR::to_char x) |
OpenDDS_Dcps_Export bool | operator>> (Serializer &s, ACE_InputCDR::to_wchar x) |
OpenDDS_Dcps_Export bool | operator>> (Serializer &s, ACE_InputCDR::to_octet x) |
OpenDDS_Dcps_Export bool | operator>> (Serializer &s, ACE_InputCDR::to_string x) |
OpenDDS_Dcps_Export bool | operator>> (Serializer &s, ACE_InputCDR::to_wstring x) |
OpenDDS_Dcps_Export bool | operator>> (Serializer &s, std::string &x) |
Class to serialize and deserialize data for DDS.
This class provides a mechanism to insert and extract data to and from an ACE_Message_Block chain that represents the data which can be transported on the wire to other DDS service participants.
Definition at line 41 of file Serializer.h.
Definition at line 44 of file Serializer.h.
00044 { 00045 ALIGN_NONE, // no alignment needed 00046 ALIGN_INITIALIZE, // align to CDR rules and zero-out padding 00047 ALIGN_CDR // align to CDR rules with uninitialized padding 00048 #ifdef ACE_INITIALIZE_MEMORY_BEFORE_USE 00049 = ALIGN_INITIALIZE // if the above macro is set, always init padding 00050 #endif 00051 };
OpenDDS::DCPS::Serializer::Serializer | ( | ACE_Message_Block * | chain, | |
bool | swap_bytes = false , |
|||
Alignment | align = ALIGN_NONE | |||
) | [explicit] |
Constructor with a message block chain. This installs the message block chain and sets the current block to the first in the chain. Memory management is the responsibility of the owner of this object, and is not performed internally. Ownership of the message block chain is retained by the owner of this object and the lifetime of the chain must be longer than the use of this object.
Bytes are swapped when either reading or writing from the message chain if the swap_bytes argument is true. It is the responsibility of the owner of this object to determine whether this should be performed or not.
Definition at line 27 of file Serializer.cpp.
00029 : current_(chain) 00030 , swap_bytes_(swap_bytes) 00031 , good_bit_(true) 00032 , alignment_(align) 00033 , align_rshift_(chain ? ptrdiff_t(chain->rd_ptr()) % MAX_ALIGN : 0) 00034 , align_wshift_(chain ? ptrdiff_t(chain->wr_ptr()) % MAX_ALIGN : 0) 00035 { 00036 }
OpenDDS::DCPS::Serializer::~Serializer | ( | ) | [virtual] |
Definition at line 38 of file Serializer.cpp.
ACE_INLINE void OpenDDS::DCPS::Serializer::align_cont_r | ( | ) | [private] |
Update alignment state when a cont() chain is followed during a read.
Definition at line 564 of file Serializer.inl.
References align_rshift_, ACE_Message_Block::cont(), current_, MAX_ALIGN, and ACE_Message_Block::rd_ptr().
Referenced by doread(), and skip().
00565 { 00566 const size_t thisblock = 00567 (ptrdiff_t(this->current_->rd_ptr()) - this->align_rshift_) % MAX_ALIGN; 00568 00569 this->current_ = this->current_->cont(); 00570 00571 if (this->current_) { 00572 this->align_rshift_ = 00573 (ptrdiff_t(this->current_->rd_ptr()) - thisblock) % MAX_ALIGN; 00574 } 00575 }
ACE_INLINE void OpenDDS::DCPS::Serializer::align_cont_w | ( | ) | [private] |
Update alignment state when a cont() chain is followed during a write.
Definition at line 578 of file Serializer.inl.
References align_wshift_, ACE_Message_Block::cont(), current_, MAX_ALIGN, and ACE_Message_Block::wr_ptr().
Referenced by align_w(), and dowrite().
00579 { 00580 const size_t thisblock = 00581 (ptrdiff_t(this->current_->wr_ptr()) - this->align_wshift_) % MAX_ALIGN; 00582 00583 this->current_ = this->current_->cont(); 00584 00585 if (this->current_) { 00586 this->align_wshift_ = 00587 (ptrdiff_t(this->current_->wr_ptr()) - thisblock) % MAX_ALIGN; 00588 } 00589 }
ACE_INLINE int OpenDDS::DCPS::Serializer::align_r | ( | size_t | alignment | ) |
Align for reading: moves current_->rd_ptr() past the alignment padding. Alignments of 2, 4, or 8 are supported by CDR and this implementation.
Definition at line 525 of file Serializer.inl.
References align_rshift_, current_, len, ACE_Message_Block::rd_ptr(), and skip().
Referenced by OpenDDS::DCPS::operator>>(), read_double_array(), read_float_array(), read_long_array(), read_longdouble_array(), read_longlong_array(), read_short_array(), read_string(), read_ulong_array(), read_ulonglong_array(), read_ushort_array(), and skip().
00526 { 00527 const size_t len = 00528 (al - ptrdiff_t(this->current_->rd_ptr()) + this->align_rshift_) % al; 00529 this->skip(static_cast<ACE_CDR::UShort>(len)); 00530 return 0; 00531 }
ACE_INLINE int OpenDDS::DCPS::Serializer::align_w | ( | size_t | alignment | ) |
Align for writing: moves current_->wr_ptr() past the padding, possibly zero-filling the pad bytes (based on the alignment_ setting). Alignments of 2, 4, or 8 are supported by CDR and this implementation.
Definition at line 534 of file Serializer.inl.
References align_cont_w(), ALIGN_INITIALIZE, ALIGN_PAD, align_wshift_, alignment_, current_, good_bit_, len, smemcpy(), ACE_Message_Block::space(), and ACE_Message_Block::wr_ptr().
Referenced by OpenDDS::DCPS::operator<<(), write_double_array(), write_float_array(), write_long_array(), write_longdouble_array(), write_longlong_array(), write_short_array(), write_ulong_array(), write_ulonglong_array(), and write_ushort_array().
00535 { 00536 size_t len = 00537 (al - ptrdiff_t(this->current_->wr_ptr()) + this->align_wshift_) % al; 00538 while (len) { 00539 if (!this->current_) { 00540 this->good_bit_ = false; 00541 break; 00542 } 00543 const size_t cur_spc = this->current_->space(); 00544 if (cur_spc <= len) { 00545 len -= cur_spc; 00546 if (this->alignment_ == ALIGN_INITIALIZE) { 00547 this->smemcpy(this->current_->wr_ptr(), ALIGN_PAD, cur_spc); 00548 } 00549 this->current_->wr_ptr(cur_spc); 00550 this->align_cont_w(); 00551 } else { 00552 if (this->alignment_ == ALIGN_INITIALIZE) { 00553 this->smemcpy(this->current_->wr_ptr(), ALIGN_PAD, len); 00554 } 00555 this->current_->wr_ptr(len); 00556 break; 00557 } 00558 } 00559 return 0; 00560 }
ACE_INLINE Serializer::Alignment OpenDDS::DCPS::Serializer::alignment | ( | ) | const |
Examine alignment behavior.
Definition at line 206 of file Serializer.inl.
References alignment_.
Referenced by OpenDDS::DCPS::operator<<(), OpenDDS::DCPS::operator>>(), read_double_array(), read_float_array(), read_long_array(), read_longdouble_array(), read_longlong_array(), read_short_array(), read_ulong_array(), read_ulonglong_array(), read_ushort_array(), write_double_array(), write_float_array(), write_long_array(), write_longdouble_array(), write_longlong_array(), write_short_array(), write_ulong_array(), write_ulonglong_array(), and write_ushort_array().
00207 { 00208 return this->alignment_; 00209 }
size_t OpenDDS::DCPS::Serializer::available_r | ( | ) | const [inline] |
Definition at line 109 of file Serializer.h.
00109 { return current_ ? current_->total_length() : 0; }
ACE_INLINE void OpenDDS::DCPS::Serializer::buffer_read | ( | char * | dest, | |
size_t | size, | |||
bool | swap | |||
) |
Read from the chain into a destination buffer.
Definition at line 98 of file Serializer.inl.
References doread().
Referenced by OpenDDS::DCPS::operator>>(), read_array(), and read_string().
00099 { 00100 size_t offset = 0; 00101 00102 while (size > offset) { 00103 offset = this->doread(dest, size, swap, offset); 00104 } 00105 }
ACE_INLINE void OpenDDS::DCPS::Serializer::buffer_write | ( | const char * | src, | |
size_t | size, | |||
bool | swap | |||
) | [private] |
Write to the chain from a source buffer.
Definition at line 184 of file Serializer.inl.
References dowrite().
Referenced by OpenDDS::DCPS::operator<<(), and write_array().
00185 { 00186 size_t offset = 0; 00187 00188 while (size > offset) { 00189 offset = this->dowrite(src, size, swap, offset); 00190 } 00191 }
ACE_INLINE size_t OpenDDS::DCPS::Serializer::doread | ( | char * | dest, | |
size_t | size, | |||
bool | swap, | |||
size_t | offset | |||
) | [private] |
Implementation of the actual read from the chain.
Definition at line 25 of file Serializer.inl.
References align_cont_r(), ALIGN_NONE, alignment_, ACE_Message_Block::cont(), current_, good_bit_, len, ACE_Message_Block::length(), ACE_Message_Block::rd_ptr(), smemcpy(), and swapcpy().
Referenced by buffer_read().
00026 { 00027 // 00028 // Ensure we work only with buffer data. 00029 // 00030 if (this->current_ == 0) { 00031 this->good_bit_ = false; 00032 return size; 00033 } 00034 00035 // 00036 // Determine how much data will remain to be read after the current 00037 // buffer has been entirely read. 00038 // 00039 const size_t len = this->current_->length(); 00040 const size_t remainder = (size - offset > len) ? size - offset - len : 0; 00041 00042 // 00043 // Derive how much data we need to read from the current buffer. 00044 // 00045 const size_t initial = size - offset - remainder; 00046 00047 // 00048 // Copy or swap the source data from the current buffer into the 00049 // destination. 00050 // 00051 swap 00052 ? this->swapcpy(dest + remainder, this->current_->rd_ptr(), initial) 00053 : this->smemcpy(dest + offset, this->current_->rd_ptr(), initial); 00054 this->current_->rd_ptr(initial); 00055 00056 // smemcpy 00057 // 00058 // dest b1 b2 b3 offset remainder initial 00059 // xxxxxxxx 01 23 4567xx 00060 // ^ 0 6 2 00061 // 01xxxxxx 01 23 4567xx 00062 // ^ 2 4 2 00063 // 0123xxxx 01 23 4567xx 00064 // ^ 4 0 4 00065 // 01234567 01 23 4567xx 00066 // ^ 00067 00068 // swapcpy 00069 // 00070 // dest b1 b2 b3 offset remainder initial 00071 // xxxxxxxx 01 23 4567xx 00072 // ^ 0 6 2 00073 // xxxxxx10 01 23 4567xx 00074 // ^ 2 4 2 00075 // xxxx3210 01 23 4567xx 00076 // ^ 4 0 4 00077 // 76543210 01 23 4567xx 00078 // ^ 00079 00080 // 00081 // Move to the next chained block if this one is spent. 00082 // 00083 if (this->current_->length() == 0) { 00084 00085 if (this->alignment_ == ALIGN_NONE) { 00086 this->current_ = this->current_->cont(); 00087 } else { 00088 this->align_cont_r(); 00089 } 00090 } 00091 // 00092 // Return the current location in the read. 00093 // 00094 return offset + initial; 00095 }
ACE_INLINE size_t OpenDDS::DCPS::Serializer::dowrite | ( | const char * | dest, | |
size_t | size, | |||
bool | swap, | |||
size_t | offset | |||
) | [private] |
Implementation of the actual write to the chain.
Definition at line 111 of file Serializer.inl.
References align_cont_w(), ALIGN_NONE, alignment_, ACE_Message_Block::cont(), current_, good_bit_, smemcpy(), ACE_Message_Block::space(), swapcpy(), and ACE_Message_Block::wr_ptr().
Referenced by buffer_write().
00112 { 00113 // 00114 // Ensure we work only with buffer data. 00115 // 00116 if (this->current_ == 0) { 00117 this->good_bit_ = false; 00118 return size; 00119 } 00120 00121 // 00122 // Determine how much data will remain to be written after the current 00123 // buffer has been entirely filled. 00124 // 00125 const size_t spc = this->current_->space(); 00126 const size_t remainder = (size - offset > spc) ? size - offset - spc : 0; 00127 00128 // 00129 // Derive how much data we need to write to the current buffer. 00130 // 00131 const size_t initial = size - offset - remainder; 00132 00133 // 00134 // Copy or swap the source data into the current buffer. 00135 // 00136 swap 00137 ? this->swapcpy(this->current_->wr_ptr(), src + remainder, initial) 00138 : this->smemcpy(this->current_->wr_ptr(), src + offset, initial); 00139 this->current_->wr_ptr(initial); 00140 00141 // smemcpy 00142 // 00143 // src b1 b2 b3 offset remainder initial 00144 // 01234567 xx xx xxxxxx 00145 // ^ 0 6 2 00146 // 01 xx xxxxxx 00147 // ^ 2 4 2 00148 // 01 23 xxxxxx 00149 // ^ 4 0 4 00150 // 01 23 4567xx 00151 // ^ 00152 00153 // swapcpy 00154 // 00155 // src b1 b2 b3 offset remainder initial 00156 // 01234567 xx xx xxxxxx 00157 // ^ 0 6 2 00158 // 76 xx xxxxxx 00159 // ^ 2 4 2 00160 // 76 54 xxxxxx 00161 // ^ 4 0 4 00162 // 76 54 3210xx 00163 // ^ 00164 00165 // 00166 // Move to the next chained block if this one is spent. 00167 // 00168 if (this->current_->space() == 0) { 00169 00170 if (this->alignment_ == ALIGN_NONE) { 00171 this->current_ = this->current_->cont(); 00172 } else { 00173 this->align_cont_w(); 00174 } 00175 } 00176 00177 // 00178 // Return the current location in the write. 00179 // 00180 return offset + initial; 00181 }
ACE_INLINE bool OpenDDS::DCPS::Serializer::good_bit | ( | void | ) | const |
Examine the state of the stream abstraction.
Definition at line 212 of file Serializer.inl.
References good_bit_.
Referenced by OpenDDS::DCPS::operator<<(), OpenDDS::FaceTypes::operator>>(), OpenDDS::DCPS::operator>>(), read_boolean_array(), read_char_array(), read_double_array(), read_float_array(), read_long_array(), read_longdouble_array(), read_longlong_array(), read_octet_array(), read_short_array(), read_ulong_array(), read_ulonglong_array(), read_ushort_array(), read_wchar_array(), skip(), write_boolean_array(), write_char_array(), write_double_array(), write_float_array(), write_long_array(), write_longdouble_array(), write_longlong_array(), write_octet_array(), write_short_array(), write_ulong_array(), write_ulonglong_array(), write_ushort_array(), and write_wchar_array().
00213 { 00214 return this->good_bit_; 00215 }
ACE_INLINE size_t OpenDDS::DCPS::Serializer::length | ( | void | ) | const |
Number of bytes left to read in message block chain.
Definition at line 218 of file Serializer.inl.
References current_, good_bit_, and ACE_Message_Block::total_length().
Referenced by read_string().
00219 { 00220 return this->good_bit_ && this->current_ ? this->current_->total_length() : 0; 00221 }
ACE_INLINE void OpenDDS::DCPS::Serializer::read_array | ( | char * | x, | |
size_t | size, | |||
ACE_CDR::ULong | length, | |||
bool | swap | |||
) | [private] |
Definition at line 258 of file Serializer.inl.
References buffer_read().
00260 { 00261 if (!swap || size == 1) { 00262 // 00263 // No swap, copy direct. This silently corrupts the data if there is 00264 // padding in the buffer. 00265 // 00266 this->buffer_read(x, size * length, false); 00267 00268 } else { 00269 // 00270 // Swapping _must_ be done at 'size' boundaries, so we need to spin 00271 // through the array element by element. This silently corrupts the 00272 // data if there is padding in the buffer. 00273 // 00274 while (length-- > 0) { 00275 this->buffer_read(x, size, true); 00276 x += size; 00277 } 00278 } 00279 }
ACE_INLINE void OpenDDS::DCPS::Serializer::read_array | ( | char * | x, | |
size_t | size, | |||
ACE_CDR::ULong | length | |||
) | [private] |
Read an array of values from the chain. NOTE: This assumes that the buffer contains elements that are properly aligned. The buffer must have padding if the elements are not naturally aligned; or this routine should not be used.
Definition at line 252 of file Serializer.inl.
References swap_bytes_.
Referenced by read_boolean_array(), read_char_array(), read_double_array(), read_float_array(), read_long_array(), read_longdouble_array(), read_longlong_array(), read_octet_array(), read_short_array(), read_string(), read_ulong_array(), read_ulonglong_array(), and read_ushort_array().
00253 { 00254 this->read_array(x, size, length, this->swap_bytes_); 00255 }
ACE_INLINE bool OpenDDS::DCPS::Serializer::read_boolean_array | ( | ACE_CDR::Boolean * | x, | |
ACE_CDR::ULong | length | |||
) |
The buffer x must be large enough to contain length elements. Return false
on failure and true
on success.
Definition at line 313 of file Serializer.inl.
References good_bit(), and read_array().
00314 { 00315 this->read_array(reinterpret_cast<char*>(x), sizeof(ACE_CDR::Boolean), length); 00316 return this->good_bit(); 00317 }
ACE_INLINE bool OpenDDS::DCPS::Serializer::read_char_array | ( | ACE_CDR::Char * | x, | |
ACE_CDR::ULong | length | |||
) |
The buffer x must be large enough to contain length elements. Return false
on failure and true
on success.
Definition at line 320 of file Serializer.inl.
References good_bit(), and read_array().
Referenced by read_string().
00321 { 00322 this->read_array(reinterpret_cast<char*>(x), sizeof(ACE_CDR::Char), length); 00323 return this->good_bit(); 00324 }
ACE_INLINE bool OpenDDS::DCPS::Serializer::read_double_array | ( | ACE_CDR::Double * | x, | |
ACE_CDR::ULong | length | |||
) |
The buffer x must be large enough to contain length elements. Return false
on failure and true
on success.
Definition at line 401 of file Serializer.inl.
References ALIGN_NONE, align_r(), alignment(), good_bit(), and read_array().
00402 { 00403 this->alignment() == Serializer::ALIGN_NONE ? 0 : this->align_r(sizeof(ACE_CDR::Double)); 00404 this->read_array(reinterpret_cast<char*>(x), sizeof(ACE_CDR::Double), length); 00405 return this->good_bit(); 00406 }
ACE_INLINE bool OpenDDS::DCPS::Serializer::read_float_array | ( | ACE_CDR::Float * | x, | |
ACE_CDR::ULong | length | |||
) |
The buffer x must be large enough to contain length elements. Return false
on failure and true
on success.
Definition at line 393 of file Serializer.inl.
References ALIGN_NONE, align_r(), alignment(), good_bit(), and read_array().
00394 { 00395 this->alignment() == Serializer::ALIGN_NONE ? 0 : this->align_r(sizeof(ACE_CDR::Float)); 00396 this->read_array(reinterpret_cast<char*>(x), sizeof(ACE_CDR::Float), length); 00397 return this->good_bit(); 00398 }
ACE_INLINE bool OpenDDS::DCPS::Serializer::read_long_array | ( | ACE_CDR::Long * | x, | |
ACE_CDR::ULong | length | |||
) |
The buffer x must be large enough to contain length elements. Return false
on failure and true
on success.
Definition at line 361 of file Serializer.inl.
References ALIGN_NONE, align_r(), alignment(), good_bit(), and read_array().
00362 { 00363 this->alignment() == Serializer::ALIGN_NONE ? 0 : this->align_r(sizeof(ACE_CDR::Long)); 00364 this->read_array(reinterpret_cast<char*>(x), sizeof(ACE_CDR::Long), length); 00365 return this->good_bit(); 00366 }
ACE_INLINE bool OpenDDS::DCPS::Serializer::read_longdouble_array | ( | ACE_CDR::LongDouble * | x, | |
ACE_CDR::ULong | length | |||
) |
The buffer x must be large enough to contain length elements. Return false
on failure and true
on success.
Definition at line 409 of file Serializer.inl.
References ALIGN_NONE, align_r(), alignment(), good_bit(), and read_array().
00410 { 00411 this->alignment() == Serializer::ALIGN_NONE ? 0 : this->align_r(8); 00412 this->read_array(reinterpret_cast<char*>(x), sizeof(ACE_CDR::LongDouble), length); 00413 return this->good_bit(); 00414 }
ACE_INLINE bool OpenDDS::DCPS::Serializer::read_longlong_array | ( | ACE_CDR::LongLong * | x, | |
ACE_CDR::ULong | length | |||
) |
The buffer x must be large enough to contain length elements. Return false
on failure and true
on success.
Definition at line 377 of file Serializer.inl.
References ALIGN_NONE, align_r(), alignment(), good_bit(), and read_array().
00378 { 00379 this->alignment() == Serializer::ALIGN_NONE ? 0 : this->align_r(sizeof(ACE_CDR::LongLong)); 00380 this->read_array(reinterpret_cast<char*>(x), sizeof(ACE_CDR::LongLong), length); 00381 return this->good_bit(); 00382 }
ACE_INLINE bool OpenDDS::DCPS::Serializer::read_octet_array | ( | ACE_CDR::Octet * | x, | |
ACE_CDR::ULong | length | |||
) |
The buffer x must be large enough to contain length elements. Return false
on failure and true
on success.
Definition at line 338 of file Serializer.inl.
References good_bit(), and read_array().
Referenced by OpenDDS::DCPS::TransportHeader::init().
00339 { 00340 this->read_array(reinterpret_cast<char*>(x), sizeof(ACE_CDR::Octet), length); 00341 return this->good_bit(); 00342 }
ACE_INLINE bool OpenDDS::DCPS::Serializer::read_short_array | ( | ACE_CDR::Short * | x, | |
ACE_CDR::ULong | length | |||
) |
The buffer x must be large enough to contain length elements. Return false
on failure and true
on success.
Definition at line 345 of file Serializer.inl.
References ALIGN_NONE, align_r(), alignment(), good_bit(), and read_array().
00346 { 00347 this->alignment() == Serializer::ALIGN_NONE ? 0 : this->align_r(sizeof(ACE_CDR::Short)); 00348 this->read_array(reinterpret_cast<char*>(x), sizeof(ACE_CDR::Short), length); 00349 return this->good_bit(); 00350 }
size_t OpenDDS::DCPS::Serializer::read_string | ( | ACE_CDR::WChar *& | dest, | |
ACE_CDR::WChar * | str_allocACE_CDR::ULong = CORBA::wstring_alloc , |
|||
void | str_freeACE_CDR::WChar * = CORBA::wstring_free | |||
) |
Read a wide string.
Definition at line 178 of file Serializer.cpp.
References ALIGN_NONE, align_r(), alignment_, buffer_read(), current_, good_bit_, length(), read_array(), SWAP_BE, swap_bytes(), ACE_Message_Block::total_length(), and WCHAR_SIZE.
00181 { 00182 this->alignment_ == ALIGN_NONE ? 0 : this->align_r(sizeof(ACE_CDR::ULong)); 00183 // 00184 // Ensure no bad values leave the routine. 00185 // 00186 str_free(dest); 00187 dest = 0; 00188 00189 // 00190 // Extract the string length. 00191 // 00192 ACE_CDR::ULong bytecount = 0; 00193 this->buffer_read(reinterpret_cast<char*>(&bytecount), 00194 sizeof(ACE_CDR::ULong), this->swap_bytes()); 00195 00196 if (!this->good_bit_) { 00197 return 0; 00198 } 00199 00200 // 00201 // NOTE: Maintain the ACE implementation where the length check is 00202 // done here before the allocation even though it will be 00203 // checked during the actual read as well. 00204 // 00205 ACE_CDR::ULong length = 0; 00206 if (bytecount <= this->current_->total_length()) { 00207 length = bytecount / WCHAR_SIZE; 00208 dest = str_alloc(length); 00209 00210 if (dest == 0) { 00211 this->good_bit_ = false; 00212 return 0; 00213 } 00214 00215 #if ACE_SIZEOF_WCHAR == 2 00216 this->read_array(reinterpret_cast<char*>(dest), WCHAR_SIZE, length, SWAP_BE); 00217 #else 00218 for (size_t i = 0; i < length && this->good_bit_; ++i) { 00219 ACE_UINT16 as_utf16; 00220 this->buffer_read(reinterpret_cast<char*>(&as_utf16), WCHAR_SIZE, SWAP_BE); 00221 if (this->good_bit_) { 00222 dest[i] = as_utf16; 00223 } 00224 } 00225 #endif 00226 00227 if (this->good_bit_) { 00228 // 00229 // Null terminate the string. 00230 // 00231 dest[length] = L'\0'; 00232 } else { 00233 str_free(dest); 00234 dest = 0; 00235 length = 0; 00236 } 00237 00238 } else { 00239 good_bit_ = false; 00240 } 00241 00242 return length; 00243 }
size_t OpenDDS::DCPS::Serializer::read_string | ( | ACE_CDR::Char *& | dest, | |
ACE_CDR::Char * | str_allocACE_CDR::ULong = CORBA::string_alloc , |
|||
void | str_freeACE_CDR::Char * = CORBA::string_free | |||
) |
Read a narrow string.
Definition at line 119 of file Serializer.cpp.
References ALIGN_NONE, align_r(), alignment_, buffer_read(), current_, good_bit_, length(), read_char_array(), swap_bytes(), and ACE_Message_Block::total_length().
Referenced by OpenDDS::FaceTypes::operator>>(), and OpenDDS::DCPS::operator>>().
00122 { 00123 this->alignment_ == ALIGN_NONE ? 0 : this->align_r(sizeof(ACE_CDR::ULong)); 00124 // 00125 // Ensure no bad values leave the routine. 00126 // 00127 str_free(dest); 00128 dest = 0; 00129 00130 // 00131 // Extract the string length. 00132 // 00133 ACE_CDR::ULong length; // includes the null 00134 this->buffer_read(reinterpret_cast<char*>(&length), sizeof(ACE_CDR::ULong), this->swap_bytes()); 00135 00136 if (!this->good_bit_) { 00137 return 0; 00138 } 00139 00140 if (length == 0) { 00141 // not legal CDR, but we need to accept it since other implementations may generate this 00142 dest = str_alloc(0); 00143 return 0; 00144 } 00145 00146 // 00147 // NOTE: Maintain the ACE implementation where the length check is 00148 // done here before the allocation even though it will be 00149 // checked during the actual read as well. 00150 // 00151 if (length <= this->current_->total_length()) { 00152 00153 dest = str_alloc(length - 1); 00154 00155 if (dest == 0) { 00156 this->good_bit_ = false; 00157 00158 } else { 00159 // 00160 // Extract the string. 00161 // 00162 this->read_char_array(dest, length); 00163 } 00164 00165 if (!this->good_bit_) { 00166 str_free(dest); 00167 dest = 0; 00168 } 00169 00170 } else { 00171 good_bit_ = false; 00172 } 00173 00174 return length - 1; 00175 }
ACE_INLINE bool OpenDDS::DCPS::Serializer::read_ulong_array | ( | ACE_CDR::ULong * | x, | |
ACE_CDR::ULong | length | |||
) |
The buffer x must be large enough to contain length elements. Return false
on failure and true
on success.
Definition at line 369 of file Serializer.inl.
References ALIGN_NONE, align_r(), alignment(), good_bit(), and read_array().
00370 { 00371 this->alignment() == Serializer::ALIGN_NONE ? 0 : this->align_r(sizeof(ACE_CDR::ULong)); 00372 this->read_array(reinterpret_cast<char*>(x), sizeof(ACE_CDR::ULong), length); 00373 return this->good_bit(); 00374 }
ACE_INLINE bool OpenDDS::DCPS::Serializer::read_ulonglong_array | ( | ACE_CDR::ULongLong * | x, | |
ACE_CDR::ULong | length | |||
) |
The buffer x must be large enough to contain length elements. Return false
on failure and true
on success.
Definition at line 385 of file Serializer.inl.
References ALIGN_NONE, align_r(), alignment(), good_bit(), and read_array().
00386 { 00387 this->alignment() == Serializer::ALIGN_NONE ? 0 : this->align_r(sizeof(ACE_CDR::ULongLong)); 00388 this->read_array(reinterpret_cast<char*>(x), sizeof(ACE_CDR::ULongLong), length); 00389 return this->good_bit(); 00390 }
ACE_INLINE bool OpenDDS::DCPS::Serializer::read_ushort_array | ( | ACE_CDR::UShort * | x, | |
ACE_CDR::ULong | length | |||
) |
The buffer x must be large enough to contain length elements. Return false
on failure and true
on success.
Definition at line 353 of file Serializer.inl.
References ALIGN_NONE, align_r(), alignment(), good_bit(), and read_array().
00354 { 00355 this->alignment() == Serializer::ALIGN_NONE ? 0 : this->align_r(sizeof(ACE_CDR::UShort)); 00356 this->read_array(reinterpret_cast<char*>(x), sizeof(ACE_CDR::UShort), length); 00357 return this->good_bit(); 00358 }
ACE_INLINE bool OpenDDS::DCPS::Serializer::read_wchar_array | ( | ACE_CDR::WChar * | x, | |
ACE_CDR::ULong | length | |||
) |
The buffer x must be large enough to contain length elements. Return false
on failure and true
on success.
Definition at line 327 of file Serializer.inl.
References good_bit().
00328 { 00329 for (ACE_CDR::ULong i = 0; i < length; ++i) { 00330 if (!((*this) >> ACE_InputCDR::to_wchar(x[i]))) { 00331 break; 00332 } 00333 } 00334 return this->good_bit(); 00335 }
void OpenDDS::DCPS::Serializer::reset_alignment | ( | ) |
Reset alignment as if a new instance were created.
Definition at line 43 of file Serializer.cpp.
References align_rshift_, align_wshift_, current_, MAX_ALIGN, ACE_Message_Block::rd_ptr(), and ACE_Message_Block::wr_ptr().
00044 { 00045 align_rshift_ = current_ ? ptrdiff_t(current_->rd_ptr()) % MAX_ALIGN : 0; 00046 align_wshift_ = current_ ? ptrdiff_t(current_->wr_ptr()) % MAX_ALIGN : 0; 00047 }
void OpenDDS::DCPS::Serializer::set_use_rti_serialization | ( | bool | should_use | ) | [static] |
Definition at line 246 of file Serializer.cpp.
References use_rti_serialization_.
Referenced by OpenDDS::DCPS::Service_Participant::load_common_configuration(), and OpenDDS::DCPS::Service_Participant::parse_args().
00247 { 00248 use_rti_serialization_ = should_use; 00249 }
ACE_INLINE bool OpenDDS::DCPS::Serializer::skip | ( | ACE_CDR::UShort | n, | |
int | size = 1 | |||
) |
Skip the logical rd_ptr() over a given number of bytes = n * size. If alignment is enabled, skips any padding to align to 'size' before skipping the n * size bytes. This is used by the RTPS protocol to allow reading messages from future versions of the spec which may have additional optional fields.
Definition at line 224 of file Serializer.inl.
References align_cont_r(), ALIGN_NONE, align_r(), alignment_, current_, good_bit(), good_bit_, len, ACE_Message_Block::length(), MAX_ALIGN, ACE_Message_Block::rd_ptr(), and ACE_Message_Block::wr_ptr().
Referenced by align_r(), OpenDDS::RTPS::Spdp::SpdpTransport::handle_input(), and OpenDDS::DCPS::RtpsSampleHeader::init().
00225 { 00226 if (size > 1 && this->alignment_ != ALIGN_NONE) { 00227 if (!this->current_) { 00228 this->good_bit_ = false; 00229 return false; 00230 } 00231 this->align_r(size_t(size) > MAX_ALIGN ? MAX_ALIGN : size_t(size)); 00232 } 00233 for (size_t len = static_cast<size_t>(n * size); len;) { 00234 if (!this->current_) { 00235 this->good_bit_ = false; 00236 return false; 00237 } 00238 const size_t cur_len = this->current_->length(); 00239 if (cur_len <= len) { 00240 len -= cur_len; 00241 this->current_->rd_ptr(this->current_->wr_ptr()); 00242 this->align_cont_r(); 00243 } else { 00244 this->current_->rd_ptr(len); 00245 break; 00246 } 00247 } 00248 return this->good_bit(); 00249 }
void OpenDDS::DCPS::Serializer::smemcpy | ( | char * | to, | |
const char * | from, | |||
size_t | n | |||
) | [private] |
Efficient straight copy for quad words and shorter. This is an instance method to match the swapcpy semantics.
Definition at line 50 of file Serializer.cpp.
References ACE_OS::memcpy().
Referenced by align_w(), doread(), and dowrite().
00051 { 00052 (void) ACE_OS::memcpy( 00053 reinterpret_cast<void*>(to), 00054 reinterpret_cast<const void*>(from), 00055 n); 00056 }
ACE_INLINE bool OpenDDS::DCPS::Serializer::swap_bytes | ( | ) | const |
Examine byte swapping behavior.
Definition at line 200 of file Serializer.inl.
References swap_bytes_.
Referenced by read_string().
00201 { 00202 return this->swap_bytes_; 00203 }
ACE_INLINE void OpenDDS::DCPS::Serializer::swap_bytes | ( | bool | do_swap | ) |
Establish byte swapping behavior.
Definition at line 194 of file Serializer.inl.
References swap_bytes_.
Referenced by OpenDDS::RTPS::Spdp::SpdpTransport::handle_input(), OpenDDS::DCPS::TransportHeader::init(), OpenDDS::DCPS::DataSampleHeader::init(), OpenDDS::DCPS::operator<<(), and OpenDDS::DCPS::operator>>().
00195 { 00196 this->swap_bytes_ = do_swap; 00197 }
void OpenDDS::DCPS::Serializer::swapcpy | ( | char * | to, | |
const char * | from, | |||
size_t | n | |||
) | [private] |
Efficient swapping copy for quad words and shorter. This is an instance method to allow clearing the good_bit_ on error.
Definition at line 59 of file Serializer.cpp.
References good_bit_.
Referenced by doread(), and dowrite().
00060 { 00061 // Unroll the loop... 00062 switch (n) { // 2 4 8 16 00063 case 16: 00064 to[ 15] = from[ n - 16]; // x x x 0 00065 // fallthrough 00066 case 15: 00067 to[ 14] = from[ n - 15]; // x x x 1 00068 // fallthrough 00069 case 14: 00070 to[ 13] = from[ n - 14]; // x x x 2 00071 // fallthrough 00072 case 13: 00073 to[ 12] = from[ n - 13]; // x x x 3 00074 // fallthrough 00075 case 12: 00076 to[ 11] = from[ n - 12]; // x x x 4 00077 // fallthrough 00078 case 11: 00079 to[ 10] = from[ n - 11]; // x x x 5 00080 // fallthrough 00081 case 10: 00082 to[ 9] = from[ n - 10]; // x x x 6 00083 // fallthrough 00084 case 9: 00085 to[ 8] = from[ n - 9]; // x x x 7 00086 // fallthrough 00087 case 8: 00088 to[ 7] = from[ n - 8]; // x x 0 8 00089 // fallthrough 00090 case 7: 00091 to[ 6] = from[ n - 7]; // x x 1 9 00092 // fallthrough 00093 case 6: 00094 to[ 5] = from[ n - 6]; // x x 2 10 00095 // fallthrough 00096 case 5: 00097 to[ 4] = from[ n - 5]; // x x 3 11 00098 // fallthrough 00099 case 4: 00100 to[ 3] = from[ n - 4]; // x 0 4 12 00101 // fallthrough 00102 case 3: 00103 to[ 2] = from[ n - 3]; // x 1 5 13 00104 // fallthrough 00105 case 2: 00106 to[ 1] = from[ n - 2]; // 0 2 6 14 00107 // fallthrough 00108 case 1: 00109 to[ 0] = from[ n - 1]; // 1 3 7 15 00110 // fallthrough 00111 case 0: 00112 return; 00113 default: 00114 this->good_bit_ = false; 00115 } 00116 }
bool OpenDDS::DCPS::Serializer::use_rti_serialization | ( | ) | [static] |
Definition at line 252 of file Serializer.cpp.
References use_rti_serialization_.
Referenced by OpenDDS::DCPS::DataReaderImpl_T< MessageType >::dds_demarshal(), OpenDDS::DCPS::DataWriterImpl_T< MessageType >::dds_marshal(), and OpenDDS::DCPS::DataReaderImpl_T< MessageType >::lookup_instance().
00253 { 00254 return use_rti_serialization_; 00255 }
ACE_INLINE void OpenDDS::DCPS::Serializer::write_array | ( | const char * | x, | |
size_t | size, | |||
ACE_CDR::ULong | length, | |||
bool | swap | |||
) | [private] |
Definition at line 288 of file Serializer.inl.
References buffer_write().
00290 { 00291 if (!swap || size == 1) { 00292 // 00293 // No swap, copy direct. 00294 // 00295 this->buffer_write(x, size * length, false); 00296 00297 } else { 00298 // 00299 // Swapping _must_ be done at 'size' boundaries, so we need to spin 00300 // through the array element by element. 00301 // NOTE: This assumes that there is _no_ padding between the array 00302 // elements. If this is not the case, do not use this 00303 // method. 00304 // 00305 while (length-- > 0) { 00306 this->buffer_write(x, size, true); 00307 x += size; 00308 } 00309 } 00310 }
ACE_INLINE void OpenDDS::DCPS::Serializer::write_array | ( | const char * | x, | |
size_t | size, | |||
ACE_CDR::ULong | length | |||
) | [private] |
Write an array of values to the chain. NOTE: This assumes that there is _no_ padding between the array elements. If this is not the case, do not use this method. If padding exists in the array, it will be written when _not_ swapping, and will _not_ be written when swapping, resulting in corrupted data.
Definition at line 282 of file Serializer.inl.
References swap_bytes_.
Referenced by OpenDDS::DCPS::operator<<(), write_boolean_array(), write_char_array(), write_double_array(), write_float_array(), write_long_array(), write_longdouble_array(), write_longlong_array(), write_octet_array(), write_short_array(), write_ulong_array(), write_ulonglong_array(), and write_ushort_array().
00283 { 00284 this->write_array(x, size, length, this->swap_bytes_); 00285 }
ACE_INLINE bool OpenDDS::DCPS::Serializer::write_boolean_array | ( | const ACE_CDR::Boolean * | x, | |
ACE_CDR::ULong | length | |||
) |
Note: the portion written starts at x and ends at x + length. The length is *NOT* stored into the CDR stream.
Definition at line 417 of file Serializer.inl.
References good_bit(), and write_array().
00419 { 00420 this->write_array(reinterpret_cast<const char*>(x), sizeof(ACE_CDR::Boolean), length); 00421 return this->good_bit(); 00422 }
ACE_INLINE bool OpenDDS::DCPS::Serializer::write_char_array | ( | const ACE_CDR::Char * | x, | |
ACE_CDR::ULong | length | |||
) |
The buffer x must be large enough to contain length elements. Return false
on failure and true
on success.
Definition at line 425 of file Serializer.inl.
References good_bit(), and write_array().
00426 { 00427 this->write_array(reinterpret_cast<const char*>(x), sizeof(ACE_CDR::Char), length); 00428 return this->good_bit(); 00429 }
ACE_INLINE bool OpenDDS::DCPS::Serializer::write_double_array | ( | const ACE_CDR::Double * | x, | |
ACE_CDR::ULong | length | |||
) |
The buffer x must be large enough to contain length elements. Return false
on failure and true
on success.
Definition at line 508 of file Serializer.inl.
References ALIGN_NONE, align_w(), alignment(), good_bit(), and write_array().
00509 { 00510 this->alignment() == Serializer::ALIGN_NONE ? 0 : this->align_w(sizeof(ACE_CDR::Double)); 00511 this->write_array(reinterpret_cast<const char*>(x), sizeof(ACE_CDR::Double), length); 00512 return this->good_bit(); 00513 }
ACE_INLINE bool OpenDDS::DCPS::Serializer::write_float_array | ( | const ACE_CDR::Float * | x, | |
ACE_CDR::ULong | length | |||
) |
The buffer x must be large enough to contain length elements. Return false
on failure and true
on success.
Definition at line 500 of file Serializer.inl.
References ALIGN_NONE, align_w(), alignment(), good_bit(), and write_array().
00501 { 00502 this->alignment() == Serializer::ALIGN_NONE ? 0 : this->align_w(sizeof(ACE_CDR::Float)); 00503 this->write_array(reinterpret_cast<const char*>(x), sizeof(ACE_CDR::Float), length); 00504 return this->good_bit(); 00505 }
ACE_INLINE bool OpenDDS::DCPS::Serializer::write_long_array | ( | const ACE_CDR::Long * | x, | |
ACE_CDR::ULong | length | |||
) |
The buffer x must be large enough to contain length elements. Return false
on failure and true
on success.
Definition at line 466 of file Serializer.inl.
References ALIGN_NONE, align_w(), alignment(), good_bit(), and write_array().
00467 { 00468 this->alignment() == Serializer::ALIGN_NONE ? 0 : this->align_w(sizeof(ACE_CDR::Long)); 00469 this->write_array(reinterpret_cast<const char*>(x), sizeof(ACE_CDR::Long), length); 00470 return this->good_bit(); 00471 }
ACE_INLINE bool OpenDDS::DCPS::Serializer::write_longdouble_array | ( | const ACE_CDR::LongDouble * | x, | |
ACE_CDR::ULong | length | |||
) |
The buffer x must be large enough to contain length elements. Return false
on failure and true
on success.
Definition at line 516 of file Serializer.inl.
References ALIGN_NONE, align_w(), alignment(), good_bit(), and write_array().
00518 { 00519 this->alignment() == Serializer::ALIGN_NONE ? 0 : this->align_w(8); 00520 this->write_array(reinterpret_cast<const char*>(x), sizeof(ACE_CDR::LongDouble), length); 00521 return this->good_bit(); 00522 }
ACE_INLINE bool OpenDDS::DCPS::Serializer::write_longlong_array | ( | const ACE_CDR::LongLong * | x, | |
ACE_CDR::ULong | length | |||
) |
The buffer x must be large enough to contain length elements. Return false
on failure and true
on success.
Definition at line 482 of file Serializer.inl.
References ALIGN_NONE, align_w(), alignment(), good_bit(), and write_array().
00484 { 00485 this->alignment() == Serializer::ALIGN_NONE ? 0 : this->align_w(sizeof(ACE_CDR::LongLong)); 00486 this->write_array(reinterpret_cast<const char*>(x), sizeof(ACE_CDR::LongLong), length); 00487 return this->good_bit(); 00488 }
ACE_INLINE bool OpenDDS::DCPS::Serializer::write_octet_array | ( | const ACE_CDR::Octet * | x, | |
ACE_CDR::ULong | length | |||
) |
The buffer x must be large enough to contain length elements. Return false
on failure and true
on success.
Definition at line 443 of file Serializer.inl.
References good_bit(), and write_array().
Referenced by OpenDDS::DCPS::RtpsUdpSendStrategy::marshal_transport_header().
00444 { 00445 this->write_array(reinterpret_cast<const char*>(x), sizeof(ACE_CDR::Octet), length); 00446 return this->good_bit(); 00447 }
ACE_INLINE bool OpenDDS::DCPS::Serializer::write_short_array | ( | const ACE_CDR::Short * | x, | |
ACE_CDR::ULong | length | |||
) |
The buffer x must be large enough to contain length elements. Return false
on failure and true
on success.
Definition at line 450 of file Serializer.inl.
References ALIGN_NONE, align_w(), alignment(), good_bit(), and write_array().
00451 { 00452 this->alignment() == Serializer::ALIGN_NONE ? 0 : this->align_w(sizeof(ACE_CDR::Short)); 00453 this->write_array(reinterpret_cast<const char*>(x), sizeof(ACE_CDR::Short), length); 00454 return this->good_bit(); 00455 }
ACE_INLINE bool OpenDDS::DCPS::Serializer::write_ulong_array | ( | const ACE_CDR::ULong * | x, | |
ACE_CDR::ULong | length | |||
) |
The buffer x must be large enough to contain length elements. Return false
on failure and true
on success.
Definition at line 474 of file Serializer.inl.
References ALIGN_NONE, align_w(), alignment(), good_bit(), and write_array().
00475 { 00476 this->alignment() == Serializer::ALIGN_NONE ? 0 : this->align_w(sizeof(ACE_CDR::ULong)); 00477 this->write_array(reinterpret_cast<const char*>(x), sizeof(ACE_CDR::ULong), length); 00478 return this->good_bit(); 00479 }
ACE_INLINE bool OpenDDS::DCPS::Serializer::write_ulonglong_array | ( | const ACE_CDR::ULongLong * | x, | |
ACE_CDR::ULong | length | |||
) |
The buffer x must be large enough to contain length elements. Return false
on failure and true
on success.
Definition at line 491 of file Serializer.inl.
References ALIGN_NONE, align_w(), alignment(), good_bit(), and write_array().
00493 { 00494 this->alignment() == Serializer::ALIGN_NONE ? 0 : this->align_w(sizeof(ACE_CDR::ULongLong)); 00495 this->write_array(reinterpret_cast<const char*>(x), sizeof(ACE_CDR::ULongLong), length); 00496 return this->good_bit(); 00497 }
ACE_INLINE bool OpenDDS::DCPS::Serializer::write_ushort_array | ( | const ACE_CDR::UShort * | x, | |
ACE_CDR::ULong | length | |||
) |
The buffer x must be large enough to contain length elements. Return false
on failure and true
on success.
Definition at line 458 of file Serializer.inl.
References ALIGN_NONE, align_w(), alignment(), good_bit(), and write_array().
00459 { 00460 this->alignment() == Serializer::ALIGN_NONE ? 0 : this->align_w(sizeof(ACE_CDR::UShort)); 00461 this->write_array(reinterpret_cast<const char*>(x), sizeof(ACE_CDR::UShort), length); 00462 return this->good_bit(); 00463 }
ACE_INLINE bool OpenDDS::DCPS::Serializer::write_wchar_array | ( | const ACE_CDR::WChar * | x, | |
ACE_CDR::ULong | length | |||
) |
The buffer x must be large enough to contain length elements. Return false
on failure and true
on success.
Definition at line 432 of file Serializer.inl.
References good_bit().
00433 { 00434 for (ACE_CDR::ULong i = 0; i < length; ++i) { 00435 if (!((*this) << ACE_OutputCDR::from_wchar(x[i]))) { 00436 break; 00437 } 00438 } 00439 return this->good_bit(); 00440 }
OpenDDS_Dcps_Export bool operator<< | ( | Serializer & | s, | |
const std::string & | x | |||
) | [friend] |
OpenDDS_Dcps_Export bool operator<< | ( | Serializer & | s, | |
ACE_OutputCDR::from_wstring | x | |||
) | [friend] |
OpenDDS_Dcps_Export bool operator<< | ( | Serializer & | s, | |
ACE_OutputCDR::from_string | x | |||
) | [friend] |
OpenDDS_Dcps_Export bool operator<< | ( | Serializer & | s, | |
ACE_OutputCDR::from_octet | x | |||
) | [friend] |
OpenDDS_Dcps_Export bool operator<< | ( | Serializer & | s, | |
ACE_OutputCDR::from_wchar | x | |||
) | [friend] |
OpenDDS_Dcps_Export bool operator<< | ( | Serializer & | s, | |
ACE_OutputCDR::from_char | x | |||
) | [friend] |
OpenDDS_Dcps_Export bool operator<< | ( | Serializer & | s, | |
ACE_OutputCDR::from_boolean | x | |||
) | [friend] |
OpenDDS_Dcps_Export bool operator<< | ( | Serializer & | s, | |
const ACE_CDR::WChar * | x | |||
) | [friend] |
OpenDDS_Dcps_Export bool operator<< | ( | Serializer & | s, | |
const ACE_CDR::Char * | x | |||
) | [friend] |
OpenDDS_Dcps_Export bool operator<< | ( | Serializer & | s, | |
ACE_CDR::Double | x | |||
) | [friend] |
OpenDDS_Dcps_Export bool operator<< | ( | Serializer & | s, | |
ACE_CDR::Float | x | |||
) | [friend] |
OpenDDS_Dcps_Export bool operator<< | ( | Serializer & | s, | |
ACE_CDR::LongDouble | x | |||
) | [friend] |
OpenDDS_Dcps_Export bool operator<< | ( | Serializer & | s, | |
ACE_CDR::ULongLong | x | |||
) | [friend] |
OpenDDS_Dcps_Export bool operator<< | ( | Serializer & | s, | |
ACE_CDR::LongLong | x | |||
) | [friend] |
OpenDDS_Dcps_Export bool operator<< | ( | Serializer & | s, | |
ACE_CDR::ULong | x | |||
) | [friend] |
OpenDDS_Dcps_Export bool operator<< | ( | Serializer & | s, | |
ACE_CDR::Long | x | |||
) | [friend] |
OpenDDS_Dcps_Export bool operator<< | ( | Serializer & | s, | |
ACE_CDR::UShort | x | |||
) | [friend] |
OpenDDS_Dcps_Export bool operator<< | ( | Serializer & | s, | |
ACE_CDR::Short | x | |||
) | [friend] |
OpenDDS_Dcps_Export bool operator<< | ( | Serializer & | s, | |
ACE_CDR::Char | x | |||
) | [friend] |
OpenDDS_Dcps_Export bool operator>> | ( | Serializer & | s, | |
std::string & | x | |||
) | [friend] |
OpenDDS_Dcps_Export bool operator>> | ( | Serializer & | s, | |
ACE_InputCDR::to_wstring | x | |||
) | [friend] |
OpenDDS_Dcps_Export bool operator>> | ( | Serializer & | s, | |
ACE_InputCDR::to_string | x | |||
) | [friend] |
OpenDDS_Dcps_Export bool operator>> | ( | Serializer & | s, | |
ACE_InputCDR::to_octet | x | |||
) | [friend] |
OpenDDS_Dcps_Export bool operator>> | ( | Serializer & | s, | |
ACE_InputCDR::to_wchar | x | |||
) | [friend] |
OpenDDS_Dcps_Export bool operator>> | ( | Serializer & | s, | |
ACE_InputCDR::to_char | x | |||
) | [friend] |
OpenDDS_Dcps_Export bool operator>> | ( | Serializer & | s, | |
ACE_InputCDR::to_boolean | x | |||
) | [friend] |
OpenDDS_Dcps_Export bool operator>> | ( | Serializer & | s, | |
ACE_CDR::WChar *& | x | |||
) | [friend] |
OpenDDS_Dcps_Export bool operator>> | ( | Serializer & | s, | |
ACE_CDR::Char *& | x | |||
) | [friend] |
OpenDDS_Dcps_Export bool operator>> | ( | Serializer & | s, | |
ACE_CDR::Double & | x | |||
) | [friend] |
OpenDDS_Dcps_Export bool operator>> | ( | Serializer & | s, | |
ACE_CDR::Float & | x | |||
) | [friend] |
OpenDDS_Dcps_Export bool operator>> | ( | Serializer & | s, | |
ACE_CDR::LongDouble & | x | |||
) | [friend] |
OpenDDS_Dcps_Export bool operator>> | ( | Serializer & | s, | |
ACE_CDR::ULongLong & | x | |||
) | [friend] |
OpenDDS_Dcps_Export bool operator>> | ( | Serializer & | s, | |
ACE_CDR::LongLong & | x | |||
) | [friend] |
OpenDDS_Dcps_Export bool operator>> | ( | Serializer & | s, | |
ACE_CDR::ULong & | x | |||
) | [friend] |
OpenDDS_Dcps_Export bool operator>> | ( | Serializer & | s, | |
ACE_CDR::Long & | x | |||
) | [friend] |
OpenDDS_Dcps_Export bool operator>> | ( | Serializer & | s, | |
ACE_CDR::UShort & | x | |||
) | [friend] |
OpenDDS_Dcps_Export bool operator>> | ( | Serializer & | s, | |
ACE_CDR::Short & | x | |||
) | [friend] |
OpenDDS_Dcps_Export bool operator>> | ( | Serializer & | s, | |
ACE_CDR::Char & | x | |||
) | [friend] |
const char OpenDDS::DCPS::Serializer::ALIGN_PAD = {0} [static, private] |
Definition at line 325 of file Serializer.h.
Referenced by align_w().
unsigned char OpenDDS::DCPS::Serializer::align_rshift_ [private] |
Number of bytes off of max alignment (8) that the current_ block's rd_ptr() started at.
Definition at line 318 of file Serializer.h.
Referenced by align_cont_r(), align_r(), and reset_alignment().
unsigned char OpenDDS::DCPS::Serializer::align_wshift_ [private] |
Number of bytes off of max alignment (8) that the current_ block's wr_ptr() started at.
Definition at line 322 of file Serializer.h.
Referenced by align_cont_w(), align_w(), and reset_alignment().
Current alignment mode, see Alignment enum above.
Definition at line 314 of file Serializer.h.
Referenced by align_w(), alignment(), doread(), dowrite(), read_string(), and skip().
Currently active message block in chain.
Definition at line 305 of file Serializer.h.
Referenced by align_cont_r(), align_cont_w(), align_r(), align_w(), doread(), dowrite(), length(), read_string(), reset_alignment(), and skip().
bool OpenDDS::DCPS::Serializer::good_bit_ [private] |
Indicates the current state of the stream abstraction.
Definition at line 311 of file Serializer.h.
Referenced by align_w(), doread(), dowrite(), good_bit(), length(), OpenDDS::DCPS::operator<<(), OpenDDS::DCPS::operator>>(), read_string(), skip(), and swapcpy().
const size_t OpenDDS::DCPS::Serializer::MAX_ALIGN = 8 [static, private] |
Definition at line 324 of file Serializer.h.
Referenced by align_cont_r(), align_cont_w(), reset_alignment(), and skip().
const bool OpenDDS::DCPS::Serializer::SWAP_BE = false [static] |
Definition at line 337 of file Serializer.h.
Referenced by OpenDDS::Security::extract_participant_guid_from_cpdata(), OpenDDS::Security::SSL::hash_serialized_impl::operator()(), OpenDDS::DCPS::operator<<(), OpenDDS::DCPS::operator>>(), and read_string().
bool OpenDDS::DCPS::Serializer::swap_bytes_ [private] |
Indicates whether bytes will be swapped for this stream.
Definition at line 308 of file Serializer.h.
Referenced by read_array(), swap_bytes(), and write_array().
bool OpenDDS::DCPS::Serializer::use_rti_serialization_ [static, private] |
Definition at line 326 of file Serializer.h.
Referenced by set_use_rti_serialization(), and use_rti_serialization().
const size_t OpenDDS::DCPS::Serializer::WCHAR_SIZE = 2 [static] |
Definition at line 329 of file Serializer.h.
Referenced by OpenDDS::DCPS::gen_max_marshaled_size(), OpenDDS::DCPS::max_marshaled_size_wchar(), OpenDDS::DCPS::operator<<(), OpenDDS::DCPS::operator>>(), and read_string().