OpenDDS  Snapshot(2023/04/28-20:55)
Classes | Public Types | Public Member Functions | Static Public Attributes | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
OpenDDS::DCPS::Serializer Class Reference

Class to serialize and deserialize data for DDS. More...

#include <Serializer.h>

Collaboration diagram for OpenDDS::DCPS::Serializer:
Collaboration graph
[legend]

Classes

struct  FromBoundedString
 
struct  RdState
 
struct  ScopedAlignmentContext
 
struct  ToBoundedString
 

Public Types

enum  ConstructionStatus { ConstructionSuccessful, ElementConstructionFailure, BoundConstructionFailure }
 
typedef ACE_CDR::Char *(* StrAllocate) (ACE_CDR::ULong)
 
typedef void(* StrFree) (ACE_CDR::Char *)
 
typedef ACE_CDR::WChar *(* WStrAllocate) (ACE_CDR::ULong)
 
typedef void(* WStrFree) (ACE_CDR::WChar *)
 

Public Member Functions

 Serializer (ACE_Message_Block *chain, const Encoding &encoding)
 
 Serializer (ACE_Message_Block *chain, Encoding::Kind kind, Endianness endianness=ENDIAN_NATIVE)
 
 Serializer (ACE_Message_Block *chain, Encoding::Kind kind, bool swap_bytes)
 
virtual ~Serializer ()
 
const Encodingencoding () const
 
void encoding (const Encoding &value)
 
void swap_bytes (bool do_swap)
 
bool swap_bytes () const
 
Endianness endianness () const
 
void endianness (Endianness value)
 
Encoding::Alignment alignment () const
 
void alignment (Encoding::Alignment value)
 
void reset_alignment ()
 Reset alignment as if a new instance were created. More...
 
bool good_bit () const
 
size_t length () const
 Number of bytes left to read in message block chain. More...
 
size_t read_string (ACE_CDR::Char *&dest, StrAllocate str_alloc=0, StrFree str_free=0)
 
void free_string (ACE_CDR::Char *str, StrFree str_free=0)
 
size_t read_string (ACE_CDR::WChar *&dest, WStrAllocate str_alloc=0, WStrFree str_free=0)
 
void free_string (ACE_CDR::WChar *str, WStrFree str_free=0)
 
bool skip (size_t n, int size=1)
 
ACE_Message_Blocktrim (size_t n) const
 
const char * pos_rd () const
 
const char * pos_wr () const
 
size_t rpos () const
 Examine the logical reading position of the stream. More...
 
size_t wpos () const
 Examine the logical writing position of the stream. More...
 
ACE_Message_Blockcurrent () const
 
void buffer_read (char *dest, size_t size, bool swap)
 Read from the chain into a destination buffer. More...
 
bool align_r (size_t alignment)
 
bool align_w (size_t alignment)
 
bool read_parameter_id (unsigned &id, size_t &size, bool &must_understand)
 
bool write_parameter_id (const unsigned id, size_t size, bool must_understand=false)
 
bool write_list_end_parameter_id ()
 
bool skip_delimiter ()
 
bool read_delimiter (size_t &size)
 
bool write_delimiter (size_t size)
 
ConstructionStatus get_construction_status () const
 
void set_construction_status (ConstructionStatus cs)
 
template<typename T >
bool peek_helper (ACE_Message_Block *const block, size_t bytes, T &t)
 
template<typename T >
bool peek (T &t)
 
bool peek (ACE_CDR::ULong &t)
 
RdState rdstate () const
 
void rdstate (const RdState &state)
 
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 Attributes

static const ACE_CDR::ULong emheader_must_understand = 1U << 31U
 
static const ACE_CDR::ULong MEMBER_ID_MAX = 0x0FFFFFFF
 Maximum value for member id. More...
 
static const ACE_CDR::ULong MEMBER_ID_MASK = MEMBER_ID_MAX
 
static const ACE_CDR::UShort pid_extended = 0x3f01
 
static const ACE_CDR::UShort pid_list_end = 0x3f02
 
static const ACE_CDR::UShort pid_impl_extension = 0x8000
 
static const ACE_CDR::UShort pid_must_understand = 0x4000
 

Private Member Functions

void buffer_write (const char *src, size_t size, bool swap)
 Write to the chain from a source buffer. More...
 
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. More...
 
size_t dowrite (const char *dest, size_t size, bool swap, size_t offset)
 Implementation of the actual write to the chain. More...
 
void align_cont_r ()
 Update alignment state when a cont() chain is followed during a read. More...
 
void align_cont_w ()
 Update alignment state when a cont() chain is followed during a write. More...
 
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 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)
 

Static Private Member Functions

static unsigned char offset (char *index, size_t start, size_t align)
 

Private Attributes

ACE_Message_Blockcurrent_
 Currently active message block in chain. More...
 
Encoding encoding_
 Encoding Settings. More...
 
bool swap_bytes_
 Indicates whether bytes will be swapped for this stream. More...
 
bool good_bit_
 Indicates the current state of the stream abstraction. More...
 
ConstructionStatus construction_status_
 The way to judge whether tryconstruct trim is able to be properly done. More...
 
unsigned char align_rshift_
 
unsigned char align_wshift_
 
size_t rpos_
 Logical reading position of the stream. More...
 
size_t wpos_
 Logical writing position of the stream. More...
 

Static Private Attributes

static const char ALIGN_PAD [Encoding::ALIGN_MAX] = {0}
 Buffer that is copied for zero padding. More...
 

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::Float x)
 
OpenDDS_Dcps_Export bool operator<< (Serializer &s, ACE_CDR::Double x)
 
OpenDDS_Dcps_Export bool operator<< (Serializer &s, ACE_CDR::LongDouble 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 String &x)
 
OpenDDS_Dcps_Export bool operator<< (Serializer &s, FromBoundedString< char > 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::Float &x)
 
OpenDDS_Dcps_Export bool operator>> (Serializer &s, ACE_CDR::Double &x)
 
OpenDDS_Dcps_Export bool operator>> (Serializer &s, ACE_CDR::LongDouble &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, String &x)
 
OpenDDS_Dcps_Export bool operator>> (Serializer &s, ToBoundedString< char > x)
 

Detailed Description

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 369 of file Serializer.h.

Member Typedef Documentation

◆ StrAllocate

typedef ACE_CDR::Char*(* OpenDDS::DCPS::Serializer::StrAllocate) (ACE_CDR::ULong)

Definition at line 437 of file Serializer.h.

◆ StrFree

typedef void(* OpenDDS::DCPS::Serializer::StrFree) (ACE_CDR::Char *)

Definition at line 438 of file Serializer.h.

◆ WStrAllocate

typedef ACE_CDR::WChar*(* OpenDDS::DCPS::Serializer::WStrAllocate) (ACE_CDR::ULong)

Definition at line 439 of file Serializer.h.

◆ WStrFree

typedef void(* OpenDDS::DCPS::Serializer::WStrFree) (ACE_CDR::WChar *)

Definition at line 440 of file Serializer.h.

Member Enumeration Documentation

◆ ConstructionStatus

Enumerator
ConstructionSuccessful 
ElementConstructionFailure 
BoundConstructionFailure 

Definition at line 742 of file Serializer.h.

Constructor & Destructor Documentation

◆ Serializer() [1/3]

OpenDDS::DCPS::Serializer::Serializer ( ACE_Message_Block chain,
const Encoding encoding 
)

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.

This constructor is meant for using a specific predefined encoding scheme.

Definition at line 352 of file Serializer.cpp.

References encoding(), and reset_alignment().

353  : current_(chain)
354  , good_bit_(true)
356  , align_rshift_(0)
357  , align_wshift_(0)
358  , rpos_(0)
359  , wpos_(0)
360 {
361  encoding(enc);
362  reset_alignment();
363 }
ConstructionStatus construction_status_
The way to judge whether tryconstruct trim is able to be properly done.
Definition: Serializer.h:876
void reset_alignment()
Reset alignment as if a new instance were created.
Definition: Serializer.cpp:443
unsigned char align_wshift_
Definition: Serializer.h:888
size_t wpos_
Logical writing position of the stream.
Definition: Serializer.h:894
bool good_bit_
Indicates the current state of the stream abstraction.
Definition: Serializer.h:873
const Encoding & encoding() const
Definition: Serializer.inl:199
ACE_Message_Block * current_
Currently active message block in chain.
Definition: Serializer.h:864
unsigned char align_rshift_
Definition: Serializer.h:882
size_t rpos_
Logical reading position of the stream.
Definition: Serializer.h:891

◆ Serializer() [2/3]

OpenDDS::DCPS::Serializer::Serializer ( ACE_Message_Block chain,
Encoding::Kind  kind,
Endianness  endianness = ENDIAN_NATIVE 
)

More convenient version of the constructor above if you don't need to reuse the Encoding object.

Definition at line 365 of file Serializer.cpp.

References encoding(), and reset_alignment().

367  : current_(chain)
368  , good_bit_(true)
370  , align_rshift_(0)
371  , align_wshift_(0)
372  , rpos_(0)
373  , wpos_(0)
374 {
375  encoding(Encoding(kind, endianness));
376  reset_alignment();
377 }
ConstructionStatus construction_status_
The way to judge whether tryconstruct trim is able to be properly done.
Definition: Serializer.h:876
void reset_alignment()
Reset alignment as if a new instance were created.
Definition: Serializer.cpp:443
unsigned char align_wshift_
Definition: Serializer.h:888
Endianness endianness() const
Definition: Serializer.inl:220
size_t wpos_
Logical writing position of the stream.
Definition: Serializer.h:894
bool good_bit_
Indicates the current state of the stream abstraction.
Definition: Serializer.h:873
const Encoding & encoding() const
Definition: Serializer.inl:199
ACE_Message_Block * current_
Currently active message block in chain.
Definition: Serializer.h:864
unsigned char align_rshift_
Definition: Serializer.h:882
size_t rpos_
Logical reading position of the stream.
Definition: Serializer.h:891

◆ Serializer() [3/3]

OpenDDS::DCPS::Serializer::Serializer ( ACE_Message_Block chain,
Encoding::Kind  kind,
bool  swap_bytes 
)

Equivalent to: Serializer(chain, kind, swap_bytes ? ENDIAN_NONNATIVE : ENDIAN_NATIVE)

Definition at line 379 of file Serializer.cpp.

References encoding(), and reset_alignment().

381  : current_(chain)
382  , good_bit_(true)
384  , align_rshift_(0)
385  , align_wshift_(0)
386  , rpos_(0)
387  , wpos_(0)
388 {
389  encoding(Encoding(kind, swap_bytes));
390  reset_alignment();
391 }
ConstructionStatus construction_status_
The way to judge whether tryconstruct trim is able to be properly done.
Definition: Serializer.h:876
void reset_alignment()
Reset alignment as if a new instance were created.
Definition: Serializer.cpp:443
unsigned char align_wshift_
Definition: Serializer.h:888
size_t wpos_
Logical writing position of the stream.
Definition: Serializer.h:894
bool good_bit_
Indicates the current state of the stream abstraction.
Definition: Serializer.h:873
const Encoding & encoding() const
Definition: Serializer.inl:199
ACE_Message_Block * current_
Currently active message block in chain.
Definition: Serializer.h:864
unsigned char align_rshift_
Definition: Serializer.h:882
size_t rpos_
Logical reading position of the stream.
Definition: Serializer.h:891

◆ ~Serializer()

OpenDDS::DCPS::Serializer::~Serializer ( )
virtual

Definition at line 393 of file Serializer.cpp.

394 {
395 }

Member Function Documentation

◆ align_cont_r()

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 875 of file Serializer.inl.

References ACE_INLINE, OpenDDS::STUN::encoding(), and OpenDDS::DCPS::Encoding::max_align().

876 {
877  const size_t max_align = encoding().max_align();
878  const size_t thisblock =
879  max_align ? (ptrdiff_t(current_->rd_ptr()) - align_rshift_) % max_align : 0;
880 
881  current_ = current_->cont();
882 
883  if (current_ && max_align) {
884  align_rshift_ = offset(current_->rd_ptr(), thisblock, max_align);
885  }
886 }
char * rd_ptr(void) const
ACE_Message_Block * cont(void) const
size_t max_align() const
Return the maximum alignment dictated by the alignment policy.
Definition: Serializer.inl:112
const Encoding & encoding() const
Definition: Serializer.inl:199
ACE_Message_Block * current_
Currently active message block in chain.
Definition: Serializer.h:864
static unsigned char offset(char *index, size_t start, size_t align)
Definition: Serializer.inl:869
unsigned char align_rshift_
Definition: Serializer.h:882

◆ align_cont_w()

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 889 of file Serializer.inl.

References ACE_INLINE, OpenDDS::STUN::encoding(), and OpenDDS::DCPS::Encoding::max_align().

890 {
891  const size_t max_align = encoding().max_align();
892  const size_t thisblock =
893  max_align ? (ptrdiff_t(current_->wr_ptr()) - align_wshift_) % max_align : 0;
894 
895  current_ = current_->cont();
896 
897  if (current_ && max_align) {
898  align_wshift_ = offset(current_->wr_ptr(), thisblock, max_align);
899  }
900 }
unsigned char align_wshift_
Definition: Serializer.h:888
ACE_Message_Block * cont(void) const
char * wr_ptr(void) const
size_t max_align() const
Return the maximum alignment dictated by the alignment policy.
Definition: Serializer.inl:112
const Encoding & encoding() const
Definition: Serializer.inl:199
ACE_Message_Block * current_
Currently active message block in chain.
Definition: Serializer.h:864
static unsigned char offset(char *index, size_t start, size_t align)
Definition: Serializer.inl:869

◆ align_r()

ACE_INLINE bool 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 813 of file Serializer.inl.

References ACE_INLINE, OpenDDS::DCPS::Encoding::alignment(), OpenDDS::STUN::encoding(), and OpenDDS::DCPS::Encoding::max_align().

Referenced by OpenDDS::DCPS::operator>>(), read_parameter_id(), and OpenDDS::DCPS::RtpsUdpReceiveStrategy::sec_submsg_to_octets().

814 {
815  if (!alignment()) {
816  return true;
817  }
818  if (!current_) {
819  good_bit_ = false;
820  return false;
821  }
822  al = (std::min)(al, encoding().max_align());
823  const size_t len =
824  (al - ptrdiff_t(current_->rd_ptr()) + align_rshift_) % al;
825 
826  return skip(static_cast<ACE_CDR::UShort>(len));
827 }
bool skip(size_t n, int size=1)
Definition: Serializer.inl:443
Encoding::Alignment alignment() const
Definition: Serializer.inl:417
char * rd_ptr(void) const
bool good_bit_
Indicates the current state of the stream abstraction.
Definition: Serializer.h:873
size_t max_align() const
Return the maximum alignment dictated by the alignment policy.
Definition: Serializer.inl:112
const Encoding & encoding() const
Definition: Serializer.inl:199
ACE_Message_Block * current_
Currently active message block in chain.
Definition: Serializer.h:864
unsigned char align_rshift_
Definition: Serializer.h:882

◆ align_w()

ACE_INLINE bool 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 830 of file Serializer.inl.

References ACE_INLINE, OpenDDS::DCPS::Encoding::alignment(), OpenDDS::STUN::encoding(), OpenDDS::DCPS::Encoding::max_align(), and OpenDDS::DCPS::Encoding::zero_init_padding().

Referenced by OpenDDS::Security::CryptoBuiltInImpl::encode_rtps_message(), OpenDDS::Security::CryptoBuiltInImpl::encode_submessage(), OpenDDS::DCPS::operator<<(), OpenDDS::DCPS::RtpsUdpDataLink::submsgs_to_msgblock(), and write_parameter_id().

