26 #ifndef OPENDDS_DCPS_SERIALIZER_H 27 #define OPENDDS_DCPS_SERIALIZER_H 29 #include <ace/config-macros.h> 30 #ifndef ACE_LACKS_PRAGMA_ONCE 57 #ifdef ACE_LITTLE_ENDIAN 143 ALIGN_MAX = ALIGN_CDR
176 bool zero_init_padding()
const;
177 void zero_init_padding(
bool value);
187 bool skip_sequence_dheader()
const;
188 void skip_sequence_dheader(
bool value);
192 size_t max_align()
const;
195 void align(
size_t&
value,
size_t by = (std::numeric_limits<size_t>::max)())
const;
205 static bool is_encapsulated(
Kind kind);
206 bool is_encapsulated()
const;
237 KIND_CDR_BE = 0x0000,
238 KIND_CDR_LE = 0x0001,
239 KIND_PL_CDR_BE = 0x0002,
240 KIND_PL_CDR_LE = 0x0003,
241 KIND_CDR2_BE = 0x0006,
242 KIND_CDR2_LE = 0x0007,
243 KIND_D_CDR2_BE = 0x0008,
244 KIND_D_CDR2_LE = 0x0009,
245 KIND_PL_CDR2_BE = 0x000a,
246 KIND_PL_CDR2_LE = 0x000b,
248 KIND_INVALID = 0xFFFF
252 const static size_t padding_marker_byte_index = 3;
253 const static size_t padding_marker_alignment = 4;
263 void kind(
Kind value);
265 ACE_UINT16 options()
const;
266 void options(ACE_UINT16 value);
272 bool is_good()
const;
314 template <
typename T>
331 template <
typename T>
339 reinterpret_cast<const char*>(seq.get_buffer()),
343 mb_.wr_ptr(mb_.space());
348 reinterpret_cast<const char*>(seq.get_buffer()),
420 void swap_bytes(
bool do_swap);
421 bool swap_bytes()
const;
430 void reset_alignment();
432 bool good_bit()
const;
435 size_t length()
const;
443 StrAllocate str_alloc = 0,
444 StrFree str_free = 0);
447 StrFree str_free = 0);
450 WStrAllocate str_alloc = 0,
451 WStrFree str_free = 0);
454 WStrFree str_free = 0);
461 bool skip(
size_t n,
int size = 1);
471 const char*
pos_rd()
const {
return current_ ? current_->rd_ptr() : 0; }
472 const char*
pos_wr()
const {
return current_ ? current_->wr_ptr() : 0; }
475 size_t rpos()
const {
return rpos_; }
478 size_t wpos()
const {
return wpos_; }
496 #if OPENDDS_HAS_EXPLICIT_INTS 520 #if OPENDDS_HAS_EXPLICIT_INTS 560 #ifdef NONNATIVE_LONGDOUBLE 578 #if OPENDDS_HAS_EXPLICIT_INTS 588 template <
typename CharT>
590 typedef std::basic_string<CharT, std::char_traits<CharT>,
593 : str_(str), bound_(bound) {}
599 bool operator<<(Serializer& s, FromBoundedString<char> x);
606 bool operator<<(Serializer& s, FromBoundedString<wchar_t> x);
635 #ifdef NONNATIVE_LONGDOUBLE 653 #if OPENDDS_HAS_EXPLICIT_INTS 663 template <
typename CharT>
665 typedef std::basic_string<CharT, std::char_traits<CharT>,
668 : str_(str), bound_(bound) {}
687 void buffer_read(
char* dest,
size_t size,
bool swap);
691 bool align_r(
size_t alignment);
696 bool align_w(
size_t alignment);
703 bool read_parameter_id(
unsigned&
id,
size_t& size,
bool& must_understand);
710 bool write_parameter_id(
const unsigned id,
size_t size,
bool must_understand =
false);
717 bool write_list_end_parameter_id();
724 bool skip_delimiter();
732 bool read_delimiter(
size_t& size);
740 bool write_delimiter(
size_t size);
745 BoundConstructionFailure
767 template <
typename T>
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)) {
776 result = peek_helper(block->
cont(), bytes - length, t);
782 template <
typename T>
786 const size_t rpos = rpos_;
787 const unsigned char align_rshift = align_rshift_;
791 if (!peek_helper(current_, 0, t)) {
797 align_rshift_ = align_rshift;
807 explicit RdState(
unsigned char shift = 0,
size_t pos = 0)
808 : align_rshift(shift), rpos(pos) {}
828 void buffer_write(
const char* src,
size_t size,
bool swap);
837 void write_array(
const char* x,
size_t size,
ACE_CDR::ULong length);
843 void smemcpy(
char* to,
const char* from,
size_t n);
847 void swapcpy(
char* to,
const char* from,
size_t n);
850 size_t doread(
char* dest,
size_t size,
bool swap,
size_t offset);
853 size_t dowrite(
const char* dest,
size_t size,
bool swap,
size_t offset);
861 static unsigned char offset(
char* index,
size_t start,
size_t align);
900 template<
typename Type>
907 operator Type&()
const 915 template<
typename Type>
922 operator Type&()
const 934 template <
typename T,
typename >
939 operator T&()
const {
return *val_; }
943 template<
typename Type>
949 template<
typename Type,
typename Tag>
996 const Encoding& encoding,
size_t& size,
1000 const Encoding& encoding,
size_t& size,
1004 const Encoding& encoding,
size_t& size,
1008 const Encoding& encoding,
size_t& size,
1010 #if OPENDDS_HAS_EXPLICIT_INTS 1013 const Encoding& encoding,
size_t& size,
1017 const Encoding& encoding,
size_t& size,
1037 #if OPENDDS_HAS_EXPLICIT_INTS 1039 void primitive_serialized_size_uint8(
const Encoding& encoding,
size_t& size,
1042 void primitive_serialized_size_int8(
const Encoding& encoding,
size_t& size,
1052 const Encoding& encoding,
size_t& size,
size_t& running_size);
1056 const Encoding& encoding,
size_t& size,
size_t& running_size);
1063 #ifdef __ACE_INLINE__
const size_t boolean_cdr_size
#define ACE_BEGIN_VERSIONED_NAMESPACE_DECL
void swap(MessageBlock &lhs, MessageBlock &rhs)
size_t rpos() const
Examine the logical reading position of the stream.
const size_t int8_cdr_size
const LogLevel::Value value
const size_t uint64_cdr_size
bool swap_bytes_
Indicates whether bytes will be swapped for this stream.
OpenDDS_Dcps_Export void primitive_serialized_size_ulong(const Encoding &encoding, size_t &size, size_t count=1)
const size_t int64_cdr_size
size_t length(void) const
size_t wpos() const
Examine the logical writing position of the stream.
ToBoundedString(string_t &str, ACE_CDR::ULong bound)
ConstructionStatus construction_status_
The way to judge whether tryconstruct trim is able to be properly done.
Kind kind_
The first two bytes as a big endian integer.
#define OpenDDS_Dcps_Export
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
const ACE_CDR::ULong bound_
OpenDDS_Dcps_Export void serialized_size_delimiter(const Encoding &encoding, size_t &size)
Add delimiter to the size of a serialized size if the encoding has them.
OpenDDS_Dcps_Export void primitive_serialized_size_octet(const Encoding &encoding, size_t &size, size_t count=1)
#define OPENDDS_ASSERT(C)
const size_t float64_cdr_size
String endianness_to_string(Endianness endianness)
RdState(unsigned char shift=0, size_t pos=0)
const size_t int16_cdr_size
void serialized_size(const Encoding &encoding, size_t &size, const SequenceNumber &)
const size_t uint32_cdr_size
char * rd_ptr(void) const
Encoding encoding_
Encoding Settings.
unsigned char align_rshift
ACE_CDR::UShort options_
The last two bytes as a big endian integer.
const size_t float32_cdr_size
bool skip_sequence_dheader_
#define OPENDDS_ALLOCATOR(T)
NestedKeyOnly(Type &value)
OpenDDS_Dcps_Export void primitive_serialized_size_char(const Encoding &encoding, size_t &size, size_t count=1)
MessageBlockHelper(const T &seq)
Class to serialize and deserialize data for DDS.
ACE_CDR::Boolean operator<<(Serializer &serializer, CoherentChangeControl &value)
Marshal/Insertion into a buffer.
const size_t xcdr1_pid_alignment
OpenDDS_Dcps_Export void primitive_serialized_size_wchar(const Encoding &encoding, size_t &size, size_t count=1)
unsigned char align_wshift_
const size_t char8_cdr_size
FromBoundedString(const string_t &str, ACE_CDR::ULong bound)
size_t wpos_
Logical writing position of the stream.
ACE_Message_Block * current() const
virtual ~ScopedAlignmentContext()
ACE_Message_Block * cont(void) const
#define ACE_END_VERSIONED_NAMESPACE_DECL
const size_t uint8_cdr_size
MessageBlockHelper(T &seq)
OpenDDS_Dcps_Export void align(size_t &value, size_t by)
Align "value" by "by" if it's not already.
const size_t int32_cdr_size
bool good_bit_
Indicates the current state of the stream abstraction.
OpenDDS_Dcps_Export void serialized_size_parameter_id(const Encoding &encoding, size_t &size, size_t &running_size)
std::basic_string< CharT, std::char_traits< CharT >, OPENDDS_ALLOCATOR(CharT) > string_t
const size_t char16_cdr_size
const ACE_CDR::ULong bound_
#define OPENDDS_END_VERSIONED_NAMESPACE_DECL
ACE_Message_Block * current_
Currently active message block in chain.
bool peek_helper(ACE_Message_Block *const block, size_t bytes, T &t)
ACE_CDR::Boolean operator>>(Serializer &serializer, CoherentChangeControl &value)
const size_t uint16_cdr_size
const char * to_string(MessageId value)
unsigned char align_rshift_
const char * pos_rd() const
const DCPS::Encoding encoding(DCPS::Encoding::KIND_UNALIGNED_CDR, DCPS::ENDIAN_BIG)
const size_t byte_cdr_size
size_t rpos_
Logical reading position of the stream.
The Internal API and Implementation of OpenDDS.
std::basic_string< CharT, std::char_traits< CharT >, OPENDDS_ALLOCATOR(CharT) > string_t
OpenDDS_Dcps_Export void serialized_size_list_end_parameter_id(const Encoding &encoding, size_t &size, size_t &running_size)
const char * ext_to_string(Extensibility ext)
OpenDDS_Dcps_Export void primitive_serialized_size_boolean(const Encoding &encoding, size_t &size, size_t count=1)
const char * pos_wr() const
const size_t float128_cdr_size
extensibility(MUTABLE) struct TypeLookup_getTypes_In
XcdrVersion xcdr_version_
Maximum alignment that could be used.
OpenDDS_Dcps_Export bool primitive_serialized_size(const Encoding &encoding, size_t &size, const ACE_CDR::Short &value, size_t count=1)