async_mqtt 9.0.1
Loading...
Searching...
No Matches
v3_1_1_unsubscribe.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_V3_1_1_UNSUBSCRIBE_HPP)
8#define ASYNC_MQTT_PACKET_V3_1_1_UNSUBSCRIBE_HPP
9
10
11#include <async_mqtt/buffer_to_packet_variant.hpp>
12
13#include <async_mqtt/util/buffer.hpp>
14#include <async_mqtt/util/static_vector.hpp>
15#include <async_mqtt/util/variable_bytes.hpp>
16
17#include <async_mqtt/packet/control_packet_type.hpp>
18#include <async_mqtt/packet/packet_id_type.hpp>
19#include <async_mqtt/packet/topic_sharename.hpp>
20
31namespace async_mqtt::v3_1_1 {
32
33namespace as = boost::asio;
34
52template <std::size_t PacketIdBytes>
54public:
55
64 std::vector<topic_sharename> params
65 );
66
71 static constexpr control_packet_type type() {
73 }
74
80 std::vector<as::const_buffer> const_buffer_sequence() const;
81
86 std::size_t size() const;
87
92 std::size_t num_of_const_buffer_sequence() const;
93
99
104 std::vector<topic_sharename> const& entries() const;
105
106private:
107
108 template <std::size_t PacketIdBytesArg>
111
112#if defined(ASYNC_MQTT_UNIT_TEST_FOR_PACKET)
113 friend struct ::ut_packet::v311_unsubscribe;
114 friend struct ::ut_packet::v311_unsubscribe_pid4;
115 friend struct ::ut_packet::v311_unsubscribe_error;
116#endif // defined(ASYNC_MQTT_UNIT_TEST_FOR_PACKET)
117
118 // private constructor for internal use
119 explicit basic_unsubscribe_packet(buffer buf, error_code& ec);
120
121private:
122 std::uint8_t fixed_header_;
123 std::vector<static_vector<char, 2>> topic_length_buf_entries_;
124 std::vector<topic_sharename> entries_;
125 static_vector<char, PacketIdBytes> packet_id_ = static_vector<char, PacketIdBytes>(PacketIdBytes);
126 std::size_t remaining_length_;
127 static_vector<char, 4> remaining_length_buf_;
128};
129
142template <std::size_t PacketIdBytes>
144
157template <std::size_t PacketIdBytes>
159
172template <std::size_t PacketIdBytes>
173std::ostream& operator<<(std::ostream& o, basic_unsubscribe_packet<PacketIdBytes> const& v);
174
186
187} // namespace async_mqtt::v3_1_1
188
189#if !defined(ASYNC_MQTT_SEPARATE_COMPILATION)
190#include <async_mqtt/packet/impl/v3_1_1_unsubscribe.ipp>
191#endif // !defined(ASYNC_MQTT_SEPARATE_COMPILATION)
192
193#endif // ASYNC_MQTT_PACKET_V3_1_1_UNSUBSCRIBE_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 UNSUBSCRIBE packet (v3.1.1)
Definition v3_1_1_unsubscribe.hpp:53
std::size_t num_of_const_buffer_sequence() const
Get number of element of const_buffer_sequence.
basic_packet_id_type< PacketIdBytes >::type packet_id() const
Get packet_id.
std::vector< as::const_buffer > const_buffer_sequence() const
Create const buffer sequence it is for boost asio APIs.
std::ostream & operator<<(std::ostream &o, basic_unsubscribe_packet< PacketIdBytes > const &v)
stream output operator
std::size_t size() const
Get packet size.
static constexpr control_packet_type type()
Get MQTT control packet type.
Definition v3_1_1_unsubscribe.hpp:71
bool operator==(basic_unsubscribe_packet< PacketIdBytes > const &lhs, basic_unsubscribe_packet< PacketIdBytes > const &rhs)
equal operator
std::vector< topic_sharename > const & entries() const
Get entries.
basic_unsubscribe_packet(typename basic_packet_id_type< PacketIdBytes >::type packet_id, std::vector< topic_sharename > params)
constructor
bool operator<(basic_unsubscribe_packet< PacketIdBytes > const &lhs, basic_unsubscribe_packet< PacketIdBytes > const &rhs)
less than operator
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
packet idenfitifer type class template
Definition packet_id_type.hpp:25