831 {
832  if (!alignment()) {
833  return true;
834  }
835  if (!current_) {
836  good_bit_ = false;
837  return false;
838  }
839  al = (std::min)(al, encoding().max_align());
840  size_t len =
841  (al - ptrdiff_t(current_->wr_ptr()) + align_wshift_) % al;
842  while (len) {
843  if (!current_) {
844  good_bit_ = false;
845  break;
846  }
847  const size_t cur_spc = current_->space();
848  if (cur_spc <= len) {
849  len -= cur_spc;
850  if (encoding().zero_init_padding()) {
851  smemcpy(current_->wr_ptr(), ALIGN_PAD, cur_spc);
852  }
853  current_->wr_ptr(cur_spc);
854  wpos_ += cur_spc;
855  align_cont_w();
856  } else {
857  if (encoding().zero_init_padding()) {
858  smemcpy(current_->wr_ptr(), ALIGN_PAD, len);
859  }
860  current_->wr_ptr(len);
861  wpos_ += len;
862  break;
863  }
864  }
865  return good_bit_;
866 }
Encoding::Alignment alignment() const
Definition: Serializer.inl:417
unsigned char align_wshift_
Definition: Serializer.h:888
size_t wpos_
Logical writing position of the stream.
Definition: Serializer.h:894
char * wr_ptr(void) const
void align_cont_w()
Update alignment state when a cont() chain is followed during a write.
Definition: Serializer.inl:889
bool good_bit_
Indicates the current state of the stream abstraction.
Definition: Serializer.h:873
size_t max_align() const
Return the maximum alignment dictated by the alignment policy.
Definition: Serializer.inl:112
size_t space(void) const
void smemcpy(char *to, const char *from, size_t n)
Definition: Serializer.cpp:453
static const char ALIGN_PAD[Encoding::ALIGN_MAX]
Buffer that is copied for zero padding.
Definition: Serializer.h:897
const Encoding & encoding() const
Definition: Serializer.inl:199
ACE_Message_Block * current_
Currently active message block in chain.
Definition: Serializer.h:864

◆ alignment() [1/2]

ACE_INLINE Encoding::Alignment OpenDDS::DCPS::Serializer::alignment ( ) const

Definition at line 417 of file Serializer.inl.

References ACE_INLINE, OpenDDS::DCPS::Encoding::alignment(), and OpenDDS::STUN::encoding().

418 {
419  return encoding().alignment();
420 }
Alignment alignment() const
Definition: Serializer.inl:76
const Encoding & encoding() const
Definition: Serializer.inl:199

◆ alignment() [2/2]

ACE_INLINE void OpenDDS::DCPS::Serializer::alignment ( Encoding::Alignment  value)

Definition at line 423 of file Serializer.inl.

References ACE_INLINE, OpenDDS::DCPS::Encoding::alignment(), OpenDDS::STUN::encoding(), and encoding_.

424 {
425  Encoding enc = encoding_;
426  enc.alignment(value);
427  encoding(enc);
428 }
const LogLevel::Value value
Definition: debug.cpp:61
Alignment alignment() const
Definition: Serializer.inl:76
Encoding encoding_
Encoding Settings.
Definition: Serializer.h:867
const Encoding & encoding() const
Definition: Serializer.inl:199

◆ buffer_read()

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 305 of file Serializer.inl.

References ACE_INLINE.

Referenced by OpenDDS::DCPS::operator>>(), and read_string().

306 {
307  size_t offset = 0;
308 
309  while (size > offset) {
310  offset = doread(dest, size, swap, offset);
311  }
312 }
void swap(MessageBlock &lhs, MessageBlock &rhs)
size_t doread(char *dest, size_t size, bool swap, size_t offset)
Implementation of the actual read from the chain.
Definition: Serializer.inl:229
static unsigned char offset(char *index, size_t start, size_t align)
Definition: Serializer.inl:869

◆ buffer_write()

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 393 of file Serializer.inl.

References ACE_INLINE.

Referenced by OpenDDS::DCPS::operator<<().

394 {
395  size_t offset = 0;
396 
397  while (size > offset) {
398  offset = dowrite(src, size, swap, offset);
399  }
400 }
void swap(MessageBlock &lhs, MessageBlock &rhs)
size_t dowrite(const char *dest, size_t size, bool swap, size_t offset)
Implementation of the actual write to the chain.
Definition: Serializer.inl:318
static unsigned char offset(char *index, size_t start, size_t align)
Definition: Serializer.inl:869

◆ current()

ACE_Message_Block* OpenDDS::DCPS::Serializer::current ( void  ) const
inline

Definition at line 480 of file Serializer.h.

References OpenDDS_Dcps_Export, and OpenDDS::DCPS::operator<<().

Referenced by peek(), and OpenDDS::XTypes::DynamicDataXcdrReadImpl::skip_aggregated_member().

481  {
482  return current_;
483  }
ACE_Message_Block * current_
Currently active message block in chain.
Definition: Serializer.h:864

◆ doread()

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 229 of file Serializer.inl.

References ACE_INLINE, OpenDDS::DCPS::Encoding::alignment(), and OpenDDS::STUN::encoding().

230 {
231  //
232  // Ensure we work only with buffer data.
233  //
234  if (current_ == 0) {
235  good_bit_ = false;
236  return size;
237  }
238 
239  //
240  // Determine how much data will remain to be read after the current
241  // buffer has been entirely read.
242  //
243  const size_t len = current_->length();
244  const size_t remainder = (size - offset > len) ? size - offset - len : 0;
245 
246  //
247  // Derive how much data we need to read from the current buffer.
248  //
249  const size_t initial = size - offset - remainder;
250 
251  //
252  // Copy or swap the source data from the current buffer into the
253  // destination.
254  //
255  swap
256  ? swapcpy(dest + remainder, current_->rd_ptr(), initial)
257  : smemcpy(dest + offset, current_->rd_ptr(), initial);
258  current_->rd_ptr(initial);
259 
260  // Update the logical reading position in the stream.
261  rpos_ += initial;
262 
263  // smemcpy
264  //
265  // dest b1 b2 b3 offset remainder initial
266  // xxxxxxxx 01 23 4567xx
267  // ^ 0 6 2
268  // 01xxxxxx 01 23 4567xx
269  // ^ 2 4 2
270  // 0123xxxx 01 23 4567xx
271  // ^ 4 0 4
272  // 01234567 01 23 4567xx
273  // ^
274 
275  // swapcpy
276  //
277  // dest b1 b2 b3 offset remainder initial
278  // xxxxxxxx 01 23 4567xx
279  // ^ 0 6 2
280  // xxxxxx10 01 23 4567xx
281  // ^ 2 4 2
282  // xxxx3210 01 23 4567xx
283  // ^ 4 0 4
284  // 76543210 01 23 4567xx
285  // ^
286 
287  //
288  // Move to the next chained block if this one is spent.
289  //
290  if (current_->length() == 0) {
291  if (encoding().alignment()) {
292  align_cont_r();
293  } else {
294  current_ = current_->cont();
295  }
296  }
297 
298  //
299  // Return the current location in the read.
300  //
301  return offset + initial;
302 }
void swap(MessageBlock &lhs, MessageBlock &rhs)
size_t length(void) const
Alignment alignment() const
Definition: Serializer.inl:76
char * rd_ptr(void) const
ACE_Message_Block * cont(void) const
bool good_bit_
Indicates the current state of the stream abstraction.
Definition: Serializer.h:873
void smemcpy(char *to, const char *from, size_t n)
Definition: Serializer.cpp:453
void align_cont_r()
Update alignment state when a cont() chain is followed during a read.
Definition: Serializer.inl:875
void swapcpy(char *to, const char *from, size_t n)
Definition: Serializer.cpp:460
const Encoding & encoding() const
Definition: Serializer.inl:199
ACE_Message_Block * current_
Currently active message block in chain.
Definition: Serializer.h:864
static unsigned char offset(char *index, size_t start, size_t align)
Definition: Serializer.inl:869
size_t rpos_
Logical reading position of the stream.
Definition: Serializer.h:891

◆ dowrite()

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 318 of file Serializer.inl.

References ACE_INLINE, OpenDDS::DCPS::Encoding::alignment(), and OpenDDS::STUN::encoding().

319 {
320  //
321  // Ensure we work only with buffer data.
322  //
323  if (current_ == 0) {
324  good_bit_ = false;
325  return size;
326  }
327 
328  //
329  // Determine how much data will remain to be written after the current
330  // buffer has been entirely filled.
331  //
332  const size_t spc = current_->space();
333  const size_t remainder = (size - offset > spc) ? size - offset - spc : 0;
334 
335  //
336  // Derive how much data we need to write to the current buffer.
337  //
338  const size_t initial = size - offset - remainder;
339 
340  //
341  // Copy or swap the source data into the current buffer.
342  //
343  swap
344  ? swapcpy(current_->wr_ptr(), src + remainder, initial)
345  : smemcpy(current_->wr_ptr(), src + offset, initial);
346  current_->wr_ptr(initial);
347 
348  // Update the logical writing position in the stream.
349  wpos_ += initial;
350 
351  // smemcpy
352  //
353  // src b1 b2 b3 offset remainder initial
354  // 01234567 xx xx xxxxxx
355  // ^ 0 6 2
356  // 01 xx xxxxxx
357  // ^ 2 4 2
358  // 01 23 xxxxxx
359  // ^ 4 0 4
360  // 01 23 4567xx
361  // ^
362 
363  // swapcpy
364  //
365  // src b1 b2 b3 offset remainder initial
366  // 01234567 xx xx xxxxxx
367  // ^ 0 6 2
368  // 76 xx xxxxxx
369  // ^ 2 4 2
370  // 76 54 xxxxxx
371  // ^ 4 0 4
372  // 76 54 3210xx
373  // ^
374 
375  //
376  // Move to the next chained block if this one is spent.
377  //
378  if (current_->space() == 0) {
379  if (encoding().alignment()) {
380  align_cont_w();
381  } else {
382  current_ = current_->cont();
383  }
384  }
385 
386  //
387  // Return the current location in the write.
388  //
389  return offset + initial;
390 }
void swap(MessageBlock &lhs, MessageBlock &rhs)
Alignment alignment() const
Definition: Serializer.inl:76
size_t wpos_
Logical writing position of the stream.
Definition: Serializer.h:894
ACE_Message_Block * cont(void) const
char * wr_ptr(void) const
void align_cont_w()
Update alignment state when a cont() chain is followed during a write.
Definition: Serializer.inl:889
bool good_bit_
Indicates the current state of the stream abstraction.
Definition: Serializer.h:873
size_t space(void) const
void smemcpy(char *to, const char *from, size_t n)
Definition: Serializer.cpp:453
void swapcpy(char *to, const char *from, size_t n)
Definition: Serializer.cpp:460
const Encoding & encoding() const
Definition: Serializer.inl:199
ACE_Message_Block * current_
Currently active message block in chain.
Definition: Serializer.h:864
static unsigned char offset(char *index, size_t start, size_t align)
Definition: Serializer.inl:869

◆ encoding() [1/2]

ACE_INLINE const Encoding & OpenDDS::DCPS::Serializer::encoding ( ) const

Definition at line 199 of file Serializer.inl.

References ACE_INLINE, and encoding_.

Referenced by OpenDDS::XTypes::DynamicDataXcdrReadImpl::clone(), OpenDDS::DCPS::DataReaderImpl_T< DynamicSample >::dds_demarshal(), OpenDDS::XTypes::DynamicSample::deserialize(), OpenDDS::RTPS::Spdp::SpdpTransport::dispose_unregister(), OpenDDS::DCPS::RtpsUdpSendStrategy::encode_rtps_message(), OpenDDS::RTPS::Spdp::SpdpTransport::handle_input(), OpenDDS::DCPS::operator<<(), read_parameter_id(), reset_alignment(), OpenDDS::XTypes::DynamicDataImpl::DataContainer::serialize_basic_struct_member_xcdr2(), OpenDDS::XTypes::DynamicDataImpl::DataContainer::serialize_bitmask_array_as_uints_i(), OpenDDS::XTypes::DynamicDataImpl::DataContainer::serialize_bitmask_sequence_as_uints_i(), OpenDDS::XTypes::DynamicDataImpl::DataContainer::serialize_complex_aggregated_member_xcdr2(), OpenDDS::XTypes::DynamicDataImpl::DataContainer::serialize_complex_aggregated_member_xcdr2_default(), OpenDDS::XTypes::DynamicDataImpl::DataContainer::serialize_complex_array(), OpenDDS::XTypes::DynamicDataImpl::DataContainer::serialize_complex_sequence(), OpenDDS::XTypes::DynamicDataImpl::DataContainer::serialize_discriminator_member_xcdr2(), OpenDDS::XTypes::DynamicDataImpl::DataContainer::serialize_enum_array_as_ints_i(), OpenDDS::XTypes::DynamicDataImpl::DataContainer::serialize_enum_sequence_as_ints_i(), OpenDDS::XTypes::DynamicDataImpl::DataContainer::serialize_generic_string_array(), OpenDDS::XTypes::DynamicDataImpl::DataContainer::serialize_generic_string_sequence(), OpenDDS::XTypes::DynamicDataImpl::DataContainer::serialize_nested_bitmask_sequences(), OpenDDS::XTypes::DynamicDataImpl::DataContainer::serialize_nested_enum_sequences(), OpenDDS::XTypes::DynamicDataImpl::DataContainer::serialize_nesting_basic_array_i(), OpenDDS::XTypes::DynamicDataImpl::DataContainer::serialize_nesting_basic_sequence_i(), OpenDDS::XTypes::DynamicDataImpl::DataContainer::serialize_nesting_bitmask_array(), OpenDDS::XTypes::DynamicDataImpl::DataContainer::serialize_nesting_bitmask_sequence(), OpenDDS::XTypes::DynamicDataImpl::DataContainer::serialize_nesting_enum_array(), OpenDDS::XTypes::DynamicDataImpl::DataContainer::serialize_nesting_enum_sequence(), OpenDDS::XTypes::DynamicDataImpl::DataContainer::serialize_sequence_aggregated_member_xcdr2(), OpenDDS::XTypes::DynamicDataImpl::DataContainer::serialize_sequence_member_default_value(), OpenDDS::XTypes::DynamicDataImpl::DataContainer::serialize_sequence_struct_member_xcdr2(), OpenDDS::XTypes::DynamicDataImpl::DataContainer::serialize_single_aggregated_member_xcdr2(), OpenDDS::XTypes::DynamicDataImpl::DataContainer::serialize_structure(), OpenDDS::XTypes::DynamicDataImpl::DataContainer::serialize_structure_xcdr2(), OpenDDS::XTypes::DynamicDataImpl::DataContainer::serialize_union(), OpenDDS::XTypes::DynamicDataImpl::DataContainer::serialize_union_xcdr2(), Serializer(), OpenDDS::XTypes::DynamicDataXcdrReadImpl::skip_all(), OpenDDS::XTypes::DynamicDataXcdrReadImpl::skip_collection_member(), OpenDDS::XTypes::DynamicDataXcdrReadImpl::skip_struct_member_at_index(), OpenDDS::XTypes::write_empty_xcdr2_nonfinal(), OpenDDS::RTPS::Spdp::SpdpTransport::write_i(), and write_parameter_id().

200 {
201  return encoding_;
202 }
Encoding encoding_
Encoding Settings.
Definition: Serializer.h:867

◆ encoding() [2/2]

ACE_INLINE void OpenDDS::DCPS::Serializer::encoding ( const Encoding value)

Definition at line 205 of file Serializer.inl.

References ACE_INLINE, encoding_, OpenDDS::DCPS::ENDIAN_NATIVE, OpenDDS::DCPS::Encoding::endianness(), and value.

206 {
207  encoding_ = value;
208  swap_bytes_ = value.endianness() != ENDIAN_NATIVE;
209 }
const LogLevel::Value value
Definition: debug.cpp:61
bool swap_bytes_
Indicates whether bytes will be swapped for this stream.
Definition: Serializer.h:870
Encoding encoding_
Encoding Settings.
Definition: Serializer.h:867

◆ endianness() [1/2]

ACE_INLINE Endianness OpenDDS::DCPS::Serializer::endianness ( ) const

Definition at line 220 of file Serializer.inl.

References ACE_INLINE, and encoding_.

Referenced by OpenDDS::Security::CryptoBuiltInImpl::decode_rtps_message(), and OpenDDS::Security::CryptoBuiltInImpl::decode_submessage().

221 {
222  return encoding_.endianness();
223 }
Endianness endianness() const
Definition: Serializer.inl:64
Encoding encoding_
Encoding Settings.
Definition: Serializer.h:867

