mqtt_cpp
protocol_version.hpp
Go to the documentation of this file.
1 // Copyright Takatoshi Kondo 2019
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(MQTT_PROTOCOL_VERSION_HPP)
8 #define MQTT_PROTOCOL_VERSION_HPP
9 
10 #include <cstdint>
11 #include <ostream>
12 
13 #include <mqtt/namespace.hpp>
14 
15 namespace MQTT_NS {
16 
17 enum class protocol_version {
18  undetermined = 0,
19  v3_1_1 = 4,
20  v5 = 5,
21 };
22 
23 constexpr char const* protocol_version_to_str(protocol_version v) {
24  switch(v) {
25  case protocol_version::undetermined: return "undetermined";
26  case protocol_version::v3_1_1: return "v3_1_1";
27  case protocol_version::v5: return "v5";
28  default: return "unknown protocol_version";
29  }
30 }
31 
32 inline
33 std::ostream& operator<<(std::ostream& os, protocol_version val)
34 {
35  os << protocol_version_to_str(val);
36  return os;
37 }
38 
39 } // namespace MQTT_NS
40 
41 #endif // MQTT_PROTOCOL_VERSION_HPP
Definition: any.hpp:27
constexpr char const * protocol_version_to_str(protocol_version v)
Definition: protocol_version.hpp:23
std::ostream & operator<<(std::ostream &os, connect_return_code val)
Definition: connect_return_code.hpp:43
protocol_version
Definition: protocol_version.hpp:17