SNode.C
Loading...
Searching...
No Matches
iot::mqtt::FixedHeader Class Reference

#include <FixedHeader.h>

Collaboration diagram for iot::mqtt::FixedHeader:

Public Member Functions

 FixedHeader ()
 
 FixedHeader (uint8_t type, uint8_t flags, uint32_t remainingLength=0)
 
 ~FixedHeader ()
 
std::size_t deserialize (iot::mqtt::MqttContext *mqttContext)
 
std::vector< char > serialize () const
 
uint8_t getType () const
 
uint8_t getFlags () const
 
void setRemainingLength (uint32_t remainingLength)
 
uint32_t getRemainingLength () const
 
bool isComplete () const
 
bool isError () const
 
void reset ()
 

Private Attributes

types::UInt8 typeFlags
 
types::UIntV remainingLength
 
bool complete = false
 
bool error = false
 
int state = 0
 

Detailed Description

Definition at line 62 of file FixedHeader.h.

Constructor & Destructor Documentation

◆ FixedHeader() [1/2]

iot::mqtt::FixedHeader::FixedHeader ( )

Definition at line 50 of file FixedHeader.cpp.

50 {
51 }

◆ FixedHeader() [2/2]

iot::mqtt::FixedHeader::FixedHeader ( uint8_t  type,
uint8_t  flags,
uint32_t  remainingLength = 0 
)

Definition at line 53 of file FixedHeader.cpp.

53 {
54 this->typeFlags = static_cast<uint8_t>((type << 4) | (flags & 0x0F));
56 }
types::UInt8 typeFlags
Definition FixedHeader.h:84
types::UIntV remainingLength
Definition FixedHeader.h:85

References iot::mqtt::types::UIntV::operator=(), iot::mqtt::types::UInt8::operator=(), remainingLength, and typeFlags.

Referenced by iot::mqtt::ControlPacket::serialize().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ~FixedHeader()

iot::mqtt::FixedHeader::~FixedHeader ( )

Definition at line 58 of file FixedHeader.cpp.

58 {
59 }

Member Function Documentation

◆ deserialize()

std::size_t iot::mqtt::FixedHeader::deserialize ( iot::mqtt::MqttContext mqttContext)

Definition at line 61 of file FixedHeader.cpp.

61 {
62 std::size_t consumed = 0;
63
64 switch (state) {
65 case 0:
66 consumed += typeFlags.deserialize(mqttContext);
67
68 if (!typeFlags.isComplete()) {
69 break;
70 }
71 state++;
72 [[fallthrough]];
73 case 1:
74 consumed += remainingLength.deserialize(mqttContext);
75
78
79 break;
80 }
81
82 return consumed;
83 }
virtual std::size_t deserialize(iot::mqtt::MqttContext *mqttContext)
Definition TypeBase.hpp:59
std::size_t deserialize(iot::mqtt::MqttContext *mqttContext) override
Definition UIntV.cpp:62
bool isError() const
Definition UIntV.cpp:112

References complete, iot::mqtt::types::TypeBase< ValueTypeT >::deserialize(), iot::mqtt::types::UIntV::deserialize(), error, iot::mqtt::types::TypeBase< ValueTypeT >::isComplete(), iot::mqtt::types::UIntV::isError(), remainingLength, state, and typeFlags.

Referenced by iot::mqtt::Mqtt::onReceivedFromPeer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getFlags()

uint8_t iot::mqtt::FixedHeader::getFlags ( ) const

Definition at line 89 of file FixedHeader.cpp.

89 {
90 return static_cast<uint8_t>(typeFlags & 0x0F);
91 }

References typeFlags.

Referenced by iot::mqtt::client::Mqtt::createControlPacketDeserializer(), iot::mqtt::server::Mqtt::createControlPacketDeserializer(), and iot::mqtt::Mqtt::printFixedHeader().

Here is the caller graph for this function:

◆ getRemainingLength()

uint32_t iot::mqtt::FixedHeader::getRemainingLength ( ) const

Definition at line 97 of file FixedHeader.cpp.

97 {
98 return remainingLength;
99 }

References remainingLength.

Referenced by iot::mqtt::client::Mqtt::createControlPacketDeserializer(), iot::mqtt::server::Mqtt::createControlPacketDeserializer(), and iot::mqtt::Mqtt::printFixedHeader().

Here is the caller graph for this function:

◆ getType()

uint8_t iot::mqtt::FixedHeader::getType ( ) const

Definition at line 85 of file FixedHeader.cpp.

85 {
86 return static_cast<uint8_t>(typeFlags >> 0x04);
87 }

References typeFlags.

Referenced by iot::mqtt::client::Mqtt::createControlPacketDeserializer(), iot::mqtt::server::Mqtt::createControlPacketDeserializer(), and iot::mqtt::Mqtt::printFixedHeader().

Here is the caller graph for this function:

◆ isComplete()

bool iot::mqtt::FixedHeader::isComplete ( ) const

Definition at line 101 of file FixedHeader.cpp.

101 {
102 return complete;
103 }

References complete.

◆ isError()

bool iot::mqtt::FixedHeader::isError ( ) const

Definition at line 105 of file FixedHeader.cpp.

105 {
106 return error;
107 }

References error.

◆ reset()

void iot::mqtt::FixedHeader::reset ( )

Definition at line 118 of file FixedHeader.cpp.

118 {
121
122 complete = false;
123 error = false;
124
125 state = 0;
126 }
virtual void reset(std::size_t size=sizeof(ValueType))
Definition TypeBase.hpp:93
void reset(std::size_t size=sizeof(ValueType)) override
Definition UIntV.cpp:116

References complete, error, remainingLength, iot::mqtt::types::TypeBase< ValueTypeT >::reset(), iot::mqtt::types::UIntV::reset(), state, and typeFlags.

Here is the call graph for this function:

◆ serialize()

std::vector< char > iot::mqtt::FixedHeader::serialize ( ) const

Definition at line 109 of file FixedHeader.cpp.

109 {
110 std::vector<char> packet = typeFlags.serialize();
111
112 std::vector<char> tmpVector = remainingLength.serialize();
113 packet.insert(packet.end(), tmpVector.begin(), tmpVector.end());
114
115 return packet;
116 }
virtual std::vector< char > serialize() const
Definition TypeBase.hpp:83

References remainingLength, iot::mqtt::types::TypeBase< ValueTypeT >::serialize(), and typeFlags.

Referenced by iot::mqtt::Mqtt::printFixedHeader(), and iot::mqtt::ControlPacket::serialize().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setRemainingLength()

void iot::mqtt::FixedHeader::setRemainingLength ( uint32_t  remainingLength)

Definition at line 93 of file FixedHeader.cpp.

93 {
95 }

References iot::mqtt::types::UIntV::operator=(), and remainingLength.

Here is the call graph for this function:

Member Data Documentation

◆ complete

bool iot::mqtt::FixedHeader::complete = false
private

Definition at line 87 of file FixedHeader.h.

Referenced by deserialize(), isComplete(), and reset().

◆ error

bool iot::mqtt::FixedHeader::error = false
private

Definition at line 88 of file FixedHeader.h.

Referenced by deserialize(), isError(), and reset().

◆ remainingLength

types::UIntV iot::mqtt::FixedHeader::remainingLength
private

◆ state

int iot::mqtt::FixedHeader::state = 0
private

Definition at line 90 of file FixedHeader.h.

Referenced by deserialize(), and reset().

◆ typeFlags

types::UInt8 iot::mqtt::FixedHeader::typeFlags
private

Definition at line 84 of file FixedHeader.h.

Referenced by deserialize(), FixedHeader(), getFlags(), getType(), reset(), and serialize().


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