◆ endianness() [2/2]

ACE_INLINE void OpenDDS::DCPS::Serializer::endianness ( Endianness  value)

Definition at line 212 of file Serializer.inl.

References ACE_INLINE, OpenDDS::STUN::encoding(), and OpenDDS::DCPS::Encoding::endianness().

213 {
214  Encoding enc = encoding();
215  enc.endianness(value);
216  encoding(enc);
217 }
const LogLevel::Value value
Definition: debug.cpp:61
const Encoding & encoding() const
Definition: Serializer.inl:199

◆ free_string() [1/2]

void OpenDDS::DCPS::Serializer::free_string ( ACE_CDR::Char str,
StrFree  str_free = 0 
)

Definition at line 589 of file Serializer.cpp.

References CORBA::string_free(), and FACE::string_free().

Referenced by OpenDDS::DCPS::operator>>(), and read_string().

591 {
592  if (str_free == 0) {
593 #ifdef OPENDDS_UTIL_BUILD
594  str_free = string_free;
595 #else
596  str_free = CORBA::string_free;
597 #endif
598  }
599  str_free(str);
600 }
void string_free(Char *str)
void string_free(char *)

◆ free_string() [2/2]

void OpenDDS::DCPS::Serializer::free_string ( ACE_CDR::WChar str,
WStrFree  str_free = 0 
)

Definition at line 675 of file Serializer.cpp.

References wstring_free(), and CORBA::wstring_free().

677 {
678  if (str_free == 0) {
679 #ifdef OPENDDS_UTIL_BUILD
680  str_free = wstring_free;
681 #else
682  str_free = CORBA::wstring_free;
683 #endif
684  }
685  str_free(str);
686 }
void wstring_free(WChar *const)

◆ get_construction_status()

ACE_INLINE Serializer::ConstructionStatus OpenDDS::DCPS::Serializer::get_construction_status ( ) const

Definition at line 1745 of file Serializer.inl.

References ACE_INLINE.

Referenced by OpenDDS::DCPS::DataReaderImpl_T< DynamicSample >::dds_demarshal().

1746 {
1747  return construction_status_;
1748 }
ConstructionStatus construction_status_
The way to judge whether tryconstruct trim is able to be properly done.
Definition: Serializer.h:876

◆ good_bit()

ACE_INLINE bool OpenDDS::DCPS::Serializer::good_bit ( void  ) const

◆ length()

ACE_INLINE size_t OpenDDS::DCPS::Serializer::length ( void  ) const

◆ offset()

ACE_INLINE unsigned char OpenDDS::DCPS::Serializer::offset ( char *  index,
size_t  start,
size_t  align 
)
staticprivate

Definition at line 869 of file Serializer.inl.

References ACE_INLINE.

Referenced by reset_alignment(), and OpenDDS::DCPS::Serializer::ScopedAlignmentContext::restore().

870 {
871  return static_cast<unsigned char>((ptrdiff_t(index) - start) % align);
872 }
OpenDDS_Dcps_Export void align(size_t &value, size_t by)
Align "value" by "by" if it&#39;s not already.
Definition: Serializer.inl:23

◆ peek() [1/2]

template<typename T >
bool OpenDDS::DCPS::Serializer::peek ( T &  t)
inline

Definition at line 783 of file Serializer.h.

Referenced by read_parameter_id().

784  {
785  // save
786  const size_t rpos = rpos_;
787  const unsigned char align_rshift = align_rshift_;
789 
790  // read
791  if (!peek_helper(current_, 0, t)) {
792  return false;
793  }
794 
795  // reset
796  current_ = current;
797  align_rshift_ = align_rshift;
798  rpos_ = rpos;
799  return true;
800  }
size_t rpos() const
Examine the logical reading position of the stream.
Definition: Serializer.h:475
ACE_Message_Block * current() const
Definition: Serializer.h:480
ACE_Message_Block * current_
Currently active message block in chain.
Definition: Serializer.h:864
bool peek_helper(ACE_Message_Block *const block, size_t bytes, T &t)
Definition: Serializer.h:768
unsigned char align_rshift_
Definition: Serializer.h:882
size_t rpos_
Logical reading position of the stream.
Definition: Serializer.h:891

◆ peek() [2/2]

bool OpenDDS::DCPS::Serializer::peek ( ACE_CDR::ULong t)

Definition at line 423 of file Serializer.cpp.

References align_rshift_, current(), current_, peek_helper(), rpos(), rpos_, and OpenDDS::DCPS::uint32_cdr_size.

424 {
425  // save
426  const size_t rpos = rpos_;
427  const unsigned char align_rshift = align_rshift_;
429 
430  // read
431  if (!peek_helper(current_, 2 * uint32_cdr_size, t)) {
432  return false;
433  }
434 
435  // reset
436  current_ = current;
437  align_rshift_ = align_rshift;
438  rpos_ = rpos;
439  return true;
440 }
size_t rpos() const
Examine the logical reading position of the stream.
Definition: Serializer.h:475
const size_t uint32_cdr_size
Definition: Serializer.h:96
ACE_Message_Block * current() const
Definition: Serializer.h:480
ACE_Message_Block * current_
Currently active message block in chain.
Definition: Serializer.h:864
bool peek_helper(ACE_Message_Block *const block, size_t bytes, T &t)
Definition: Serializer.h:768
unsigned char align_rshift_
Definition: Serializer.h:882
size_t rpos_
Logical reading position of the stream.
Definition: Serializer.h:891

◆ peek_helper()

template<typename T >
bool OpenDDS::DCPS::Serializer::peek_helper ( ACE_Message_Block *const  block,
size_t  bytes,
T &  t 
)
inline

Definition at line 768 of file Serializer.h.

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

Referenced by peek().

769  {
770  bool result = false;
771  char* const rd_ptr = block->rd_ptr();
772  const size_t length = block->length();
773  if (!block->cont() || length == 0 || (bytes != 0 && bytes <= length)) {
774  result = *this >> t;
775  } else {
776  result = peek_helper(block->cont(), bytes - length, t);
777  }
778  block->rd_ptr(rd_ptr);
779  return result;
780  }
size_t length(void) const
char * rd_ptr(void) const
size_t length() const
Number of bytes left to read in message block chain.
Definition: Serializer.inl:437
ACE_Message_Block * cont(void) const
bool peek_helper(ACE_Message_Block *const block, size_t bytes, T &t)
Definition: Serializer.h:768

◆ pos_rd()

const char* OpenDDS::DCPS::Serializer::pos_rd ( ) const
inline

Definition at line 471 of file Serializer.h.

471 { return current_ ? current_->rd_ptr() : 0; }
char * rd_ptr(void) const
ACE_Message_Block * current_
Currently active message block in chain.
Definition: Serializer.h:864

◆ pos_wr()

const char* OpenDDS::DCPS::Serializer::pos_wr ( ) const
inline

Definition at line 472 of file Serializer.h.

472 { return current_ ? current_->wr_ptr() : 0; }
char * wr_ptr(void) const
ACE_Message_Block * current_
Currently active message block in chain.
Definition: Serializer.h:864

◆ rdstate() [1/2]

ACE_INLINE Serializer::RdState OpenDDS::DCPS::Serializer::rdstate ( void  ) const

Definition at line 1757 of file Serializer.inl.

References ACE_INLINE, and state.

Referenced by OpenDDS::XTypes::DynamicDataXcdrReadImpl::DynamicDataXcdrReadImpl(), OpenDDS::XTypes::DynamicDataXcdrReadImpl::setup_stream(), and OpenDDS::XTypes::DynamicDataXcdrReadImpl::skip_aggregated_member().

1758 {
1759  RdState state(align_rshift_, rpos_);
1760  return state;
1761 }
YARD is all original work While it may rely on standard YARD does not include code from other sources We have chosen to release our work as public domain code This means that YARD has been released outside the copyright system Feel free to use the code in any way you wish especially in an academic plagiarism has very little to do with copyright In an academic or in any situation where you are expected to give credit to other people s you will need to cite YARD as a source The author is Christopher and the appropriate date is December the release date for we can t make any promises regarding whether YARD will do what you or whether we will make any changes you ask for You are free to hire your own expert for that If you choose to distribute YARD you ll probably want to read up on the laws covering warranties in your state
Definition: COPYING.txt:14
unsigned char align_rshift_
Definition: Serializer.h:882
size_t rpos_
Logical reading position of the stream.
Definition: Serializer.h:891

◆ rdstate() [2/2]

ACE_INLINE void OpenDDS::DCPS::Serializer::rdstate ( const RdState state)

Definition at line 1764 of file Serializer.inl.

References OpenDDS::DCPS::Serializer::RdState::align_rshift, OPENDDS_END_VERSIONED_NAMESPACE_DECL, and OpenDDS::DCPS::Serializer::RdState::rpos.

1765 {
1766  align_rshift_ = state.align_rshift;
1767  rpos_ = state.rpos;
1768 }
YARD is all original work While it may rely on standard YARD does not include code from other sources We have chosen to release our work as public domain code This means that YARD has been released outside the copyright system Feel free to use the code in any way you wish especially in an academic plagiarism has very little to do with copyright In an academic or in any situation where you are expected to give credit to other people s you will need to cite YARD as a source The author is Christopher and the appropriate date is December the release date for we can t make any promises regarding whether YARD will do what you or whether we will make any changes you ask for You are free to hire your own expert for that If you choose to distribute YARD you ll probably want to read up on the laws covering warranties in your state
Definition: COPYING.txt:14
unsigned char align_rshift_
Definition: Serializer.h:882
size_t rpos_
Logical reading position of the stream.
Definition: Serializer.h:891

◆ read_array() [1/2]

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 472 of file Serializer.inl.

References ACE_INLINE.

Referenced by read_string().

473 {
474  read_array(x, size, length, swap_bytes_);
475 }
bool swap_bytes_
Indicates whether bytes will be swapped for this stream.
Definition: Serializer.h:870
void read_array(char *x, size_t size, ACE_CDR::ULong length)
Definition: Serializer.inl:472
size_t length() const
Number of bytes left to read in message block chain.
Definition: Serializer.inl:437

◆ read_array() [2/2]

ACE_INLINE void OpenDDS::DCPS::Serializer::read_array ( char *  x,
size_t  size,
ACE_CDR::ULong  length,
bool  swap 
)
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 478 of file Serializer.inl.

References ACE_INLINE.

480 {
481  if (!swap || size == 1) {
482  //
483  // No swap, copy direct. This silently corrupts the data if there is
484  // padding in the buffer.
485  //
486  buffer_read(x, size * length, false);
487 
488  } else {
489  //
490  // Swapping _must_ be done at 'size' boundaries, so we need to spin
491  // through the array element by element. This silently corrupts the
492  // data if there is padding in the buffer.
493  //
494  while (length-- > 0) {
495  buffer_read(x, size, true);
496  x += size;
497  }
498  }
499 }
void swap(MessageBlock &lhs, MessageBlock &rhs)
size_t length() const
Number of bytes left to read in message block chain.
Definition: Serializer.inl:437
void buffer_read(char *dest, size_t size, bool swap)
Read from the chain into a destination buffer.
Definition: Serializer.inl:305

◆ read_boolean_array()

ACE_INLINE bool OpenDDS::DCPS::Serializer::read_boolean_array ( ACE_CDR::Boolean x,
ACE_CDR::ULong  length 
)

Read basic IDL types arrays The buffer x must be large enough to contain length elements. Return false on failure and true on success.

Definition at line 533 of file Serializer.inl.

References ACE_INLINE, and OpenDDS::DCPS::boolean_cdr_size.

534 {
535  read_array(reinterpret_cast<char*>(x), boolean_cdr_size, length);
536  return good_bit();
537 }
const size_t boolean_cdr_size
Definition: Serializer.h:89
void read_array(char *x, size_t size, ACE_CDR::ULong length)
Definition: Serializer.inl:472
size_t length() const
Number of bytes left to read in message block chain.
Definition: Serializer.inl:437

◆ read_char_array()

ACE_INLINE bool OpenDDS::DCPS::Serializer::read_char_array ( ACE_CDR::Char x,
ACE_CDR::ULong  length 
)

Read basic IDL types arrays The buffer x must be large enough to contain length elements. Return false on failure and true on success.

Definition at line 540 of file Serializer.inl.

References ACE_INLINE, and OpenDDS::DCPS::char8_cdr_size.

Referenced by read_string().

541 {
542  read_array(reinterpret_cast<char*>(x), char8_cdr_size, length);
543  return good_bit();
544 }
void read_array(char *x, size_t size, ACE_CDR::ULong length)
Definition: Serializer.inl:472
size_t length() const
Number of bytes left to read in message block chain.
Definition: Serializer.inl:437
const size_t char8_cdr_size
Definition: Serializer.h:102

◆ read_delimiter()

ACE_INLINE bool OpenDDS::DCPS::Serializer::read_delimiter ( size_t &  size)

Read a delimiter used for XCDR2 delimited data.

Returns true if successful and size will be set to the size of the CDR value excluding the delimiter.

Definition at line 912 of file Serializer.inl.

References ACE_INLINE, OpenDDS::STUN::encoding(), OpenDDS::DCPS::Encoding::xcdr_version(), and OpenDDS::DCPS::Encoding::XCDR_VERSION_2.

Referenced by OpenDDS::XTypes::DynamicDataXcdrReadImpl::get_item_count(), OpenDDS::DCPS::operator>>(), OpenDDS::XTypes::read_empty_xcdr2_nonfinal(), OpenDDS::XTypes::DynamicDataXcdrReadImpl::skip_all(), OpenDDS::XTypes::DynamicDataXcdrReadImpl::skip_collection_member(), OpenDDS::XTypes::DynamicDataXcdrReadImpl::skip_to_map_element(), and OpenDDS::XTypes::DynamicDataXcdrReadImpl::skip_to_struct_member().

913 {
914  if (encoding().xcdr_version() == Encoding::XCDR_VERSION_2) {
915  ACE_CDR::ULong dheader;
916  if (*this >> dheader) {
917  size = dheader;
918  return true;
919  }
920  }
921  return false;
922 }
ACE_UINT32 ULong
const Encoding & encoding() const
Definition: Serializer.inl:199

◆ read_double_array()

ACE_INLINE bool OpenDDS::DCPS::Serializer::read_double_array ( ACE_CDR::Double x,
ACE_CDR::ULong  length 
)

Read basic IDL types arrays The buffer x must be large enough to contain length elements. Return false on failure and true on success.

Definition at line 651 of file Serializer.inl.

References ACE_INLINE, and OpenDDS::DCPS::float64_cdr_size.

652 {
653  if (!align_r(float64_cdr_size)) {
654  return false;
655  }
656  read_array(reinterpret_cast<char*>(x), float64_cdr_size, length);
657  return good_bit();
658 }
const size_t float64_cdr_size
Definition: Serializer.h:100
void read_array(char *x, size_t size, ACE_CDR::ULong length)
Definition: Serializer.inl:472
size_t length() const
Number of bytes left to read in message block chain.
Definition: Serializer.inl:437
bool align_r(size_t alignment)
Definition: Serializer.inl:813

◆ read_float_array()

ACE_INLINE bool OpenDDS::DCPS::Serializer::read_float_array ( ACE_CDR::Float x,
ACE_CDR::ULong  length 
)

Read basic IDL types arrays The buffer x must be large enough to contain length elements. Return false on failure and true on success.

Definition at line 641 of file Serializer.inl.

References ACE_INLINE, and OpenDDS::DCPS::float32_cdr_size.

642 {
643  if (!align_r(float32_cdr_size)) {
644  return false;
645  }
646  read_array(reinterpret_cast<char*>(x), float32_cdr_size, length);
647  return good_bit();
648 }
const size_t float32_cdr_size
Definition: Serializer.h:99
void read_array(char *x, size_t size, ACE_CDR::ULong length)
Definition: Serializer.inl:472
size_t length() const
Number of bytes left to read in message block chain.
Definition: Serializer.inl:437
bool align_r(size_t alignment)
Definition: Serializer.inl:813

◆ read_long_array()

ACE_INLINE bool OpenDDS::DCPS::Serializer::read_long_array ( ACE_CDR::Long x,
ACE_CDR::ULong  length 
)

