SNode.C
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages Concepts
iot::mqtt_fast::ControlPacket Class Reference

#include <ControlPacket.h>

Inheritance diagram for iot::mqtt_fast::ControlPacket:
Collaboration diagram for iot::mqtt_fast::ControlPacket:

Public Member Functions

 ControlPacket (uint8_t type, uint8_t reserved=0)
 
 ControlPacket (iot::mqtt_fast::ControlPacketFactory &controlPacketFactory)
 
 ControlPacket (const ControlPacket &)=delete
 
 ControlPacket (ControlPacket &&)=delete
 
ControlPacketoperator= (const ControlPacket &)=delete
 
ControlPacketoperator= (ControlPacket &&)=delete
 
uint8_t getType () const
 
uint8_t getReserved () const
 
uint64_t getRemainingLength () const
 
std::vector< char > getPacket ()
 
bool isError () const
 

Protected Member Functions

std::vector< char > & getValue ()
 
uint8_t getInt8 ()
 
uint16_t getInt16 ()
 
uint32_t getInt32 ()
 
uint64_t getInt64 ()
 
uint32_t getIntV ()
 
std::string getString ()
 
std::string getStringRaw ()
 
std::list< uint8_t > getUint8ListRaw ()
 
void putInt8 (uint8_t value)
 
void putInt16 (uint16_t value)
 
void putInt32 (uint32_t value)
 
void putInt64 (uint64_t value)
 
void putIntV (uint32_t value)
 
void putString (const std::string &value)
 
void putStringRaw (const std::string &value)
 
void putUint8ListRaw (const std::list< uint8_t > &value)
 
bool isError ()
 

Protected Attributes

bool error = false
 

Private Attributes

uint8_t type
 
uint8_t reserved
 
iot::mqtt_fast::types::Binary data
 

Detailed Description

Definition at line 62 of file ControlPacket.h.

Constructor & Destructor Documentation

◆ ControlPacket() [1/4]

◆ ControlPacket() [2/4]

iot::mqtt_fast::ControlPacket::ControlPacket ( iot::mqtt_fast::ControlPacketFactory & controlPacketFactory)
explicit

Definition at line 59 of file ControlPacket.cpp.

60 : type(controlPacketFactory.getPacketType())
61 , reserved(controlPacketFactory.getPacketFlags())
62 , data(std::move(controlPacketFactory.getPacket())) {
63 }
iot::mqtt_fast::types::Binary & getPacket()
iot::mqtt_fast::types::Binary data

References ControlPacket(), iot::mqtt_fast::ControlPacketFactory::getPacketFlags(), iot::mqtt_fast::ControlPacketFactory::getPacketType(), reserved, and type.

Referenced by iot::mqtt_fast::packets::Connack::Connack(), iot::mqtt_fast::packets::Connect::Connect(), ControlPacket(), iot::mqtt_fast::packets::Disconnect::Disconnect(), iot::mqtt_fast::packets::Pingreq::Pingreq(), iot::mqtt_fast::packets::Pingresp::Pingresp(), iot::mqtt_fast::packets::Puback::Puback(), iot::mqtt_fast::packets::Pubcomp::Pubcomp(), iot::mqtt_fast::packets::Publish::Publish(), iot::mqtt_fast::packets::Pubrec::Pubrec(), iot::mqtt_fast::packets::Pubrel::Pubrel(), iot::mqtt_fast::packets::Suback::Suback(), iot::mqtt_fast::packets::Subscribe::Subscribe(), iot::mqtt_fast::packets::Unsuback::Unsuback(), and iot::mqtt_fast::packets::Unsubscribe::Unsubscribe().

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

◆ ControlPacket() [3/4]

iot::mqtt_fast::ControlPacket::ControlPacket ( const ControlPacket & )
delete

◆ ControlPacket() [4/4]

iot::mqtt_fast::ControlPacket::ControlPacket ( ControlPacket && )
delete

Member Function Documentation

◆ getInt16()

◆ getInt32()

