mqtt_cpp
connect_return_code.hpp
Go to the documentation of this file.
1 // Copyright Takatoshi Kondo 2015
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_CONNECT_RETURN_CODE_HPP)
8 #define MQTT_CONNECT_RETURN_CODE_HPP
9 
10 #include <cstdint>
11 #include <ostream>
12 
13 #include <mqtt/namespace.hpp>
14 
15 namespace MQTT_NS {
16 
17 enum class connect_return_code : std::uint8_t {
18 
19  accepted = 0,
24  not_authorized = 5,
25 
26 };
27 
28 constexpr
30  char const * const str[] = {
31  "accepted",
32  "unacceptable_protocol_version",
33  "identifier_rejected",
34  "server_unavailable",
35  "bad_user_name_or_password",
36  "not_authorized"
37  };
38  if (static_cast<std::uint8_t>(v) < sizeof(str)) return str[static_cast<std::uint8_t>(v)];
39  return "unknown_connect_return_code";
40 }
41 
42 inline
43 std::ostream& operator<<(std::ostream& os, connect_return_code val)
44 {
45  os << connect_return_code_to_str(val);
46  return os;
47 }
48 
49 } // namespace MQTT_NS
50 
51 #endif // MQTT_CONNECT_RETURN_CODE_HPP
Definition: any.hpp:27
constexpr char const * connect_return_code_to_str(connect_return_code v)
Definition: connect_return_code.hpp:29
connect_return_code
Definition: connect_return_code.hpp:17
std::ostream & operator<<(std::ostream &os, connect_return_code val)
Definition: connect_return_code.hpp:43