async_mqtt 9.0.1
Loading...
Searching...
No Matches
qos.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_QOS_HPP)
8#define ASYNC_MQTT_PACKET_QOS_HPP
9
10#include <cstdint>
11#include <ostream>
12
21namespace async_mqtt {
22
34enum class qos : std::uint8_t
35{
36 at_most_once = 0b00000000,
37 at_least_once = 0b00000001,
38 exactly_once = 0b00000010,
39};
40
52constexpr char const* qos_to_str(qos v) {
53 switch(v) {
54 case qos::at_most_once: return "at_most_once";
55 case qos::at_least_once: return "at_least_once";
56 case qos::exactly_once: return "exactly_once";
57 default: return "invalid_qos";
58 }
59}
60
73inline
74std::ostream& operator<<(std::ostream& o, qos v)
75{
76 o << qos_to_str(v);
77 return o;
78}
79
80} // namespace async_mqtt
81
82#endif // ASYNC_MQTT_PACKET_QOS_HPP
std::ostream & operator<<(std::ostream &o, mqtt_error v)
output to the stream
qos
MQTT QoS.
Definition qos.hpp:35
constexpr char const * qos_to_str(qos v)
stringize qos
Definition qos.hpp:52
@ exactly_once
Exactly once delivery.
@ at_most_once
At most once delivery.
@ at_least_once
At least once delivery.