SNode.C
Loading...
Searching...
No Matches
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 40 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 37 of file ControlPacket.cpp.

38 : type(controlPacketFactory.getPacketType())
39 , reserved(controlPacketFactory.getPacketFlags())
40 , data(std::move(controlPacketFactory.getPacket())) {
41 }
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 91 of file ControlPacket.cpp.

91 {
92 return data.getInt32();
93 }

◆ getInt64()

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

Definition at line 95 of file ControlPacket.cpp.

95 {
96 return data.getInt64();
97 }

◆ getInt8()

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

Definition at line 83 of file ControlPacket.cpp.

83 {
84 return data.getInt8();
85 }

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 99 of file ControlPacket.cpp.

99 {
100 return data.getIntV();
101 }

◆ getPacket()

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

Definition at line 55 of file ControlPacket.cpp.

55 {
56 std::vector<char> packet;
57
58 packet.push_back(static_cast<char>((type << 0x04) | (reserved & 0x0F)));
59
60 uint64_t remainingLength = data.getLength();
61 do {
62 uint8_t encodedByte = static_cast<uint8_t>(remainingLength % 0x80);
63 remainingLength /= 0x80;
64 if (remainingLength > 0) {
65 encodedByte |= 0x80;
66 }
67 packet.push_back(static_cast<char>(encodedByte));
68 } while (remainingLength > 0);
69
70 packet.insert(packet.end(), data.getValue().begin(), data.getValue().end());
71
72 return packet;
73 }
std::vector< char > & getValue()
Definition Binary.cpp:54
std::vector< char >::size_type getLength() const
Definition Binary.cpp:40

◆ getRemainingLength()

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

Definition at line 51 of file ControlPacket.cpp.

51 {
52 return data.getLength();
53 }

◆ getReserved()

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

Definition at line 47 of file ControlPacket.cpp.

47 {
48 return reserved;
49 }

References reserved.

◆ getString()

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

Definition at line 103 of file ControlPacket.cpp.

103 {
104 return data.getString();
105 }

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 107 of file ControlPacket.cpp.

107 {
108 return data.getStringRaw();
109 }

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 43 of file ControlPacket.cpp.

43 {
44 return type;
45 }

References type.

◆ getUint8ListRaw()

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

Definition at line 111 of file ControlPacket.cpp.

111 {
112 return data.getUint8ListRaw();
113 }
std::list< uint8_t > getUint8ListRaw()
Definition Binary.cpp:172

◆ getValue()

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

Definition at line 79 of file ControlPacket.cpp.

79 {
80 return data.getValue();
81 }

◆ isError() [1/2]

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

Definition at line 147 of file ControlPacket.cpp.

147 {
148 return data.isError();
149 }

◆ isError() [2/2]

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

Definition at line 75 of file ControlPacket.cpp.

75 {
76 return error;
77 }

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 123 of file ControlPacket.cpp.

123 {
124 data.putInt32(value);
125 }
void putInt32(uint32_t value)
Definition Binary.cpp:199

◆ putInt64()

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

Definition at line 127 of file ControlPacket.cpp.

127 {
128 data.putInt64(value);
129 }
void putInt64(uint64_t value)
Definition Binary.cpp:208

◆ putInt8()

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

Definition at line 115 of file ControlPacket.cpp.

115 {
116 data.putInt8(value);
117 }
void putInt8(uint8_t value)
Definition Binary.cpp:186

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 131 of file ControlPacket.cpp.

131 {
132 data.putIntV(value);
133 }
void putIntV(uint32_t value)
Definition Binary.cpp:221

◆ putString()

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

Definition at line 135 of file ControlPacket.cpp.

135 {
136 data.putString(value);
137 }
void putString(const std::string &string)
Definition Binary.cpp:234

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 139 of file ControlPacket.cpp.

139 {
140 data.putStringRaw(value);
141 }
void putStringRaw(const std::string &string)
Definition Binary.cpp:241

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 143 of file ControlPacket.cpp.

143 {
144 data.putUint8ListRaw(value);
145 }
void putUint8ListRaw(const std::list< uint8_t > &values)
Definition Binary.cpp:247

Member Data Documentation

◆ data

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

Definition at line 85 of file ControlPacket.h.

◆ error

◆ reserved

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

Definition at line 83 of file ControlPacket.h.

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

◆ type

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

Definition at line 82 of file ControlPacket.h.

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


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