Line data Source code
1 : /* 2 : * 3 : * 4 : * Distributed under the OpenDDS License. 5 : * See: http://www.opendds.org/license.html 6 : */ 7 : 8 : #ifndef OPENDDS_DCPS_RTPS_MESSAGEPARSER_H 9 : #define OPENDDS_DCPS_RTPS_MESSAGEPARSER_H 10 : 11 : #include "RtpsCoreTypeSupportImpl.h" 12 : 13 : 14 : OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL 15 : 16 : namespace OpenDDS { 17 : namespace RTPS { 18 : 19 : /// Utility for iterating through a contiguous buffer (either really contiguous 20 : /// or virtually contiguous using message block chaining) of RTPS Submessages 21 : /// optionally prefixed by the RTPS Header 22 : class OpenDDS_Rtps_Export MessageParser { 23 : public: 24 : explicit MessageParser(const ACE_Message_Block& in); 25 : explicit MessageParser(const DDS::OctetSeq& in); 26 : 27 : bool parseHeader(); 28 : bool parseSubmessageHeader(); 29 : bool hasNextSubmessage() const; 30 : bool skipToNextSubmessage(); 31 : bool skipSubmessageContent(); 32 : 33 : const Header& header() const { return header_; } 34 0 : SubmessageHeader submessageHeader() const { return sub_; } 35 0 : size_t remaining() const { return in_ ? in_->total_length() : fromSeq_.length(); } 36 0 : const char* current() const { return ser_.pos_rd(); } 37 : 38 0 : DCPS::Serializer& serializer() { return ser_; } 39 : 40 : template <typename T> 41 0 : bool operator>>(T& rhs) { return ser_ >> rhs; } 42 : 43 : private: 44 : ACE_Message_Block fromSeq_; 45 : DCPS::Message_Block_Ptr in_; 46 : DCPS::Serializer ser_; 47 : Header header_; 48 : SubmessageHeader sub_; 49 : size_t smContentStart_; 50 : }; 51 : 52 : } // namespace RTPS 53 : } // namespace OpenDDS 54 : 55 : OPENDDS_END_VERSIONED_NAMESPACE_DECL 56 : 57 : #endif /* OPENDDS_DCPS_RTPS_MESSAGEPARSER_H */