OpenDDS  Snapshot(2023/04/28-20:55)
MessageParser.cpp
Go to the documentation of this file.
1 /*
2  * Distributed under the OpenDDS License.
3  * See: http://www.opendds.org/license.html
4  */
5 
6 #include "MessageParser.h"
7 
9 
10 namespace OpenDDS {
11 namespace RTPS {
12 
13 using DCPS::Encoding;
14 
15 namespace {
16  const Encoding encoding_plain_native(Encoding::KIND_XCDR1);
17 }
18 
20  : in_(in.duplicate())
21  , ser_(in_.get(), encoding_plain_native)
22  , header_()
23  , sub_()
24  , smContentStart_(0)
25 {}
26 
28  : fromSeq_(reinterpret_cast<const char*>(in.get_buffer()), in.length())
29  , ser_(&fromSeq_, encoding_plain_native)
30  , header_()
31  , sub_()
32  , smContentStart_(0)
33 {
35 }
36 
38 {
39  return ser_ >> header_;
40 }
41 
43 {
46  return false;
47  }
48 
50  if(!(ser_ >> sub_.submessageLength)) {
51  return false;
52  }
54  return sub_.submessageLength <= ser_.length();
55 }
56 
58 {
59  if(sub_.submessageLength == 0) {
61  return false;
62  }
63  return ser_.length();
64  }
66 }
67 
69 {
70  const size_t read = smContentStart_ - ser_.length();
71  return ser_.skip(static_cast<unsigned short>(sub_.submessageLength - read));
72 }
73 
75 {
77  const size_t read = smContentStart_ - ser_.length();
78  return ser_.skip(static_cast<unsigned short>(sub_.submessageLength - read));
79  } else if (sub_.submessageId == PAD || sub_.submessageId == INFO_TS) {
80  return true;
81  } else {
82  return ser_.skip(static_cast<unsigned short>(ser_.length()));
83  }
84 }
85 
86 }
87 }
88 
MessageParser(const ACE_Message_Block &in)
const octet FLAG_E
Definition: RtpsCore.idl:521
bool skip(size_t n, int size=1)
Definition: Serializer.inl:443
#define ACE_CDR_BYTE_ORDER
ACE_Message_Block fromSeq_
Definition: MessageParser.h:44
size_t length() const
Number of bytes left to read in message block chain.
Definition: Serializer.inl:437
size_t size(void) const
ssize_t read(ACE_HANDLE handle, void *buf, size_t len)
char * wr_ptr(void) const
sequence< octet > OctetSeq
Definition: DdsDcpsCore.idl:64
void swap_bytes(bool do_swap)
Definition: Serializer.inl:403
#define OPENDDS_END_VERSIONED_NAMESPACE_DECL
The Internal API and Implementation of OpenDDS.
Definition: AddressCache.h:28