Read basic IDL types arrays The buffer x must be large enough to contain length elements. Return false on failure and true on success.

Definition at line 601 of file Serializer.inl.

References ACE_INLINE, and OpenDDS::DCPS::int32_cdr_size.

Referenced by OpenDDS::DCPS::operator>>().

602 {
603  if (!align_r(int32_cdr_size)) {
604  return false;
605  }
606  read_array(reinterpret_cast<char*>(x), int32_cdr_size, length);
607  return good_bit();
608 }
void read_array(char *x, size_t size, ACE_CDR::ULong length)
Definition: Serializer.inl:472
size_t length() const
Number of bytes left to read in message block chain.
Definition: Serializer.inl:437
bool align_r(size_t alignment)
Definition: Serializer.inl:813
const size_t int32_cdr_size
Definition: Serializer.h:95

◆ read_longdouble_array()

ACE_INLINE bool OpenDDS::DCPS::Serializer::read_longdouble_array ( ACE_CDR::LongDouble x,
ACE_CDR::ULong  length 
)

Read basic IDL types arrays The buffer x must be large enough to contain length elements. Return false on failure and true on success.

Definition at line 661 of file Serializer.inl.

References ACE_INLINE, and OpenDDS::DCPS::float128_cdr_size.

662 {
663  if (!align_r(float128_cdr_size)) {
664  return false;
665  }
666  read_array(reinterpret_cast<char*>(x), float128_cdr_size, length);
667  return good_bit();
668 }
void read_array(char *x, size_t size, ACE_CDR::ULong length)
Definition: Serializer.inl:472
size_t length() const
Number of bytes left to read in message block chain.
Definition: Serializer.inl:437
bool align_r(size_t alignment)
Definition: Serializer.inl:813
const size_t float128_cdr_size
Definition: Serializer.h:101

◆ read_longlong_array()

ACE_INLINE bool OpenDDS::DCPS::Serializer::read_longlong_array ( ACE_CDR::LongLong x,
ACE_CDR::ULong  length 
)

Read basic IDL types arrays The buffer x must be large enough to contain length elements. Return false on failure and true on success.

Definition at line 621 of file Serializer.inl.

References ACE_INLINE, and OpenDDS::DCPS::int64_cdr_size.

622 {
623  if (!align_r(int64_cdr_size)) {
624  return false;
625  }
626  read_array(reinterpret_cast<char*>(x), int64_cdr_size, length);
627  return good_bit();
628 }
const size_t int64_cdr_size
Definition: Serializer.h:97
void read_array(char *x, size_t size, ACE_CDR::ULong length)
Definition: Serializer.inl:472
size_t length() const
Number of bytes left to read in message block chain.
Definition: Serializer.inl:437
bool align_r(size_t alignment)
Definition: Serializer.inl:813

◆ read_octet_array()

ACE_INLINE bool OpenDDS::DCPS::Serializer::read_octet_array ( ACE_CDR::Octet x,
ACE_CDR::ULong  length 
)

Read basic IDL types arrays The buffer x must be large enough to contain length elements. Return false on failure and true on success.

Definition at line 558 of file Serializer.inl.

References ACE_INLINE, OpenDDS::DCPS::byte_cdr_size, OpenDDS::DCPS::int8_cdr_size, and OpenDDS::DCPS::uint8_cdr_size.

Referenced by OpenDDS::XTypes::DynamicSample::deserialize(), OpenDDS::DCPS::RtpsUdpSendStrategy::encode_rtps_message(), OpenDDS::DCPS::TransportHeader::init(), OpenDDS::STUN::operator>>(), and OpenDDS::DCPS::operator>>().

559 {
560  read_array(reinterpret_cast<char*>(x), byte_cdr_size, length);
561  return good_bit();
562 }
void read_array(char *x, size_t size, ACE_CDR::ULong length)
Definition: Serializer.inl:472
size_t length() const
Number of bytes left to read in message block chain.
Definition: Serializer.inl:437
const size_t byte_cdr_size
Definition: Serializer.h:90

◆ read_parameter_id()

bool OpenDDS::DCPS::Serializer::read_parameter_id ( unsigned &  id,
size_t &  size,
bool &  must_understand 
)

Read a XCDR parameter ID used in XCDR parameter lists.

Returns true if successful.

Definition at line 707 of file Serializer.cpp.

References align_r(), emheader_must_understand, encoding(), peek(), pid_extended, reset_alignment(), skip(), OpenDDS::DCPS::uint32_cdr_size, OpenDDS::DCPS::xcdr1_pid_alignment, OpenDDS::DCPS::Encoding::xcdr_version(), OpenDDS::DCPS::Encoding::XCDR_VERSION_1, and OpenDDS::DCPS::Encoding::XCDR_VERSION_2.

Referenced by OpenDDS::XTypes::DynamicDataXcdrReadImpl::get_complex_value(), OpenDDS::XTypes::DynamicDataXcdrReadImpl::get_item_count(), OpenDDS::XTypes::DynamicDataXcdrReadImpl::get_member_id_at_index(), OpenDDS::XTypes::DynamicDataXcdrReadImpl::get_value_from_union(), OpenDDS::XTypes::DynamicDataXcdrReadImpl::get_values_from_union(), OpenDDS::DCPS::operator>>(), OpenDDS::XTypes::DynamicDataXcdrReadImpl::read_discriminator(), and OpenDDS::XTypes::DynamicDataXcdrReadImpl::skip_to_struct_member().

708 {
710  if (xcdr == Encoding::XCDR_VERSION_1) {
711  // Get the "short" id and size
713  return false;
714  }
715  ACE_CDR::UShort pid;
716  if (!(*this >> pid)) {
717  return false;
718  }
719  const ACE_CDR::UShort short_id = pid & 0x3fff;
720  ACE_CDR::UShort short_size;
721  if (!(*this >> short_size)) {
722  return false;
723  }
724 
725  // TODO(iguessthislldo): handle PID flags
726  must_understand = false; // Placeholder
727 
728  // If extended, get the "long" id and size
729  if (short_id == pid_extended) {
730  ACE_CDR::ULong long_id, long_size;
731  if (!(*this >> long_id) || !(*this >> long_size)) {
732  return false;
733  }
734  const unsigned short_size_left = short_size - 8;
735  if (short_size_left) {
736  skip(short_size_left);
737  }
738  id = long_id;
739  size = long_size;
740  } else {
741  id = short_id;
742  size = short_size;
743  }
744 
745  reset_alignment();
746  } else if (xcdr == Encoding::XCDR_VERSION_2) {
747  ACE_CDR::ULong emheader;
748  if (!(*this >> emheader)) {
749  return false;
750  }
751 
752  must_understand = emheader & emheader_must_understand;
753 
754  // Get Size
755  const unsigned short lc = (emheader >> 28) & 0x7;
756  if (lc < 4) {
757  size = size_t(1) << lc;
758  } else {
759  ACE_CDR::ULong next_int;
760  if (lc == 4 ? !(*this >> next_int) : !peek(next_int)) {
761  return false;
762  }
763  switch (lc) {
764  case 4:
765  size = next_int;
766  break;
767  case 5:
768  size = uint32_cdr_size + next_int;
769  break;
770  case 6:
771  size = uint32_cdr_size + next_int * 4;
772  break;
773  case 7:
774  size = uint32_cdr_size + next_int * 8;
775  break;
776  }
777  }
778  id = emheader & 0xfffffff;
779  }
780 
781  return true;
782 }
bool skip(size_t n, int size=1)
Definition: Serializer.inl:443
static const ACE_CDR::UShort pid_extended
Definition: Serializer.h:373
const size_t uint32_cdr_size
Definition: Serializer.h:96
void reset_alignment()
Reset alignment as if a new instance were created.
Definition: Serializer.cpp:443
const size_t xcdr1_pid_alignment
Definition: Serializer.h:104
ACE_UINT16 UShort
bool align_r(size_t alignment)
Definition: Serializer.inl:813
static const ACE_CDR::ULong emheader_must_understand
Definition: Serializer.h:384
ACE_UINT32 ULong
XcdrVersion xcdr_version() const
Definition: Serializer.inl:127
const Encoding & encoding() const
Definition: Serializer.inl:199

◆ read_short_array()

ACE_INLINE bool OpenDDS::DCPS::Serializer::read_short_array ( ACE_CDR::Short x,
ACE_CDR::ULong  length 
)

Read basic IDL types arrays The buffer x must be large enough to contain length elements. Return false on failure and true on success.

Definition at line 581 of file Serializer.inl.

References ACE_INLINE, and OpenDDS::DCPS::int16_cdr_size.

582 {
583  if (!align_r(int16_cdr_size)) {
584  return false;
585  }
586  read_array(reinterpret_cast<char*>(x), int16_cdr_size, length);
587  return good_bit();
588 }
const size_t int16_cdr_size
Definition: Serializer.h:93
void read_array(char *x, size_t size, ACE_CDR::ULong length)
Definition: Serializer.inl:472
size_t length() const
Number of bytes left to read in message block chain.
Definition: Serializer.inl:437
bool align_r(size_t alignment)
Definition: Serializer.inl:813

◆ read_string() [1/2]

size_t OpenDDS::DCPS::Serializer::read_string ( ACE_CDR::Char *&  dest,
StrAllocate  str_alloc = 0,
StrFree  str_free = 0 
)

Definition at line 520 of file Serializer.cpp.

References current_, free_string(), good_bit_, length(), read_char_array(), CORBA::string_alloc(), and FACE::string_alloc().

Referenced by OpenDDS::FaceTypes::operator>>(), and OpenDDS::DCPS::operator>>().

523 {
524  if (str_alloc == 0) {
525 #ifdef OPENDDS_UTIL_BUILD
526  str_alloc = string_alloc;
527 #else
528  str_alloc = CORBA::string_alloc;
529 #endif
530  }
531 
532  //
533  // Ensure no bad values leave the routine.
534  //
535  free_string(dest, str_free);
536  dest = 0;
537 
538  //
539  // Extract the string length.
540  //
541  ACE_CDR::ULong length; // includes the null
542  if (!(*this >> length)) {
543  return 0;
544  }
545 
546  if (length == 0) {
547  // not legal CDR, but we need to accept it since other implementations may generate this
548  dest = str_alloc(0);
549  return 0;
550  }
551 
552  //
553  // NOTE: Maintain the ACE implementation where the length check is
554  // done here before the allocation even though it will be
555  // checked during the actual read as well.
556  //
557  if (current_ && length <= current_->total_length()) {
558 
559  dest = str_alloc(length - 1);
560 
561  if (dest == 0) {
562  good_bit_ = false;
563 
564  } else {
565  //
566  // Extract the string.
567  //
568  read_char_array(dest, length);
569 
570  if (good_bit_ && dest[length - 1]) {
571  // If the last byte was not a 0 it's not a valid CDR string
572  good_bit_ = false;
573  }
574  }
575 
576  if (!good_bit_) {
577  free_string(dest, str_free);
578  dest = 0;
579  }
580 
581  } else {
582  good_bit_ = false;
583  }
584 
585  return length - 1;
586 }
char * string_alloc(ULong len)
Char * string_alloc(UnsignedLong len)
size_t length() const
Number of bytes left to read in message block chain.
Definition: Serializer.inl:437
ACE_UINT32 ULong
bool read_char_array(ACE_CDR::Char *x, ACE_CDR::ULong length)
Definition: Serializer.inl:540
bool good_bit_
Indicates the current state of the stream abstraction.
Definition: Serializer.h:873
ACE_Message_Block * current_
Currently active message block in chain.
Definition: Serializer.h:864
void free_string(ACE_CDR::Char *str, StrFree str_free=0)
Definition: Serializer.cpp:589

◆ read_string() [2/2]

size_t OpenDDS::DCPS::Serializer::read_string ( ACE_CDR::WChar *&  dest,
WStrAllocate  str_alloc = 0,
WStrFree  str_free = 0 
)

Definition at line 603 of file Serializer.cpp.

References buffer_read(), OpenDDS::DCPS::char16_cdr_size, current_, free_string(), good_bit_, length(), read_array(), swap_bytes(), wstring_alloc(), and CORBA::wstring_alloc().

606 {
607  if (str_alloc == 0) {
608 #ifdef OPENDDS_UTIL_BUILD
609  str_alloc = wstring_alloc;
610 #else
611  str_alloc = CORBA::wstring_alloc;
612 #endif
613  }
614 
615  //
616  // Ensure no bad values leave the routine.
617  //
618  free_string(dest, str_free);
619  dest = 0;
620 
621  //
622  // Extract the string size.
623  //
624  ACE_CDR::ULong bytecount;
625  if (!(*this >> bytecount)) {
626  return 0;
627  }
628 
629  //
630  // NOTE: Maintain the ACE implementation where the length check is
631  // done here before the allocation even though it will be
632  // checked during the actual read as well.
633  //
635  if (current_ && bytecount <= current_->total_length()) {
636  length = bytecount / char16_cdr_size;
637  dest = str_alloc(length);
638 
639  if (dest == 0) {
640  good_bit_ = false;
641  return 0;
642  }
643 
644 #if ACE_SIZEOF_WCHAR == 2
645  read_array(reinterpret_cast<char*>(dest), char16_cdr_size, length, swap_bytes());
646 #else
647  for (size_t i = 0; i < length && good_bit_; ++i) {
648  ACE_UINT16 as_utf16;
649  buffer_read(reinterpret_cast<char*>(&as_utf16), char16_cdr_size, swap_bytes());
650  if (good_bit_) {
651  dest[i] = as_utf16;
652  }
653  }
654 #endif
655 
656  if (good_bit_) {
657  //
658  // Null terminate the string.
659  //
660  dest[length] = L'\0';
661  } else {
662  free_string(dest, str_free);
663  dest = 0;
664  length = 0;
665  }
666 
667  } else {
668  good_bit_ = false;
669  }
670 
671  return length;
672 }
void read_array(char *x, size_t size, ACE_CDR::ULong length)
Definition: Serializer.inl:472
size_t length() const
Number of bytes left to read in message block chain.
Definition: Serializer.inl:437
WChar * wstring_alloc(ULong len)
ACE_UINT32 ULong
bool good_bit_
Indicates the current state of the stream abstraction.
Definition: Serializer.h:873
const size_t char16_cdr_size
Definition: Serializer.h:103
ACE_Message_Block * current_
Currently active message block in chain.
Definition: Serializer.h:864
void free_string(ACE_CDR::Char *str, StrFree str_free=0)
Definition: Serializer.cpp:589
void buffer_read(char *dest, size_t size, bool swap)
Read from the chain into a destination buffer.
Definition: Serializer.inl:305

◆ read_ulong_array()

ACE_INLINE bool OpenDDS::DCPS::Serializer::read_ulong_array ( ACE_CDR::ULong x,
ACE_CDR::ULong  length 
)

Read basic IDL types arrays The buffer x must be large enough to contain length elements. Return false on failure and true on success.

Definition at line 611 of file Serializer.inl.

References ACE_INLINE, and OpenDDS::DCPS::uint32_cdr_size.

Referenced by OpenDDS::DCPS::operator>>().

612 {
613  if (!align_r(uint32_cdr_size)) {
614  return false;
615  }
616  read_array(reinterpret_cast<char*>(x), uint32_cdr_size, length);
617  return good_bit();
618 }
const size_t uint32_cdr_size
Definition: Serializer.h:96
void read_array(char *x, size_t size, ACE_CDR::ULong length)
Definition: Serializer.inl:472
size_t length() const
Number of bytes left to read in message block chain.
Definition: Serializer.inl:437
bool align_r(size_t alignment)
Definition: Serializer.inl:813

◆ read_ulonglong_array()

ACE_INLINE bool OpenDDS::DCPS::Serializer::read_ulonglong_array ( ACE_CDR::ULongLong x,
ACE_CDR::ULong  length 
)

Read basic IDL types arrays The buffer x must be large enough to contain length elements. Return false on failure and true on success.

Definition at line 631 of file Serializer.inl.

References ACE_INLINE, and OpenDDS::DCPS::uint64_cdr_size.

