async_mqtt 9.0.1
Loading...
Searching...
No Matches
property_variant.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_PROPERTY_VARIANT_HPP)
8#define ASYNC_MQTT_PACKET_PROPERTY_VARIANT_HPP
9
10#include <variant>
11
12#include <async_mqtt/util/overload.hpp>
13#include <async_mqtt/packet/property.hpp>
14
15namespace async_mqtt {
16
33bool operator==(property_variant const& lhs, property_variant const& rhs);
34
46bool operator<(property_variant const& lhs, property_variant const& rhs);
47
48/*
49 * @brief output to the stream
50 * @param os output stream
51 * @param v target
52 * @return output stream
53 *
54 * #### Requirements
55 * - Header: async_mqtt/packet/property_variant.hpp
56 * - Convenience header: async_mqtt/all.hpp
57 *
58 */
59std::ostream& operator<<(std::ostream& o, property_variant const& v);
60
61
75public:
76
81 template <
82 typename Property,
83 std::enable_if_t<
84 !std::is_same_v<std::decay_t<Property>, property_variant>,
85 std::nullptr_t
86 >* = nullptr
87 >
88 property_variant(Property&& property);
89
94 explicit property_variant() = default;
95
100 template <typename Func>
101 auto visit(Func&& func) const&;
102
107 template <typename Func>
108 auto visit(Func&& func) &;
109
114 template <typename Func>
115 auto visit(Func&& func) &&;
116
122
127 std::size_t num_of_const_buffer_sequence() const;
128
134 std::vector<as::const_buffer> const_buffer_sequence() const;
135
140 std::size_t size() const;
141
146 template <typename T>
147 decltype(auto) get();
148
153 template <typename T>
154 decltype(auto) get() const;
155
160 template <typename T>
161 decltype(auto) get_if();
162
167 template <typename T>
168 decltype(auto) get_if() const;
169
174 operator bool();
175
176 friend bool operator==(property_variant const& lhs, property_variant const& rhs);
177 friend bool operator<(property_variant const& lhs, property_variant const& rhs);
178 friend std::ostream& operator<<(std::ostream& o, property_variant const& v);
179
180private:
181 using variant_t = std::variant<
182 std::monostate,
210 >;
211
212 variant_t var_;
213};
214
224using properties = std::vector<property_variant>;
225
226/*
227 * @ingroup property
228 * @brief output to the stream
229 * @param os output stream
230 * @param v target
231 * @return output stream
232 *
233 * #### Requirements
234 * - Header: async_mqtt/packet/property_variant.hpp
235 * - Convenience header: async_mqtt/all.hpp
236 *
237 */
238std::ostream& operator<<(std::ostream& o, properties const& props);
239
252bool operator<(property_variant const& lhs, property_variant const& rhs);
253
266bool operator==(property_variant const& lhs, property_variant const& rhs);
267
280std::ostream& operator<<(std::ostream& o, property_variant const& v);
281
282} // namespace async_mqtt
283
284#include <async_mqtt/packet/impl/property_variant.hpp>
285
286#endif // ASYNC_MQTT_PACKET_PROPERTY_VARIANT_HPP
shared_subscription_available property
Definition property.hpp:1581
property variant
Definition property_variant.hpp:74
decltype(auto) get()
Get by type. If not match, then throw std::bad_variant_access exception.
property_variant()=default
constructor property variant value is std::monostate
std::size_t size() const
Get packet size.
friend bool operator==(property_variant const &lhs, property_variant const &rhs)
equal operator
property::id id() const
Get property_id.
std::vector< as::const_buffer > const_buffer_sequence() const
Create const buffer sequence. it is for boost asio APIs.
decltype(auto) get_if() const
Get by type pointer.
property_variant(Property &&property)
constructor
decltype(auto) get_if()
Get by type pointer.
auto visit(Func &&func) &
visit to variant
decltype(auto) get() const
Get by type. If not match, then throw std::bad_variant_access exception.
std::size_t num_of_const_buffer_sequence() const
Get number of element of const_buffer_sequence.
auto visit(Func &&func) const &
visit to variant
friend bool operator<(property_variant const &lhs, property_variant const &rhs)
less than operator
auto visit(Func &&func) &&
visit to variant
std::ostream & operator<<(std::ostream &o, mqtt_error v)
output to the stream
id
MQTT property identifier.
Definition property_id.hpp:28
std::vector< property_variant > properties
property variant collection type
Definition property_variant.hpp:224
@ subscription_identifier
Subscription Identifier.
@ request_problem_information
Request Problem Information.
@ reason_string
Reason String.
@ server_reference
Server Reference.
@ maximum_qos
Maximum QoS.
@ response_topic
Response Topic.
@ retain_available
Retain Available.
@ message_expiry_interval
Message Expiry Interval.
@ request_response_information
Request Response Information.
@ authentication_data
Authentication Data.
@ session_expiry_interval
Session Expiry Interval.
@ receive_maximum
Receive Maximum.
@ assigned_client_identifier
Assigned Client Identifier.
@ server_keep_alive
Server Keep Alive.
@ topic_alias
Topic Alias.
@ topic_alias_maximum
Topic Alias Maximum.
@ authentication_method
Authentication Method.
@ subscription_identifier_available
Subscription Identifier Available.
@ user_property
User Property.
@ payload_format_indicator
Payload Format Indicator.
@ will_delay_interval
Will Delay Interval.
@ wildcard_subscription_available
Wildcard Subscription Available.
@ maximum_packet_size
Maximum Packet Size.
@ content_type
Content Type.
@ correlation_data
Correlation Data.
@ response_information
Response Information.
bool operator==(property_variant const &lhs, property_variant const &rhs)
equal operator
bool operator<(property_variant const &lhs, property_variant const &rhs)
less than operator