uint32_t iot::mqtt_fast::ControlPacket::getInt32 ( )
protected

Definition at line 113 of file ControlPacket.cpp.

113 {
114 return data.getInt32();
115 }

◆ getInt64()

uint64_t iot::mqtt_fast::ControlPacket::getInt64 ( )
protected

Definition at line 117 of file ControlPacket.cpp.

117 {
118 return data.getInt64();
119 }

◆ getInt8()

uint8_t iot::mqtt_fast::ControlPacket::getInt8 ( )
protected

Definition at line 105 of file ControlPacket.cpp.

105 {
106 return data.getInt8();
107 }

Referenced by iot::mqtt_fast::packets::Connack::Connack(), iot::mqtt_fast::packets::Connect::Connect(), and iot::mqtt_fast::packets::Subscribe::Subscribe().

Here is the caller graph for this function:

◆ getIntV()

uint32_t iot::mqtt_fast::ControlPacket::getIntV ( )
protected

Definition at line 121 of file ControlPacket.cpp.

121 {
122 return data.getIntV();
123 }

◆ getPacket()

std::vector< char > iot::mqtt_fast::ControlPacket::getPacket ( )

Definition at line 77 of file ControlPacket.cpp.

77 {
78 std::vector<char> packet;
79
80 packet.push_back(static_cast<char>((type << 0x04) | (reserved & 0x0F)));
81
82 uint64_t remainingLength = data.getLength();
83 do {
84 uint8_t encodedByte = static_cast<uint8_t>(remainingLength % 0x80);
85 remainingLength /= 0x80;
86 if (remainingLength > 0) {
87 encodedByte |= 0x80;
88 }
89 packet.push_back(static_cast<char>(encodedByte));
90 } while (remainingLength > 0);
91
92 packet.insert(packet.end(), data.getValue().begin(), data.getValue().end());
93
94 return packet;
95 }
std::vector< char > & getValue()
Definition Binary.cpp:76
std::vector< char >::size_type getLength() const
Definition Binary.cpp:62

◆ getRemainingLength()

uint64_t iot::mqtt_fast::ControlPacket::getRemainingLength ( ) const

Definition at line 73 of file ControlPacket.cpp.

73 {
74 return data.getLength();
75 }

◆ getReserved()

uint8_t iot::mqtt_fast::ControlPacket::getReserved ( ) const

Definition at line 69 of file ControlPacket.cpp.

69 {
70 return reserved;
71 }

References reserved.

◆ getString()

std::string iot::mqtt_fast::ControlPacket::getString ( )
protected

Definition at line 125 of file ControlPacket.cpp.

125 {
126 return data.getString();
127 }

Referenced by iot::mqtt_fast::packets::Connect::Connect(), iot::mqtt_fast::packets::Publish::Publish(), iot::mqtt_fast::packets::Subscribe::Subscribe(), and iot::mqtt_fast::packets::Unsubscribe::Unsubscribe().

Here is the caller graph for this function:

◆ getStringRaw()

std::string iot::mqtt_fast::ControlPacket::getStringRaw ( )
protected

Definition at line 129 of file ControlPacket.cpp.

129 {
130 return data.getStringRaw();
131 }

Referenced by iot::mqtt_fast::packets::Publish::Publish().

Here is the caller graph for this function:

◆ getType()

uint8_t iot::mqtt_fast::ControlPacket::getType ( ) const

Definition at line 65 of file ControlPacket.cpp.

65 {
66 return type;
67 }

References type.

◆ getUint8ListRaw()

std::list< uint8_t > iot::mqtt_fast::ControlPacket::getUint8ListRaw ( )
protected

Definition at line 133 of file ControlPacket.cpp.

133 {
134 return data.getUint8ListRaw();
135 }
std::list< uint8_t > getUint8ListRaw()
Definition Binary.cpp:194

◆ getValue()

std::vector< char > & iot::mqtt_fast::ControlPacket::getValue ( )
protected

Definition at line 101 of file ControlPacket.cpp.