632 {
633  if (!align_r(uint64_cdr_size)) {
634  return false;
635  }
636  read_array(reinterpret_cast<char*>(x), uint64_cdr_size, length);
637  return good_bit();
638 }
const size_t uint64_cdr_size
Definition: Serializer.h:98
void read_array(char *x, size_t size, ACE_CDR::ULong length)
Definition: Serializer.inl:472
size_t length() const
Number of bytes left to read in message block chain.
Definition: Serializer.inl:437
bool align_r(size_t alignment)
Definition: Serializer.inl:813

◆ read_ushort_array()

ACE_INLINE bool OpenDDS::DCPS::Serializer::read_ushort_array ( ACE_CDR::UShort x,
ACE_CDR::ULong  length 
)

Read basic IDL types arrays The buffer x must be large enough to contain length elements. Return false on failure and true on success.

Definition at line 591 of file Serializer.inl.

References ACE_INLINE, and OpenDDS::DCPS::uint16_cdr_size.

592 {
593  if (!align_r(uint16_cdr_size)) {
594  return false;
595  }
596  read_array(reinterpret_cast<char*>(x), uint16_cdr_size, length);
597  return good_bit();
598 }
void read_array(char *x, size_t size, ACE_CDR::ULong length)
Definition: Serializer.inl:472
size_t length() const
Number of bytes left to read in message block chain.
Definition: Serializer.inl:437
bool align_r(size_t alignment)
Definition: Serializer.inl:813
const size_t uint16_cdr_size
Definition: Serializer.h:94

◆ read_wchar_array()

ACE_INLINE bool OpenDDS::DCPS::Serializer::read_wchar_array ( ACE_CDR::WChar x,
ACE_CDR::ULong  length 
)

Read basic IDL types arrays The buffer x must be large enough to contain length elements. Return false on failure and true on success.

Definition at line 547 of file Serializer.inl.

References ACE_INLINE.

548 {
549  for (ACE_CDR::ULong i = 0; i < length; ++i) {
550  if (!((*this) >> ACE_InputCDR::to_wchar(x[i]))) {
551  break;
552  }
553  }
554  return good_bit();
555 }
size_t length() const
Number of bytes left to read in message block chain.
Definition: Serializer.inl:437
ACE_UINT32 ULong

◆ reset_alignment()

void OpenDDS::DCPS::Serializer::reset_alignment ( )

Reset alignment as if a new instance were created.

Definition at line 443 of file Serializer.cpp.

References OpenDDS::DCPS::align(), align_rshift_, align_wshift_, current_, encoding(), OpenDDS::DCPS::Encoding::max_align(), offset(), ACE_Message_Block::rd_ptr(), and ACE_Message_Block::wr_ptr().

Referenced by OpenDDS::RTPS::Sedp::SecurityReader::data_received_i(), OpenDDS::DCPS::operator<<(), OpenDDS::DCPS::operator>>(), read_parameter_id(), OpenDDS::DCPS::Serializer::ScopedAlignmentContext::ScopedAlignmentContext(), Serializer(), and write_parameter_id().

444 {
445  const ptrdiff_t align = encoding().max_align();
446  if (current_ && align) {
449  }
450 }
char * rd_ptr(void) const
unsigned char align_wshift_
Definition: Serializer.h:888
char * wr_ptr(void) const
OpenDDS_Dcps_Export void align(size_t &value, size_t by)
Align "value" by "by" if it&#39;s not already.
Definition: Serializer.inl:23
size_t max_align() const
Return the maximum alignment dictated by the alignment policy.
Definition: Serializer.inl:112
const Encoding & encoding() const
Definition: Serializer.inl:199
ACE_Message_Block * current_
Currently active message block in chain.
Definition: Serializer.h:864
static unsigned char offset(char *index, size_t start, size_t align)
Definition: Serializer.inl:869
unsigned char align_rshift_
Definition: Serializer.h:882

◆ rpos()

size_t OpenDDS::DCPS::Serializer::rpos ( ) const
inline

◆ set_construction_status()

ACE_INLINE void OpenDDS::DCPS::Serializer::set_construction_status ( ConstructionStatus  cs)

Definition at line 1751 of file Serializer.inl.

References ACE_INLINE.

Referenced by OpenDDS::DCPS::operator>>().

1752 {
1753  construction_status_ = cs;
1754 }
ConstructionStatus construction_status_
The way to judge whether tryconstruct trim is able to be properly done.
Definition: Serializer.h:876

◆ skip()

