async_mqtt 9.0.1
Loading...
Searching...
No Matches
v5_suback.hpp
1// Copyright Takatoshi Kondo 2022
2//
3// Distributed under the Boost Software License, Version 1.0.
4// (See accompanying file LICENSE_1_0.txt or copy at
5// http://www.boost.org/LICENSE_1_0.txt)
6
7#if !defined(ASYNC_MQTT_PACKET_V5_SUBACK_HPP)
8#define ASYNC_MQTT_PACKET_V5_SUBACK_HPP
9
10#include <async_mqtt/buffer_to_packet_variant.hpp>
11#include <async_mqtt/error.hpp>
12
13#include <async_mqtt/packet/control_packet_type.hpp>
14#include <async_mqtt/packet/packet_id_type.hpp>
15#include <async_mqtt/packet/topic_subopts.hpp>
16#include <async_mqtt/packet/property_variant.hpp>
17
18#include <async_mqtt/util/buffer.hpp>
19#include <async_mqtt/util/static_vector.hpp>
20
31namespace async_mqtt::v5 {
32
33namespace as = boost::asio;
34
52template <std::size_t PacketIdBytes>
54public:
55
65 std::vector<suback_reason_code> params,
66 properties props = {}
67 );
68
73 static constexpr control_packet_type type() {
75 }
76
82 std::vector<as::const_buffer> const_buffer_sequence() const;
83
88 std::size_t size() const;
89
94 std::size_t num_of_const_buffer_sequence() const;
95
101
106 std::vector<suback_reason_code> const& entries() const;
107
112 properties const& props() const;
113
114private:
115
116 template <std::size_t PacketIdBytesArg>
119
120#if defined(ASYNC_MQTT_UNIT_TEST_FOR_PACKET)
121 friend struct ::ut_packet::v5_suback;
122 friend struct ::ut_packet::v5_suback_pid4;
123 friend struct ::ut_packet::v5_suback_error;
124#endif // defined(ASYNC_MQTT_UNIT_TEST_FOR_PACKET)
125
126 // private constructor for internal use
127 explicit basic_suback_packet(buffer buf, error_code& ec);
128
129private:
130 std::uint8_t fixed_header_;
131 std::vector<suback_reason_code> entries_;
132 static_vector<char, PacketIdBytes> packet_id_ = static_vector<char, PacketIdBytes>(PacketIdBytes);
133 std::size_t remaining_length_;
134 static_vector<char, 4> remaining_length_buf_;
135
136 std::size_t property_length_ = 0;
137 static_vector<char, 4> property_length_buf_;
138 properties props_;
139};
140
153template <std::size_t PacketIdBytes>
155
168template <std::size_t PacketIdBytes>
170
183template <std::size_t PacketIdBytes>
184std::ostream& operator<<(std::ostream& o, basic_suback_packet<PacketIdBytes> const& v);
185
197
198} // namespace async_mqtt::v5
199
200#if !defined(ASYNC_MQTT_SEPARATE_COMPILATION)
201#include <async_mqtt/packet/impl/v5_suback.ipp>
202#endif // !defined(ASYNC_MQTT_SEPARATE_COMPILATION)
203
204#endif // ASYNC_MQTT_PACKET_V5_SUBACK_HPP
The varaint type of all packets and system_error.
Definition packet_variant_fwd.hpp:37
buffer that has string_view interface and shared ownership This class is only for advanced usecase su...
Definition buffer.hpp:46
MQTT SUBACK packet (v5)
Definition v5_suback.hpp:53
bool operator<(basic_suback_packet< PacketIdBytes > const &lhs, basic_suback_packet< PacketIdBytes > const &rhs)
less than operator
static constexpr control_packet_type type()
Get MQTT control packet type.
Definition v5_suback.hpp:73
std::vector< as::const_buffer > const_buffer_sequence() const
Create const buffer sequence it is for boost asio APIs.
std::vector< suback_reason_code > const & entries() const
Get entries.
bool operator==(basic_suback_packet< PacketIdBytes > const &lhs, basic_suback_packet< PacketIdBytes > const &rhs)
equal operator
basic_suback_packet(typename basic_packet_id_type< PacketIdBytes >::type packet_id, std::vector< suback_reason_code > params, properties props={})
constructor
std::size_t size() const
Get packet size.
std::ostream & operator<<(std::ostream &o, basic_suback_packet< PacketIdBytes > const &v)
stream output operator
properties const & props() const
Get properties.
basic_packet_id_type< PacketIdBytes >::type packet_id() const
Get packet_id.
std::size_t num_of_const_buffer_sequence() const
Get number of element of const_buffer_sequence.
sys::error_code error_code
sys is a namespace alias of boost::sytem.
Definition error.hpp:56
protocol_version
MQTT protocol version.
Definition protocol_version.hpp:29
basic_packet_variant< PacketIdBytes > buffer_to_basic_packet_variant(buffer buf, protocol_version ver, error_code &ec)
create basic_packet_variant from the buffer
control_packet_type
MQTT control packet type.
Definition control_packet_type.hpp:26
std::vector< property_variant > properties
property variant collection type
Definition property_variant.hpp:224
packet idenfitifer type class template
Definition packet_id_type.hpp:25