7#if !defined(ASYNC_MQTT_PACKET_WILL_HPP)
8#define ASYNC_MQTT_PACKET_WILL_HPP
10#include <async_mqtt/util/buffer.hpp>
11#include <async_mqtt/packet/pubopts.hpp>
12#include <async_mqtt/packet/property_variant.hpp>
13#include <async_mqtt/util/json_like_out.hpp>
44 typename StringViewLikeTopic,
45 typename StringViewLikeMessage,
47 std::is_convertible_v<std::decay_t<StringViewLikeTopic>, std::string_view> &&
48 std::is_convertible_v<std::decay_t<StringViewLikeMessage>, std::string_view>,
53 StringViewLikeTopic&&
topic,
54 StringViewLikeMessage&&
message,
58 topic_{std::
string{std::forward<StringViewLikeTopic>(
topic)}},
59 message_{std::
string{std::forward<StringViewLikeMessage>(
message)}},
61 props_(force_move(
props))
69 return std::string{topic_};
93 return std::string{message_};
153 std::tie(lhs.topic_, lhs.message_, lhs.pubopts_, lhs.props_) ==
154 std::tie(rhs.topic_, rhs.message_, rhs.pubopts_, rhs.props_);
166 std::tie(lhs.topic_, lhs.message_, lhs.pubopts_, lhs.props_) <
167 std::tie(rhs.topic_, rhs.message_, rhs.pubopts_, rhs.props_);
190inline std::ostream&
operator<<(std::ostream& o, will
const& v) {
192 "topic:" << v.topic_as_buffer() <<
"," <<
193 "message:" << json_like_out(v.message_as_buffer()) <<
"," <<
194 "qos:" << v.get_qos() <<
"," <<
195 "retain:" << v.get_retain();
196 if (!v.props().empty()) {
197 o <<
",ps:" << v.props();
buffer that has string_view interface and shared ownership This class is only for advanced usecase su...
Definition buffer.hpp:46
MQTT will message.
Definition will.hpp:30
buffer & topic_as_buffer()
Get topic as a buffer.
Definition will.hpp:84
buffer const & topic_as_buffer() const
Get topic as a buffer.
Definition will.hpp:76
std::string topic() const
Get topic.
Definition will.hpp:68
will(StringViewLikeTopic &&topic, StringViewLikeMessage &&message, pub::opts pubopts={}, properties props={})
constructor
Definition will.hpp:52
friend bool operator<(will const &lhs, will const &rhs)
less than operator
Definition will.hpp:164
constexpr qos get_qos() const
Get QoS.
Definition will.hpp:124
buffer const & message_as_buffer() const
Get message as a buffer.
Definition will.hpp:100
constexpr properties & props()
Get properties.
Definition will.hpp:140
std::string message() const
Get message.
Definition will.hpp:92
friend bool operator==(will const &lhs, will const &rhs)
equal operator
Definition will.hpp:151
constexpr properties const & props() const
Get properties.
Definition will.hpp:132
constexpr pub::retain get_retain() const
Get retain.
Definition will.hpp:116
buffer & message_as_buffer()
Get message as a buffer.
Definition will.hpp:108
std::ostream & operator<<(std::ostream &o, mqtt_error v)
output to the stream
std::vector< property_variant > properties
property variant collection type
Definition property_variant.hpp:224
retain
MQTT RETAIN.
Definition pubopts.hpp:100
qos
MQTT QoS.
Definition qos.hpp:35
MQTT PublishOptions.
Definition pubopts.hpp:136
constexpr retain get_retain() const
Get retain.
Definition pubopts.hpp:232
constexpr qos get_qos() const
Get qos.
Definition pubopts.hpp:248