ACE_INLINE bool OpenDDS::DCPS::Serializer::skip ( size_t  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 443 of file Serializer.inl.

References ACE_INLINE, OpenDDS::STUN::encoding(), and OpenDDS::DCPS::Encoding::max_align().

Referenced by OpenDDS::Security::CryptoBuiltInImpl::authtag(), OpenDDS::RTPS::blob_to_locators(), OpenDDS::Security::CryptoBuiltInImpl::decode_serialized_payload(), OpenDDS::Security::CryptoBuiltInImpl::decode_submessage(), OpenDDS::XTypes::DynamicDataXcdrReadImpl::get_item_count(), OpenDDS::XTypes::DynamicDataXcdrReadImpl::get_member_id_at_index(), OpenDDS::RTPS::Spdp::SpdpTransport::handle_input(), OpenDDS::DCPS::RtpsSampleHeader::init(), OpenDDS::STUN::operator>>(), OpenDDS::DCPS::operator>>(), OpenDDS::Security::CryptoBuiltInImpl::preprocess_secure_submsg(), OpenDDS::XTypes::read_empty_xcdr2_nonfinal(), read_parameter_id(), OpenDDS::DCPS::Serializer::ScopedAlignmentContext::restore(), OpenDDS::XTypes::DynamicDataXcdrReadImpl::skip(), OpenDDS::XTypes::DynamicDataXcdrReadImpl::skip_to_array_element(), OpenDDS::XTypes::DynamicDataXcdrReadImpl::skip_to_map_element(), OpenDDS::XTypes::DynamicDataXcdrReadImpl::skip_to_sequence_element(), OpenDDS::XTypes::DynamicDataXcdrReadImpl::skip_to_struct_member(), OpenDDS::RTPS::MessageParser::skipSubmessageContent(), and OpenDDS::RTPS::MessageParser::skipToNextSubmessage().

444 {
445  if (size > 1 && !align_r((std::min)(size_t(size), encoding().max_align()))) {
446  return false;
447  }
448 
449  for (size_t len = static_cast<size_t>(n * size); len;) {
450  if (!current_) {
451  good_bit_ = false;
452  return false;
453  }
454  const size_t cur_len = current_->length();
455  if (cur_len <= len) {
456  len -= cur_len;
458  align_cont_r();
459  } else {
460  current_->rd_ptr(len);
461  break;
462  }
463  }
464 
465  if (good_bit_) {
466  rpos_ += n * size;
467  }
468  return good_bit();
469 }
size_t length(void) const
char * rd_ptr(void) const
bool align_r(size_t alignment)
Definition: Serializer.inl:813
char * wr_ptr(void) const
bool good_bit_
Indicates the current state of the stream abstraction.
Definition: Serializer.h:873
void align_cont_r()
Update alignment state when a cont() chain is followed during a read.
Definition: Serializer.inl:875
const Encoding & encoding() const
Definition: Serializer.inl:199
ACE_Message_Block * current_
Currently active message block in chain.
Definition: Serializer.h:864
size_t rpos_
Logical reading position of the stream.
Definition: Serializer.h:891

◆ skip_delimiter()

ACE_INLINE bool OpenDDS::DCPS::Serializer::skip_delimiter ( )

◆ smemcpy()

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 453 of file Serializer.cpp.

References ACE_OS::memcpy(), and OPENDDS_ASSERT.

454 {
455  OPENDDS_ASSERT(from);
456  (void) ACE_OS::memcpy(to, from, n);
457 }
void * memcpy(void *t, const void *s, size_t len)
#define OPENDDS_ASSERT(C)
Definition: Definitions.h:72

◆ swap_bytes() [1/2]

ACE_INLINE void OpenDDS::DCPS::Serializer::swap_bytes ( bool  do_swap)

◆ swap_bytes() [2/2]

ACE_INLINE bool OpenDDS::DCPS::Serializer::swap_bytes ( ) const

Definition at line 411 of file Serializer.inl.

References ACE_INLINE.

Referenced by read_string().

412 {
413  return swap_bytes_;
414 }
bool swap_bytes_
Indicates whether bytes will be swapped for this stream.
Definition: Serializer.h:870

◆ swapcpy()

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 460 of file Serializer.cpp.

References good_bit_.

461 {
462  // Unroll the loop...
463  switch (n) { // 2 4 8 16
464  case 16:
465  to[ 15] = from[ n - 16]; // x x x 0
466  // fallthrough
467  case 15:
468  to[ 14] = from[ n - 15]; // x x x 1
469  // fallthrough
470  case 14:
471  to[ 13] = from[ n - 14]; // x x x 2
472  // fallthrough
473  case 13:
474  to[ 12] = from[ n - 13]; // x x x 3
475  // fallthrough
476  case 12:
477  to[ 11] = from[ n - 12]; // x x x 4
478  // fallthrough
479  case 11:
480  to[ 10] = from[ n - 11]; // x x x 5
481  // fallthrough
482  case 10:
483  to[ 9] = from[ n - 10]; // x x x 6
484  // fallthrough
485  case 9:
486  to[ 8] = from[ n - 9]; // x x x 7
487  // fallthrough
488  case 8:
489  to[ 7] = from[ n - 8]; // x x 0 8
490  // fallthrough
491  case 7:
492  to[ 6] = from[ n - 7]; // x x 1 9
493  // fallthrough
494  case 6:
495  to[ 5] = from[ n - 6]; // x x 2 10
496  // fallthrough
497  case 5:
498  to[ 4] = from[ n - 5]; // x x 3 11
499  // fallthrough
500  case 4:
501  to[ 3] = from[ n - 4]; // x 0 4 12
502  // fallthrough
503  case 3:
504  to[ 2] = from[ n - 3]; // x 1 5 13
505  // fallthrough
506  case 2:
507  to[ 1] = from[ n - 2]; // 0 2 6 14
508  // fallthrough
509  case 1:
510  to[ 0] = from[ n - 1]; // 1 3 7 15
511  // fallthrough
512  case 0:
513  return;
514  default:
515  good_bit_ = false;
516  }
517 }
bool good_bit_
Indicates the current state of the stream abstraction.
Definition: Serializer.h:873

◆ trim()

ACE_Message_Block * OpenDDS::DCPS::Serializer::trim ( size_t  n) const

Return a duplicated Message Block (chain) which starts at the current read position (rpos) and extends for n bytes. This can be used to treat a subset of the original message as if it was itself a full message, for example the SerializedPayload or the Parameter value inside a ParameterList. The returned object should be release()'d (use Message_Block_Ptr)

Definition at line 688 of file Serializer.cpp.

References ACE_Message_Block::cont(), current_, dup(), ACE_Message_Block::duplicate(), good_bit(), ACE_Message_Block::length(), length(), and ACE_Message_Block::release().

689 {
690  if (!good_bit() || !current_ || n > length()) {
691  return 0;
692  }
694  ACE_Message_Block* i = dup.get();
695  for (size_t remain = n; i && remain; i = i->cont()) {
696  if (i->length() >= remain) {
697  i->wr_ptr(i->rd_ptr() + remain);
698  ACE_Message_Block::release(i->cont());
699  i->cont(0);
700  break;
701  }
702  remain -= i->length();
703  }
704  return dup.release();
705 }
size_t length(void) const
size_t length() const
Number of bytes left to read in message block chain.
Definition: Serializer.inl:437
virtual ACE_Message_Block * release(void)
unique_ptr< ACE_Message_Block, Message_Block_Deleter > Message_Block_Ptr
ACE_Message_Block * cont(void) const
virtual ACE_Message_Block * duplicate(void) const
ACE_Message_Block * current_
Currently active message block in chain.
Definition: Serializer.h:864
ACE_HANDLE dup(ACE_HANDLE handle)

◆ wpos()

size_t OpenDDS::DCPS::Serializer::wpos ( ) const
inline

Examine the logical writing position of the stream.

Definition at line 478 of file Serializer.h.

Referenced by OpenDDS::DCPS::Serializer::ScopedAlignmentContext::restore().

478 { return wpos_; }
size_t wpos_
Logical writing position of the stream.
Definition: Serializer.h:894

◆ write_array() [1/2]

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 502 of file Serializer.inl.

References ACE_INLINE.

Referenced by OpenDDS::DCPS::operator<<().

503 {
504  write_array(x, size, length, swap_bytes_);
505 }
bool swap_bytes_
Indicates whether bytes will be swapped for this stream.
Definition: Serializer.h:870
size_t length() const
Number of bytes left to read in message block chain.
Definition: Serializer.inl:437
void write_array(const char *x, size_t size, ACE_CDR::ULong length)
Definition: Serializer.inl:502

◆ write_array() [2/2]

ACE_INLINE void OpenDDS::DCPS::Serializer::write_array ( const char *  x,
size_t  size,
ACE_CDR::ULong  length,
bool  swap 
)
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 508 of file Serializer.inl.

References ACE_INLINE.

510 {
511  if (!swap || size == 1) {
512  //
513  // No swap, copy direct.
514  //
515  buffer_write(x, size * length, false);
516 
517  } else {
518  //
519  // Swapping _must_ be done at 'size' boundaries, so we need to spin
520  // through the array element by element.
521  // NOTE: This assumes that there is _no_ padding between the array
522  // elements. If this is not the case, do not use this
523  // method.
524  //
525  while (length-- > 0) {
526  buffer_write(x, size, true);
527  x += size;
528  }
529  }
530 }
void swap(MessageBlock &lhs, MessageBlock &rhs)
void buffer_write(const char *src, size_t size, bool swap)
Write to the chain from a source buffer.
Definition: Serializer.inl:393
size_t length() const
Number of bytes left to read in message block chain.
Definition: Serializer.inl:437

◆ write_boolean_array()

ACE_INLINE bool OpenDDS::DCPS::Serializer::write_boolean_array ( const ACE_CDR::Boolean x,
ACE_CDR::ULong  length 
)

Array write operations Note: the portion written starts at x and ends at x + length. The length is NOT stored into the CDR stream.

Definition at line 671 of file Serializer.inl.

References ACE_INLINE, and OpenDDS::DCPS::boolean_cdr_size.

Referenced by OpenDDS::XTypes::DynamicDataImpl::DataContainer::serialize_primitive_array().

673 {
674  write_array(reinterpret_cast<const char*>(x), boolean_cdr_size, length);
675  return good_bit();
676 }
const size_t boolean_cdr_size
Definition: Serializer.h:89
size_t length() const
Number of bytes left to read in message block chain.
Definition: Serializer.inl:437
void write_array(const char *x, size_t size, ACE_CDR::ULong length)
Definition: Serializer.inl:502

◆ write_char_array()

ACE_INLINE bool OpenDDS::DCPS::Serializer::write_char_array ( const ACE_CDR::Char x,
ACE_CDR::ULong  length 
)

Array write operations Note: the portion written starts at x and ends at x + length. The length is NOT stored into the CDR stream.

Definition at line 679 of file Serializer.inl.

References ACE_INLINE, and OpenDDS::DCPS::char8_cdr_size.

Referenced by OpenDDS::XTypes::DynamicDataImpl::DataContainer::serialize_primitive_array().

680 {
681  write_array(reinterpret_cast<const char*>(x), char8_cdr_size, length);
682  return good_bit();
683 }
size_t length() const
Number of bytes left to read in message block chain.
Definition: Serializer.inl:437
const size_t char8_cdr_size
Definition: Serializer.h:102
void write_array(const char *x, size_t size, ACE_CDR::ULong length)
Definition: Serializer.inl:502

◆ write_delimiter()

ACE_INLINE bool OpenDDS::DCPS::Serializer::write_delimiter ( size_t  size)

Write a delimiter used for XCDR2 delimited data.

Size is assumed to include the delimiter as serialized_size would return. Returns true if successful.

Definition at line 925 of file Serializer.inl.

References ACE_INLINE, OpenDDS::STUN::encoding(), OpenDDS::DCPS::uint32_cdr_size, OpenDDS::DCPS::Encoding::xcdr_version(), and OpenDDS::DCPS::Encoding::XCDR_VERSION_2.

Referenced by OpenDDS::DCPS::operator<<(), OpenDDS::XTypes::DynamicDataImpl::DataContainer::serialize_bitmask_array_as_uints_i(), OpenDDS::XTypes::DynamicDataImpl::DataContainer::serialize_bitmask_sequence_as_uints_i(), OpenDDS::XTypes::DynamicDataImpl::DataContainer::serialize_complex_array(), OpenDDS::XTypes::DynamicDataImpl::DataContainer::serialize_complex_sequence(), OpenDDS::XTypes::DynamicDataImpl::DataContainer::serialize_enum_array_as_ints_i(), OpenDDS::XTypes::DynamicDataImpl::DataContainer::serialize_enum_sequence_as_ints_i(), OpenDDS::XTypes::DynamicDataImpl::DataContainer::serialize_generic_string_array(), OpenDDS::XTypes::DynamicDataImpl::DataContainer::serialize_generic_string_sequence(), OpenDDS::XTypes::DynamicDataImpl::DataContainer::serialize_nested_bitmask_sequences(), OpenDDS::XTypes::DynamicDataImpl::DataContainer::serialize_nested_enum_sequences(), OpenDDS::XTypes::DynamicDataImpl::DataContainer::serialize_nesting_basic_array_i(), OpenDDS::XTypes::DynamicDataImpl::DataContainer::serialize_nesting_basic_sequence_i(), OpenDDS::XTypes::DynamicDataImpl::DataContainer::serialize_nesting_bitmask_array(), OpenDDS::XTypes::DynamicDataImpl::DataContainer::serialize_nesting_bitmask_sequence(), OpenDDS::XTypes::DynamicDataImpl::DataContainer::serialize_nesting_enum_array(), OpenDDS::XTypes::DynamicDataImpl::DataContainer::serialize_nesting_enum_sequence(), OpenDDS::XTypes::DynamicDataImpl::DataContainer::serialize_sequence_member_default_value(), OpenDDS::XTypes::DynamicDataImpl::DataContainer::serialize_structure_xcdr2(), OpenDDS::XTypes::DynamicDataImpl::DataContainer::serialize_union_xcdr2(), and OpenDDS::XTypes::write_empty_xcdr2_nonfinal().

926 {
927  if (encoding().xcdr_version() == Encoding::XCDR_VERSION_2) {
928  return *this << static_cast<ACE_CDR::ULong>(size - uint32_cdr_size);
929  }
930  return true;
931 }
const size_t uint32_cdr_size
Definition: Serializer.h:96
const Encoding & encoding() const
Definition: Serializer.inl:199

◆ write_double_array()

ACE_INLINE bool OpenDDS::DCPS::Serializer::write_double_array ( const ACE_CDR::Double x,
ACE_CDR::ULong  length 
)

Array write operations Note: the portion written starts at x and ends at x + length. The length is NOT stored into the CDR stream.

Definition at line 792 of file Serializer.inl.

References ACE_INLINE, and OpenDDS::DCPS::float64_cdr_size.

Referenced by OpenDDS::XTypes::DynamicDataImpl::DataContainer::serialize_primitive_array().

793 {
794  if (!align_w(float64_cdr_size)) {
795  return false;
796  }
797  write_array(reinterpret_cast<const char*>(x), float64_cdr_size, length);
798  return good_bit();
799 }
const size_t float64_cdr_size
Definition: Serializer.h:100
size_t length() const
Number of bytes left to read in message block chain.
Definition: Serializer.inl:437
bool align_w(size_t alignment)
Definition: Serializer.inl:830
void write_array(const char *x, size_t size, ACE_CDR::ULong length)
Definition: Serializer.inl:502

◆ write_float_array()

ACE_INLINE bool OpenDDS::DCPS::Serializer::write_float_array ( const ACE_CDR::Float x,
ACE_CDR::ULong  length 
)

Array write operations Note: the portion written starts at x and ends at x + length. The length is NOT stored into the CDR stream.

Definition at line 782 of file Serializer.inl.

References ACE_INLINE, and OpenDDS::DCPS::float32_cdr_size.

Referenced by OpenDDS::XTypes::DynamicDataImpl::DataContainer::serialize_primitive_array().

783 {
784  if (!align_w(float32_cdr_size)) {
785  return false;
786  }
787  write_array(reinterpret_cast<const char*>(x), float32_cdr_size, length);
788  return good_bit();
789 }
const size_t float32_cdr_size
Definition: Serializer.h:99
size_t length() const
Number of bytes left to read in message block chain.
Definition: Serializer.inl:437
bool align_w(size_t alignment)
Definition: Serializer.inl:830
void write_array(const char *x, size_t size, ACE_CDR::ULong length)
Definition: Serializer.inl:502

◆ write_list_end_parameter_id()

ACE_INLINE bool OpenDDS::DCPS::Serializer::write_list_end_parameter_id ( )

Write the parameter ID that marks the end of XCDR1 parameter lists.

Returns true if successful.

Definition at line 934 of file Serializer.inl.

References ACE_INLINE, OpenDDS::STUN::encoding(), OpenDDS::DCPS::xcdr1_pid_alignment, OpenDDS::DCPS::Encoding::xcdr_version(), and OpenDDS::DCPS::Encoding::XCDR_VERSION_1.

935 {
936  if (encoding().xcdr_version() == Encoding::XCDR_VERSION_1) {
937  return align_w(xcdr1_pid_alignment) && *this << pid_list_end && *this << ACE_CDR::UShort(0);
938  }
939  return true;
940 }
static const ACE_CDR::UShort pid_list_end
Definition: Serializer.h:378
const size_t xcdr1_pid_alignment
Definition: Serializer.h:104
ACE_UINT16 UShort
bool align_w(size_t alignment)
Definition: Serializer.inl:830
const Encoding & encoding() const
Definition: Serializer.inl:199

◆ write_long_array()

ACE_INLINE bool OpenDDS::DCPS::Serializer::write_long_array ( const ACE_CDR::Long x,
ACE_CDR::ULong  length 
)

Array write operations Note: the portion written starts at x and ends at x + length. The length is NOT stored into the CDR stream.

Definition at line 740 of file Serializer.inl.

References ACE_INLINE, and OpenDDS::DCPS::int32_cdr_size.

Referenced by OpenDDS::DCPS::operator<<(), OpenDDS::XTypes::DynamicDataImpl::DataContainer::serialize_enum_array_as_ints_i(), OpenDDS::XTypes::DynamicDataImpl::DataContainer::serialize_enum_sequence_as_ints_i(), and OpenDDS::XTypes::DynamicDataImpl::DataContainer::serialize_primitive_array().

741 {
742  if (!align_w(int32_cdr_size)) {
743  return false;
744  }
745  write_array(reinterpret_cast<const char*>(x), int32_cdr_size, length);
746  return good_bit();
747 }
size_t length() const
Number of bytes left to read in message block chain.
Definition: Serializer.inl:437
const size_t int32_cdr_size
Definition: Serializer.h:95
bool align_w(size_t alignment)
Definition: Serializer.inl:830
void write_array(const char *x, size_t size, ACE_CDR::ULong length)
Definition: Serializer.inl:502

◆ write_longdouble_array()

ACE_INLINE bool OpenDDS::DCPS::Serializer::write_longdouble_array ( const ACE_CDR::LongDouble x,
ACE_CDR::ULong  length 
)

Array write operations Note: the portion written starts at x and ends at x + length. The length is NOT stored into the CDR stream.

Definition at line 802 of file Serializer.inl.

References ACE_INLINE, and OpenDDS::DCPS::float128_cdr_size.

Referenced by OpenDDS::XTypes::DynamicDataImpl::DataContainer::serialize_primitive_array().

804 {
805  if (!align_w(float128_cdr_size)) {
806  return false;
807  }
808  write_array(reinterpret_cast<const char*>(x), float128_cdr_size, length);
809  return good_bit();
810 }
size_t length() const
Number of bytes left to read in message block chain.
Definition: Serializer.inl:437
bool align_w(size_t alignment)
Definition: Serializer.inl:830
void write_array(const char *x, size_t size, ACE_CDR::ULong length)
Definition: Serializer.inl:502
const size_t float128_cdr_size
Definition: Serializer.h:101

◆ write_longlong_array()

ACE_INLINE bool OpenDDS::DCPS::Serializer::write_longlong_array ( const ACE_CDR::LongLong x,
ACE_CDR::ULong  length 
)

Array write operations Note: the portion written starts at x and ends at x + length. The length is NOT stored into the CDR stream.

Definition at line 760 of file Serializer.inl.

References ACE_INLINE, and OpenDDS::DCPS::int64_cdr_size.

Referenced by OpenDDS::XTypes::DynamicDataImpl::DataContainer::serialize_primitive_array().

762 {
763  if (!align_w(int64_cdr_size)) {
764  return false;
765  }
766  write_array(reinterpret_cast<const char*>(x), int64_cdr_size, length);
767  return good_bit();
768 }
const size_t int64_cdr_size
Definition: Serializer.h:97
size_t length() const
Number of bytes left to read in message block chain.
Definition: Serializer.inl:437
bool align_w(size_t alignment)
Definition: Serializer.inl:830
void write_array(const char *x, size_t size, ACE_CDR::ULong length)
Definition: Serializer.inl:502

◆ write_octet_array()

ACE_INLINE bool OpenDDS::DCPS::Serializer::write_octet_array ( const ACE_CDR::Octet x,
ACE_CDR::ULong  length 
)

Array write operations Note: the portion written starts at x and ends at x + length. The length is NOT stored into the CDR stream.

Definition at line 697 of file Serializer.inl.

References ACE_INLINE, OpenDDS::DCPS::byte_cdr_size, OpenDDS::DCPS::int8_cdr_size, and OpenDDS::DCPS::uint8_cdr_size.

Referenced by OpenDDS::Security::CryptoBuiltInImpl::encode_rtps_message(), OpenDDS::Security::CryptoBuiltInImpl::encode_serialized_payload(), OpenDDS::Security::CryptoBuiltInImpl::encode_submessage(), OpenDDS::DCPS::RtpsUdpSendStrategy::marshal_transport_header(), OpenDDS::DCPS::operator<<(), OpenDDS::STUN::operator<<(), OpenDDS::XTypes::DynamicDataImpl::DataContainer::serialize_primitive_array(), and OpenDDS::DCPS::ReceivedDataSample::write_data().

698 {
699  write_array(reinterpret_cast<const char*>(x), byte_cdr_size, length);
700  return good_bit();
701 }
size_t length() const
Number of bytes left to read in message block chain.
Definition: Serializer.inl:437
void write_array(const char *x, size_t size, ACE_CDR::ULong length)
Definition: Serializer.inl:502
const size_t byte_cdr_size
Definition: Serializer.h:90

◆ write_parameter_id()

bool OpenDDS::DCPS::Serializer::write_parameter_id ( const unsigned  id,
size_t  size,
bool  must_understand = false 
)

Write a XCDR parameter ID used in XCDR parameter lists.

Returns true if successful.

Definition at line 784 of file Serializer.cpp.

References align_w(), emheader_must_understand, encoding(), MEMBER_ID_MAX, OPENDDS_END_VERSIONED_NAMESPACE_DECL, pid_extended, pid_impl_extension, pid_must_understand, reset_alignment(), OpenDDS::DCPS::xcdr1_pid_alignment, OpenDDS::DCPS::Encoding::xcdr_version(), OpenDDS::DCPS::Encoding::XCDR_VERSION_1, and OpenDDS::DCPS::Encoding::XCDR_VERSION_2.

Referenced by OpenDDS::DCPS::operator<<(), OpenDDS::XTypes::DynamicDataImpl::DataContainer::serialize_basic_struct_member_xcdr2(), OpenDDS::XTypes::DynamicDataImpl::DataContainer::serialize_complex_aggregated_member_xcdr2(), OpenDDS::XTypes::DynamicDataImpl::DataContainer::serialize_complex_aggregated_member_xcdr2_default(), OpenDDS::XTypes::DynamicDataImpl::DataContainer::serialize_discriminator_member_xcdr2(), OpenDDS::XTypes::DynamicDataImpl::DataContainer::serialize_sequence_aggregated_member_xcdr2(), OpenDDS::XTypes::DynamicDataImpl::DataContainer::serialize_sequence_struct_member_xcdr2(), OpenDDS::XTypes::DynamicDataImpl::DataContainer::serialize_single_aggregated_member_xcdr2(), and OpenDDS::XTypes::DynamicDataImpl::DataContainer::serialize_union_xcdr2().

785 {
786  if (static_cast<ACE_CDR::ULong>(id) > MEMBER_ID_MAX) {
787  return false;
788  }
789 
791  if (xcdr == Encoding::XCDR_VERSION_1) {
793  return false;
794  }
795 
796  // Determine if we need to use a short or long PID
797  const bool long_pid = id > (1 << 14) || size > (1 << 16);
798 
799  // Write the short part of the PID
800  /*
801  * TODO(iguessthislldo): Control when to use "must understand" and "impl
802  * extension"?
803  *
804  * The XTypes CDR rules seem to imply they're alway here but that doesn't
805  * sound quite right.
806  *
807  * Also see TODOs above and the TODO below.
808  */
809  const ACE_CDR::UShort pid_id =
811  (long_pid ? pid_extended : static_cast<ACE_CDR::UShort>(id));
812  if (!(*this << pid_id)) {
813  return false;
814  }
815  const ACE_CDR::UShort pid_size = long_pid ? 8 : ACE_CDR::UShort(size);
816  if (!(*this << pid_size)) {
817  return false;
818  }
819 
820  // If PID is long, write the extended/long part.
821  if (long_pid && (
822  !(*this << static_cast<ACE_CDR::ULong>(id)) ||
823  !(*this << static_cast<ACE_CDR::ULong>(size)))) {
824  return false;
825  }
826 
827  reset_alignment();
828  } else if (xcdr == Encoding::XCDR_VERSION_2) {
829  // Compute Length Code, write EM Header and NEXTINT
830  const ACE_CDR::ULong lc = (size == 1 ? 0 : size == 2 ? 1 : size == 4 ? 2 : size == 8 ? 3 : 4);
831  const ACE_CDR::ULong emheader = (lc << 28) | id | (must_understand ? emheader_must_understand : 0);
832  if (!(*this << emheader)) {
833  return false;
834  }
835  if (lc == 4) {
836  return *this << ACE_CDR::ULong(size);
837  }
838  }
839  return true;
840 }
static const ACE_CDR::UShort pid_must_understand
Definition: Serializer.h:380
static const ACE_CDR::ULong MEMBER_ID_MAX
Maximum value for member id.
Definition: Serializer.h:387
static const ACE_CDR::UShort pid_extended
Definition: Serializer.h:373
void reset_alignment()
Reset alignment as if a new instance were created.
Definition: Serializer.cpp:443
const size_t xcdr1_pid_alignment
Definition: Serializer.h:104
ACE_UINT16 UShort
static const ACE_CDR::ULong emheader_must_understand
Definition: Serializer.h:384
ACE_UINT32 ULong
XcdrVersion xcdr_version() const
Definition: Serializer.inl:127
bool align_w(size_t alignment)
Definition: Serializer.inl:830
static const ACE_CDR::UShort pid_impl_extension
Definition: Serializer.h:379
const Encoding & encoding() const
Definition: Serializer.inl:199

◆ write_short_array()

ACE_INLINE bool OpenDDS::DCPS::Serializer::write_short_array ( const ACE_CDR::Short x,
ACE_CDR::ULong  length 
)

Array write operations Note: the portion written starts at x and ends at x + length. The length is NOT stored into the CDR stream.

Definition at line 720 of file Serializer.inl.

References ACE_INLINE, and OpenDDS::DCPS::int16_cdr_size.

Referenced by OpenDDS::XTypes::DynamicDataImpl::DataContainer::serialize_enum_array_as_ints_i(), OpenDDS::XTypes::DynamicDataImpl::DataContainer::serialize_enum_sequence_as_ints_i(), and OpenDDS::XTypes::DynamicDataImpl::DataContainer::serialize_primitive_array().