101 {
102 return data.getValue();
103 }

◆ isError() [1/2]

bool iot::mqtt_fast::ControlPacket::isError ( )
protected

Definition at line 169 of file ControlPacket.cpp.

169 {
170 return data.isError();
171 }

◆ isError() [2/2]

bool iot::mqtt_fast::ControlPacket::isError ( ) const

Definition at line 97 of file ControlPacket.cpp.

97 {
98 return error;
99 }

References error.

◆ operator=() [1/2]

ControlPacket & iot::mqtt_fast::ControlPacket::operator= ( const ControlPacket & )
delete

◆ operator=() [2/2]

ControlPacket & iot::mqtt_fast::ControlPacket::operator= ( ControlPacket && )
delete

◆ putInt16()

void iot::mqtt_fast::ControlPacket::putInt16 ( uint16_t value)
protected

◆ putInt32()

void iot::mqtt_fast::ControlPacket::putInt32 ( uint32_t value)
protected

Definition at line 145 of file ControlPacket.cpp.

145 {
146 data.putInt32(value);
147 }
void putInt32(uint32_t value)
Definition Binary.cpp:221

◆ putInt64()

void iot::mqtt_fast::ControlPacket::putInt64 ( uint64_t value)
protected

Definition at line 149 of file ControlPacket.cpp.

149 {
150 data.putInt64(value);
151 }
void putInt64(uint64_t value)
Definition Binary.cpp:230

◆ putInt8()

void iot::mqtt_fast::ControlPacket::putInt8 ( uint8_t value)
protected

Definition at line 137 of file ControlPacket.cpp.

137 {
138 data.putInt8(value);
139 }
void putInt8(uint8_t value)
Definition Binary.cpp:208

Referenced by iot::mqtt_fast::packets::Connack::Connack(), and iot::mqtt_fast::packets::Connect::Connect().

Here is the caller graph for this function:

◆ putIntV()

void iot::mqtt_fast::ControlPacket::putIntV ( uint32_t value)
protected

Definition at line 153 of file ControlPacket.cpp.

153 {
154 data.putIntV(value);
155 }
void putIntV(uint32_t value)
Definition Binary.cpp:243

◆ putString()

void iot::mqtt_fast::ControlPacket::putString ( const std::string & value)
protected

Definition at line 157 of file ControlPacket.cpp.

157 {
158 data.putString(value);
159 }
void putString(const std::string &string)
Definition Binary.cpp:256

Referenced by iot::mqtt_fast::packets::Connect::Connect(), and iot::mqtt_fast::packets::Publish::Publish().

Here is the caller graph for this function:

◆ putStringRaw()

void iot::mqtt_fast::ControlPacket::putStringRaw ( const std::string & value)
protected

Definition at line 161 of file ControlPacket.cpp.

161 {
162 data.putStringRaw(value);
163 }
void putStringRaw(const std::string &string)
Definition Binary.cpp:263

Referenced by iot::mqtt_fast::packets::Publish::Publish().

Here is the caller graph for this function:

◆ putUint8ListRaw()

void iot::mqtt_fast::ControlPacket::putUint8ListRaw ( const std::list< uint8_t > & value)
protected

Definition at line 165 of file ControlPacket.cpp.

165 {
166 data.putUint8ListRaw(value);
167 }
void putUint8ListRaw(const std::list< uint8_t > &values)
Definition Binary.cpp:269

Member Data Documentation

◆ data

iot::mqtt_fast::types::Binary iot::mqtt_fast::ControlPacket::data
private

Definition at line 107 of file ControlPacket.h.

◆ error

◆ reserved

uint8_t iot::mqtt_fast::ControlPacket::reserved
private

Definition at line 105 of file ControlPacket.h.

Referenced by ControlPacket(), ControlPacket(), and getReserved().

◆ type

uint8_t iot::mqtt_fast::ControlPacket::type
private

Definition at line 104 of file ControlPacket.h.

Referenced by ControlPacket(), ControlPacket(), and getType().


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