async_mqtt 5.0.0
Loading...
Searching...
No Matches
qos.hpp
Go to the documentation of this file.
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
14
15namespace async_mqtt {
16
22enum class qos : std::uint8_t
23{
24 at_most_once = 0b00000000,
25 at_least_once = 0b00000001,
26 exactly_once = 0b00000010,
27};
28
32constexpr char const* qos_to_str(qos v) {
33 switch(v) {
34 case qos::at_most_once: return "at_most_once";
35 case qos::at_least_once: return "at_least_once";
36 case qos::exactly_once: return "exactly_once";
37 default: return "invalid_qos";
38 }
39}
40
44inline
45std::ostream& operator<<(std::ostream& os, qos val)
46{
47 os << qos_to_str(val);
48 return os;
49}
50
51} // namespace async_mqtt
52
53#endif // ASYNC_MQTT_PACKET_QOS_HPP
Definition packet_variant.hpp:49
qos
MQTT QoS.
Definition qos.hpp:23
@ exactly_once
Exactly once delivery.
@ at_most_once
At most once delivery.
@ at_least_once
At least once delivery.
constexpr char const * qos_to_str(qos v)
stringize qos
Definition qos.hpp:32