721 {
722  if (!align_w(int16_cdr_size)) {
723  return false;
724  }
725  write_array(reinterpret_cast<const char*>(x), int16_cdr_size, length);
726  return good_bit();
727 }
const size_t int16_cdr_size
Definition: Serializer.h:93
size_t length() const
Number of bytes left to read in message block chain.
Definition: Serializer.inl:437
bool align_w(size_t alignment)
Definition: Serializer.inl:830
void write_array(const char *x, size_t size, ACE_CDR::ULong length)
Definition: Serializer.inl:502

◆ write_ulong_array()

ACE_INLINE bool OpenDDS::DCPS::Serializer::write_ulong_array ( const ACE_CDR::ULong x,
ACE_CDR::ULong  length 
)

Array write operations Note: the portion written starts at x and ends at x + length. The length is NOT stored into the CDR stream.

Definition at line 750 of file Serializer.inl.

References ACE_INLINE, and OpenDDS::DCPS::uint32_cdr_size.

Referenced by OpenDDS::DCPS::operator<<(), OpenDDS::XTypes::DynamicDataImpl::DataContainer::serialize_bitmask_array_as_uints_i(), OpenDDS::XTypes::DynamicDataImpl::DataContainer::serialize_bitmask_sequence_as_uints_i(), and OpenDDS::XTypes::DynamicDataImpl::DataContainer::serialize_primitive_array().

751 {
752  if (!align_w(uint32_cdr_size)) {
753  return false;
754  }
755  write_array(reinterpret_cast<const char*>(x), uint32_cdr_size, length);
756  return good_bit();
757 }
const size_t uint32_cdr_size
Definition: Serializer.h:96
size_t length() const
Number of bytes left to read in message block chain.
Definition: Serializer.inl:437
bool align_w(size_t alignment)
Definition: Serializer.inl:830
void write_array(const char *x, size_t size, ACE_CDR::ULong length)
Definition: Serializer.inl:502

◆ write_ulonglong_array()

ACE_INLINE bool OpenDDS::DCPS::Serializer::write_ulonglong_array ( const ACE_CDR::ULongLong x,
ACE_CDR::ULong  length 
)

Array write operations Note: the portion written starts at x and ends at x + length. The length is NOT stored into the CDR stream.

Definition at line 771 of file Serializer.inl.

References ACE_INLINE, and OpenDDS::DCPS::uint64_cdr_size.

Referenced by OpenDDS::XTypes::DynamicDataImpl::DataContainer::serialize_bitmask_array_as_uints_i(), OpenDDS::XTypes::DynamicDataImpl::DataContainer::serialize_bitmask_sequence_as_uints_i(), and OpenDDS::XTypes::DynamicDataImpl::DataContainer::serialize_primitive_array().

773 {
774  if (!align_w(uint64_cdr_size)) {
775  return false;
776  }
777  write_array(reinterpret_cast<const char*>(x), uint64_cdr_size, length);
778  return good_bit();
779 }
const size_t uint64_cdr_size
Definition: Serializer.h:98
size_t length() const
Number of bytes left to read in message block chain.
Definition: Serializer.inl:437
bool align_w(size_t alignment)
Definition: Serializer.inl:830
void write_array(const char *x, size_t size, ACE_CDR::ULong length)
Definition: Serializer.inl:502

◆ write_ushort_array()

ACE_INLINE bool OpenDDS::DCPS::Serializer::write_ushort_array ( const ACE_CDR::UShort x,
ACE_CDR::ULong  length 
)

Array write operations Note: the portion written starts at x and ends at x + length. The length is NOT stored into the CDR stream.

Definition at line 730 of file Serializer.inl.

References ACE_INLINE, and OpenDDS::DCPS::uint16_cdr_size.

Referenced by OpenDDS::XTypes::DynamicDataImpl::DataContainer::serialize_bitmask_array_as_uints_i(), OpenDDS::XTypes::DynamicDataImpl::DataContainer::serialize_bitmask_sequence_as_uints_i(), and OpenDDS::XTypes::DynamicDataImpl::DataContainer::serialize_primitive_array().

731 {
732  if (!align_w(uint16_cdr_size)) {
733  return false;
734  }
735  write_array(reinterpret_cast<const char*>(x), uint16_cdr_size, length);
736  return good_bit();
737 }
size_t length() const
Number of bytes left to read in message block chain.
Definition: Serializer.inl:437
bool align_w(size_t alignment)
Definition: Serializer.inl:830
const size_t uint16_cdr_size
Definition: Serializer.h:94
void write_array(const char *x, size_t size, ACE_CDR::ULong length)
Definition: Serializer.inl:502

◆ write_wchar_array()

ACE_INLINE bool OpenDDS::DCPS::Serializer::write_wchar_array ( const ACE_CDR::WChar x,
ACE_CDR::ULong  length 
)

Array write operations Note: the portion written starts at x and ends at x + length. The length is NOT stored into the CDR stream.

Definition at line 686 of file Serializer.inl.

References ACE_INLINE.

Referenced by OpenDDS::XTypes::DynamicDataImpl::DataContainer::serialize_primitive_array().

687 {
688  for (ACE_CDR::ULong i = 0; i < length; ++i) {
689  if (!((*this) << ACE_OutputCDR::from_wchar(x[i]))) {
690  break;
691  }
692  }
693  return good_bit();
694 }
size_t length() const
Number of bytes left to read in message block chain.
Definition: Serializer.inl:437
ACE_UINT32 ULong

Friends And Related Function Documentation

◆ operator<< [1/20]

OpenDDS_Dcps_Export bool operator<< ( Serializer s,
ACE_CDR::Char  x 
)
friend

Definition at line 951 of file Serializer.inl.

952 {
953  s.buffer_write(reinterpret_cast<char*>(&x), char8_cdr_size, s.swap_bytes());
954  return s.good_bit();
955 }
const size_t char8_cdr_size
Definition: Serializer.h:102

◆ operator<< [2/20]

OpenDDS_Dcps_Export bool operator<< ( Serializer s,
ACE_CDR::Short  x 
)
friend

Definition at line 958 of file Serializer.inl.

959 {
960  if (!s.align_w(int16_cdr_size)) {
961  return false;
962  }
963  s.buffer_write(reinterpret_cast<char*>(&x), int16_cdr_size, s.swap_bytes());
964  return s.good_bit();
965 }
const size_t int16_cdr_size
Definition: Serializer.h:93

◆ operator<< [3/20]

OpenDDS_Dcps_Export bool operator<< ( Serializer s,
ACE_CDR::UShort  x 
)
friend

Definition at line 968 of file Serializer.inl.

969 {
970  if (!s.align_w(uint16_cdr_size)) {
971  return false;
972  }
973  s.buffer_write(reinterpret_cast<char*>(&x), uint16_cdr_size, s.swap_bytes());
974  return s.good_bit();
975 }
const size_t uint16_cdr_size
Definition: Serializer.h:94

◆ operator<< [4/20]

OpenDDS_Dcps_Export bool operator<< ( Serializer s,
ACE_CDR::Long  x 
)
friend

Definition at line 978 of file Serializer.inl.

979 {
980  if (!s.align_w(int32_cdr_size)) {
981  return false;
982  }
983  s.buffer_write(reinterpret_cast<char*>(&x), int32_cdr_size, s.swap_bytes());
984  return s.good_bit();
985 }
const size_t int32_cdr_size
Definition: Serializer.h:95

◆ operator<< [5/20]

OpenDDS_Dcps_Export bool operator<< ( Serializer s,
ACE_CDR::ULong  x 
)
friend

Definition at line 988 of file Serializer.inl.

989 {
990  if (!s.align_w(uint32_cdr_size)) {
991  return false;
992  }
993  s.buffer_write(reinterpret_cast<char*>(&x), uint32_cdr_size, s.swap_bytes());
994  return s.good_bit();
995 }
const size_t uint32_cdr_size
Definition: Serializer.h:96

◆ operator<< [6/20]

OpenDDS_Dcps_Export bool operator<< ( Serializer s,
ACE_CDR::LongLong  x 
)
friend

Definition at line 998 of file Serializer.inl.

999 {
1000  if (!s.align_w(int64_cdr_size)) {
1001  return false;
1002  }
1003  s.buffer_write(reinterpret_cast<char*>(&x), int64_cdr_size, s.swap_bytes());
1004  return s.good_bit();
1005 }
const size_t int64_cdr_size
Definition: Serializer.h:97

◆ operator<< [7/20]

OpenDDS_Dcps_Export bool operator<< ( Serializer s,
ACE_CDR::ULongLong  x 
)
friend

Definition at line 1008 of file Serializer.inl.

1009 {
1010  if (!s.align_w(uint64_cdr_size)) {
1011  return false;
1012  }
1013  s.buffer_write(reinterpret_cast<char*>(&x), uint64_cdr_size, s.swap_bytes());
1014  return s.good_bit();
1015 }
const size_t uint64_cdr_size
Definition: Serializer.h:98

◆ operator<< [8/20]

OpenDDS_Dcps_Export bool operator<< ( Serializer s,
ACE_CDR::Float  x 
)
friend

Definition at line 1018 of file Serializer.inl.

1019 {
1020  if (!s.align_w(float32_cdr_size)) {
1021  return false;
1022  }
1023  s.buffer_write(reinterpret_cast<char*>(&x), float32_cdr_size, s.swap_bytes());
1024  return s.good_bit();
1025 }
const size_t float32_cdr_size
Definition: Serializer.h:99

◆ operator<< [9/20]

OpenDDS_Dcps_Export bool operator<< ( Serializer s,
ACE_CDR::Double  x 
)
friend

Definition at line 1028 of file Serializer.inl.

1029 {
1030  if (!s.align_w(float64_cdr_size)) {
1031  return false;
1032  }
1033  s.buffer_write(reinterpret_cast<char*>(&x), float64_cdr_size, s.swap_bytes());
1034  return s.good_bit();
1035 }
const size_t float64_cdr_size
Definition: Serializer.h:100

◆ operator<< [10/20]

OpenDDS_Dcps_Export bool operator<< ( Serializer s,
ACE_CDR::LongDouble  x 
)
friend

Definition at line 1038 of file Serializer.inl.

1039 {
1040  if (!s.align_w(float128_cdr_size)) {
1041  return false;
1042  }
1043  s.buffer_write(reinterpret_cast<char*>(&x), float128_cdr_size, s.swap_bytes());
1044  return s.good_bit();
1045 }
const size_t float128_cdr_size
Definition: Serializer.h:101

◆ operator<< [11/20]

OpenDDS_Dcps_Export bool operator<< ( Serializer s,
const ACE_CDR::Char x 
)
friend

Definition at line 1048 of file Serializer.inl.

1049 {
1050  if (x != 0) {
1051  // Include the null termination in the serialized data.
1052  const ACE_CDR::ULong stringlen =
1053  1 + static_cast<ACE_CDR::ULong>(std::strlen(x));
1054  s << stringlen;
1055  s.buffer_write(reinterpret_cast<const char*>(x), stringlen, false);
1056 
1057  } else {
1058  s << ACE_CDR::ULong(0);
1059  }
1060 
1061  return s.good_bit();
1062 }
ACE_UINT32 ULong

◆ operator<< [12/20]

OpenDDS_Dcps_Export bool operator<< ( Serializer s,
const ACE_CDR::WChar x 
)
friend

Definition at line 1065 of file Serializer.inl.

1066 {
1067  if (x != 0) {
1068  // Do not include the null terminatator in the serialized data.
1069  const ACE_CDR::ULong length = static_cast<ACE_CDR::ULong>(ACE_OS::strlen(x));
1070  s << ACE_CDR::ULong(length * char16_cdr_size);
1071 
1072 #if ACE_SIZEOF_WCHAR == 2
1073  s.write_array(reinterpret_cast<const char*>(x), char16_cdr_size, length,
1074  s.swap_bytes());
1075 #else
1076  for (size_t i = 0; i < length && s.good_bit(); ++i) {
1077  const ACE_UINT16 as_utf16 = static_cast<ACE_UINT16>(x[i]);
1078  if (as_utf16 != x[i]) { // not currently handling surrogates
1079  s.good_bit_ = false;
1080  break;
1081  }
1082  s.buffer_write(reinterpret_cast<const char*>(&as_utf16), char16_cdr_size,
1083  s.swap_bytes());
1084  }
1085 #endif
1086  } else {
1087  s << ACE_CDR::ULong(0);
1088  }
1089 
1090  return s.good_bit();
1091 }
size_t strlen(const char *s)
size_t length() const
Number of bytes left to read in message block chain.
Definition: Serializer.inl:437
ACE_UINT32 ULong
const size_t char16_cdr_size
Definition: Serializer.h:103

◆ operator<< [13/20]

OpenDDS_Dcps_Export bool operator<< ( Serializer s,
ACE_OutputCDR::from_boolean  x 
)
friend

Definition at line 1107 of file Serializer.inl.

1108 {
1109  s.buffer_write(reinterpret_cast<char*>(&x.val_), boolean_cdr_size, false);
1110  return s.good_bit();
1111 }
const size_t boolean_cdr_size
Definition: Serializer.h:89

◆ operator<< [14/20]

OpenDDS_Dcps_Export bool operator<< ( Serializer s,
ACE_OutputCDR::from_char  x 
)
friend

Definition at line 1114 of file Serializer.inl.

1115 {
1116  s.buffer_write(reinterpret_cast<char*>(&x.val_), char8_cdr_size, false);
1117  return s.good_bit();
1118 }
const size_t char8_cdr_size
Definition: Serializer.h:102

◆ operator<< [15/20]

OpenDDS_Dcps_Export bool operator<< ( Serializer s,
ACE_OutputCDR::from_wchar  x 
)
friend

Definition at line 1121 of file Serializer.inl.

1122 {
1123  if (!s.align_w(char16_cdr_size)) {
1124  return false;
1125  }
1126 #if ACE_SIZEOF_WCHAR == 2
1127  s.buffer_write(reinterpret_cast<char*>(&x.val_), char16_cdr_size, s.swap_bytes());
1128 #else
1129  const ACE_UINT16 as_utf16 = static_cast<ACE_UINT16>(x.val_);
1130  if (as_utf16 != x.val_) { // not currently handling surrogates
1131  if (DCPS_debug_level) {
1132  ACE_ERROR((LM_ERROR, ACE_TEXT("(%P|%t) ")
1133  ACE_TEXT("operator<<(Serializer&, ACE_OutputCDR::from_wchar): ")
1134  ACE_TEXT("failure to convert UTF-32 to UTF-16.\n")));
1135  }
1136  s.good_bit_ = false;
1137  } else {
1138  s.buffer_write(reinterpret_cast<const char*>(&as_utf16), char16_cdr_size,
1139  s.swap_bytes());
1140  }
1141 #endif
1142  return s.good_bit();
1143 }
#define ACE_ERROR(X)
ACE_TEXT("TCP_Factory")
OpenDDS_Dcps_Export unsigned int DCPS_debug_level
Definition: debug.cpp:30
const size_t char16_cdr_size
Definition: Serializer.h:103

◆ operator<< [16/20]

OpenDDS_Dcps_Export bool operator<< ( Serializer s,
ACE_OutputCDR::from_octet  x 
)
friend

Definition at line 1172 of file Serializer.inl.

1173 {
1174  s.buffer_write(reinterpret_cast<char*>(&x.val_), byte_cdr_size, false);
1175  return s.good_bit();
1176 }
const size_t byte_cdr_size
Definition: Serializer.h:90

◆ operator<< [17/20]

OpenDDS_Dcps_Export bool operator<< ( Serializer s,
ACE_OutputCDR::from_string  x 
)
friend

Definition at line 1179 of file Serializer.inl.

1180 {
1181  // Include the null termination in the serialized data.
1182  ACE_CDR::ULong stringlen = 0;
1183  if (x.val_ != 0) {
1184  stringlen = 1 + static_cast<ACE_CDR::ULong>(ACE_OS::strlen(x.val_));
1185  s << stringlen;
1186  s.buffer_write(reinterpret_cast<char*>(x.val_), stringlen, false);
1187  } else {
1188  s << ACE_CDR::ULong(0);
1189  }
1190  return s.good_bit() && ((x.bound_ == 0) || (stringlen - 1 <= x.bound_));
1191 }
size_t strlen(const char *s)
ACE_UINT32 ULong

◆ operator<< [18/20]

OpenDDS_Dcps_Export bool operator<< ( Serializer s,
ACE_OutputCDR::from_wstring  x 
)
friend

Definition at line 1194 of file Serializer.inl.

1195 {
1196  s << x.val_;
1197  const ACE_CDR::ULong stringlen =
1198  x.bound_ ? static_cast<ACE_CDR::ULong>(ACE_OS::strlen(x.val_)) : 0;
1199  return s.good_bit() && ((x.bound_ == 0) || (stringlen <= x.bound_));
1200 }
size_t strlen(const char *s)
ACE_UINT32 ULong

◆ operator<< [19/20]

OpenDDS_Dcps_Export bool operator<< ( Serializer s,
const String x 
)
friend

Definition at line 1146 of file Serializer.inl.

1147 {
1148  return s << x.c_str();
1149 }

◆ operator<< [20/20]

OpenDDS_Dcps_Export bool operator<< ( Serializer s,
Serializer::FromBoundedString< char >  x 
)
friend

Definition at line 1152 of file Serializer.inl.

1153 {
1154  return (x.bound_ == 0 || x.str_.size() <= x.bound_) && s << x.str_;
1155 }

◆ operator>> [1/20]

OpenDDS_Dcps_Export bool operator>> ( Serializer s,
ACE_CDR::Char x 
)
friend

Definition at line 1227 of file Serializer.inl.

1228 {
1229  s.buffer_read(reinterpret_cast<char*>(&x), char8_cdr_size, s.swap_bytes());
1230  return s.good_bit();
1231 }
const size_t char8_cdr_size
Definition: Serializer.h:102

◆ operator>> [2/20]

OpenDDS_Dcps_Export bool operator>> ( Serializer s,
ACE_CDR::Short x 
)
friend

Definition at line 1234 of file Serializer.inl.

1235 {
1236  if (!s.align_r(int16_cdr_size)) {
1237  return false;
1238  }
1239  s.buffer_read(reinterpret_cast<char*>(&x), int16_cdr_size, s.swap_bytes());
1240  return s.good_bit();
1241 }
const size_t int16_cdr_size
Definition: Serializer.h:93

◆ operator>> [3/20]

OpenDDS_Dcps_Export bool operator>> ( Serializer s,
ACE_CDR::UShort x 
)
friend

Definition at line 1244 of file Serializer.inl.

1245 {
1246  if (!s.align_r(uint16_cdr_size)) {
1247  return false;
1248  }
1249  s.buffer_read(reinterpret_cast<char*>(&x), uint16_cdr_size, s.swap_bytes());
1250  return s.good_bit();
1251 }
const size_t uint16_cdr_size
Definition: Serializer.h:94

◆ operator>> [4/20]

OpenDDS_Dcps_Export bool operator>> ( Serializer s,
ACE_CDR::Long x 
)
friend

Definition at line 1254 of file Serializer.inl.

1255 {
1256  if (!s.align_r(int32_cdr_size)) {
1257  return false;
1258  }
1259  s.buffer_read(reinterpret_cast<char*>(&x), int32_cdr_size, s.swap_bytes());
1260  return s.good_bit();
1261 }
const size_t int32_cdr_size
Definition: Serializer.h:95

◆ operator>> [5/20]

OpenDDS_Dcps_Export bool operator>> ( Serializer s,
ACE_CDR::ULong x 
)
friend

Definition at line 1264 of file Serializer.inl.

1265 {
1266  if (!s.align_r(uint32_cdr_size)) {
1267  return false;
1268  }
1269  s.buffer_read(reinterpret_cast<char*>(&x), uint32_cdr_size, s.swap_bytes());
1270  return s.good_bit();
1271 }
const size_t uint32_cdr_size
Definition: Serializer.h:96

◆ operator>> [6/20]

OpenDDS_Dcps_Export bool operator>> ( Serializer s,
ACE_CDR::LongLong x 
)
friend

Definition at line 1274 of file Serializer.inl.

1275 {
1276  if (!s.align_r(int64_cdr_size)) {
1277  return false;
1278  }
1279  s.buffer_read(reinterpret_cast<char*>(&x), int64_cdr_size, s.swap_bytes());
1280  return s.good_bit();
1281 }
const size_t int64_cdr_size
Definition: Serializer.h:97

◆ operator>> [7/20]

OpenDDS_Dcps_Export bool operator>> ( Serializer s,
ACE_CDR::ULongLong x 
)
friend

Definition at line 1284 of file Serializer.inl.

1285 {
1286  if (!s.align_r(uint64_cdr_size)) {
1287  return false;
1288  }
1289  s.buffer_read(reinterpret_cast<char*>(&x), uint64_cdr_size, s.swap_bytes());
1290  return s.good_bit();
1291 }
const size_t uint64_cdr_size
Definition: Serializer.h:98

◆ operator>> [8/20]

OpenDDS_Dcps_Export bool operator>> ( Serializer s,
ACE_CDR::Float x 
)
friend

Definition at line 1294 of file Serializer.inl.

1295 {
1296  if (!s.align_r(float32_cdr_size)) {
1297  return false;
1298  }
1299  s.buffer_read(reinterpret_cast<char*>(&x), float32_cdr_size, s.swap_bytes());
1300  return s.good_bit();
1301 }
const size_t float32_cdr_size
Definition: Serializer.h:99

◆ operator>> [9/20]

OpenDDS_Dcps_Export bool operator>> ( Serializer s,
ACE_CDR::Double x 
)
friend

Definition at line 1304 of file Serializer.inl.

1305 {
1306  if (!s.align_r(float64_cdr_size)) {
1307  return false;
1308  }
1309  s.buffer_read(reinterpret_cast<char*>(&x), float64_cdr_size, s.swap_bytes());
1310  return s.good_bit();
1311 }
const size_t float64_cdr_size
Definition: Serializer.h:100

◆ operator>> [10/20]

OpenDDS_Dcps_Export bool operator>> ( Serializer s,
ACE_CDR::LongDouble x 
)
friend

Definition at line 1314 of file Serializer.inl.

1315 {
1316  if (!s.align_r(float128_cdr_size)) {
1317  return false;
1318  }
1319  s.buffer_read(reinterpret_cast<char*>(&x), float128_cdr_size, s.swap_bytes());
1320  return s.good_bit();
1321 }
const size_t float128_cdr_size
Definition: Serializer.h:101

◆ operator>> [11/20]

OpenDDS_Dcps_Export bool operator>> ( Serializer s,
ACE_CDR::Char *&  x 
)
friend

Definition at line 1324 of file Serializer.inl.

1325 {
1326  s.read_string(x);
1327  return s.good_bit();
1328 }

◆ operator>> [12/20]

OpenDDS_Dcps_Export bool operator>> ( Serializer s,
ACE_CDR::WChar *&  x 
)
friend

Definition at line 1331 of file Serializer.inl.

1332 {
1333  s.read_string(x);
1334  return s.good_bit();
1335 }

◆ operator>> [13/20]

OpenDDS_Dcps_Export bool operator>> ( Serializer s,
ACE_InputCDR::to_boolean  x 
)
friend

Definition at line 1354 of file Serializer.inl.

1355 {
1356  s.buffer_read(reinterpret_cast<char*>(&x.ref_), boolean_cdr_size, s.swap_bytes());
1357  return s.good_bit();
1358 }
const size_t boolean_cdr_size
Definition: Serializer.h:89
ACE_CDR::Boolean & ref_

◆ operator>> [14/20]

OpenDDS_Dcps_Export bool operator>> ( Serializer s,
ACE_InputCDR::to_char  x 
)
friend

Definition at line 1361 of file Serializer.inl.

1362 {
1363  s.buffer_read(reinterpret_cast<char*>(&x.ref_), char8_cdr_size, s.swap_bytes());
1364  return s.good_bit();
1365 }
const size_t char8_cdr_size
Definition: Serializer.h:102
ACE_CDR::Char & ref_

◆ operator>> [15/20]

OpenDDS_Dcps_Export bool operator>> ( Serializer s,
ACE_InputCDR::to_wchar  x 
)
friend

Definition at line 1368 of file Serializer.inl.

1369 {
1370  if (!s.align_r(char16_cdr_size)) {
1371  return false;
1372  }
1373 #if ACE_SIZEOF_WCHAR == 2
1374  s.buffer_read(reinterpret_cast<char*>(&x.ref_), char16_cdr_size,
1375  s.swap_bytes());
1376 #else
1377  ACE_UINT16 as_utf16;
1378  s.buffer_read(reinterpret_cast<char*>(&as_utf16), char16_cdr_size,
1379  s.swap_bytes());
1380  x.ref_ = as_utf16;
1381 #endif
1382  return s.good_bit();
1383 }
const size_t char16_cdr_size
Definition: Serializer.h:103
ACE_CDR::WChar & ref_

◆ operator>> [16/20]

OpenDDS_Dcps_Export bool operator>> ( Serializer s,
ACE_InputCDR::to_octet  x 
)
friend

Definition at line 1386 of file Serializer.inl.

1387 {
1388  s.buffer_read(reinterpret_cast<char*>(&x.ref_), byte_cdr_size, false);
1389  return s.good_bit();
1390 }
ACE_CDR::Octet & ref_
const size_t byte_cdr_size
Definition: Serializer.h:90

◆ operator>> [17/20]

OpenDDS_Dcps_Export bool operator>> ( Serializer s,
ACE_InputCDR::to_string  x 
)
friend

Definition at line 1393 of file Serializer.inl.

1394 {
1395  const size_t length = s.read_string(const_cast<char*&>(x.val_));
1396  if (s.good_bit() && (x.bound_ != 0) && (length > x.bound_)) {
1397  s.set_construction_status(Serializer::BoundConstructionFailure);
1398  return false;
1399  }
1400  return s.good_bit();
1401 }
size_t length() const
Number of bytes left to read in message block chain.
Definition: Serializer.inl:437
const ACE_CDR::Char *& val_
ACE_CDR::ULong bound_

◆ operator>> [18/20]

OpenDDS_Dcps_Export bool operator>> ( Serializer s,
ACE_InputCDR::to_wstring  x 
)
friend

Definition at line 1404 of file Serializer.inl.

1405 {
1406  const size_t length = s.read_string(const_cast<ACE_CDR::WChar*&>(x.val_));
1407  if (s.good_bit() && (x.bound_ != 0) && (length > x.bound_)) {
1408  s.set_construction_status(Serializer::BoundConstructionFailure);
1409  return false;
1410  }
1411  return s.good_bit();
1412 }
const ACE_CDR::WChar *& val_
size_t length() const
Number of bytes left to read in message block chain.
Definition: Serializer.inl:437

◆ operator>> [19/20]

OpenDDS_Dcps_Export bool operator>> ( Serializer s,
String x 
)
friend

Definition at line 1431 of file Serializer.inl.

1432 {
1433  char* buf = 0;
1434  const size_t length = s.read_string(buf);
1435  if (!s.good_bit()) {
1436  return false;
1437  }
1438  x.assign(buf, length);
1439  s.free_string(buf);
1440  return true;
1441 }
size_t length() const
Number of bytes left to read in message block chain.
Definition: Serializer.inl:437

◆ operator>> [20/20]

OpenDDS_Dcps_Export bool operator>> ( Serializer s,
Serializer::ToBoundedString< char >  x 
)
friend

Definition at line 1444 of file Serializer.inl.

1445 {
1446  if (s >> x.str_) {
1447  if ((x.bound_ != 0) && (x.str_.size() > x.bound_)) {
1448  s.set_construction_status(Serializer::BoundConstructionFailure);
1449  return false;
1450  }
1451  return true;
1452  }
1453  return false;
1454 }

Member Data Documentation

◆ ALIGN_PAD

const char OpenDDS::DCPS::Serializer::ALIGN_PAD = {0}
staticprivate

Buffer that is copied for zero padding.

Definition at line 897 of file Serializer.h.

Referenced by OpenDDS::DCPS::Encoding::to_string().

◆ align_rshift_

unsigned char OpenDDS::DCPS::Serializer::align_rshift_
private

Number of bytes off of max alignment that the current_ block's rd_ptr() started at.

Definition at line 882 of file Serializer.h.

Referenced by peek(), reset_alignment(), and OpenDDS::DCPS::Serializer::ScopedAlignmentContext::restore().

◆ align_wshift_

unsigned char OpenDDS::DCPS::Serializer::align_wshift_
private

Number of bytes off of max alignment that the current_ block's wr_ptr() started at.

Definition at line 888 of file Serializer.h.

Referenced by reset_alignment(), and OpenDDS::DCPS::Serializer::ScopedAlignmentContext::restore().

◆ construction_status_

ConstructionStatus OpenDDS::DCPS::Serializer::construction_status_
private

The way to judge whether tryconstruct trim is able to be properly done.

Definition at line 876 of file Serializer.h.

◆ current_

ACE_Message_Block* OpenDDS::DCPS::Serializer::current_
private

Currently active message block in chain.

Definition at line 864 of file Serializer.h.

Referenced by peek(), read_string(), reset_alignment(), OpenDDS::DCPS::Serializer::ScopedAlignmentContext::restore(), and trim().

◆ emheader_must_understand

const ACE_CDR::ULong OpenDDS::DCPS::Serializer::emheader_must_understand = 1U << 31U
static

Definition at line 384 of file Serializer.h.

Referenced by read_parameter_id(), and write_parameter_id().

◆ encoding_

Encoding OpenDDS::DCPS::Serializer::encoding_
private

Encoding Settings.

Definition at line 867 of file Serializer.h.

◆ good_bit_

bool OpenDDS::DCPS::Serializer::good_bit_
private

Indicates the current state of the stream abstraction.

Definition at line 873 of file Serializer.h.

Referenced by OpenDDS::DCPS::operator<<(), read_string(), and swapcpy().

◆ MEMBER_ID_MASK

const ACE_CDR::ULong OpenDDS::DCPS::Serializer::MEMBER_ID_MASK = MEMBER_ID_MAX
static

Definition at line 388 of file Serializer.h.

Referenced by OpenDDS::XTypes::hash_member_name_to_id().

◆ MEMBER_ID_MAX

const ACE_CDR::ULong OpenDDS::DCPS::Serializer::MEMBER_ID_MAX = 0x0FFFFFFF
static

Maximum value for member id.

Definition at line 387 of file Serializer.h.

Referenced by invalid_option(), and write_parameter_id().

◆ pid_extended

const ACE_CDR::UShort OpenDDS::DCPS::Serializer::pid_extended = 0x3f01
static

Flags and reserved ids used in parameter list ids.

Definition at line 373 of file Serializer.h.

Referenced by read_parameter_id(), and write_parameter_id().

◆ pid_impl_extension

const ACE_CDR::UShort OpenDDS::DCPS::Serializer::pid_impl_extension = 0x8000
static

Flags and reserved ids used in parameter list ids.

Definition at line 379 of file Serializer.h.

Referenced by write_parameter_id().

◆ pid_list_end

const ACE_CDR::UShort OpenDDS::DCPS::Serializer::pid_list_end = 0x3f02
static

Note that this is different than OpenDDS::RTPS::PID_SENTINEL(0x0001). See XTypes 1.3 Table 34 for details.

Definition at line 378 of file Serializer.h.

◆ pid_must_understand

const ACE_CDR::UShort OpenDDS::DCPS::Serializer::pid_must_understand = 0x4000
static

Flags and reserved ids used in parameter list ids.

Definition at line 380 of file Serializer.h.

Referenced by write_parameter_id().

◆ rpos_

size_t OpenDDS::DCPS::Serializer::rpos_
private

Logical reading position of the stream.

Definition at line 891 of file Serializer.h.

Referenced by peek().

◆ swap_bytes_

bool OpenDDS::DCPS::Serializer::swap_bytes_
private

Indicates whether bytes will be swapped for this stream.

Definition at line 870 of file Serializer.h.

◆ wpos_

size_t OpenDDS::DCPS::Serializer::wpos_
private

Logical writing position of the stream.

Definition at line 894 of file Serializer.h.


The documentation for this class was generated from the following files: