protocol_version.hpp 956 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. #if !defined(MQTT_PROTOCOL_VERSION_HPP)
  7. #define MQTT_PROTOCOL_VERSION_HPP
  8. #include <cstdint>
  9. #include <ostream>
  10. #include <mqtt/namespace.hpp>
  11. namespace MQTT_NS {
  12. enum class protocol_version {
  13. undetermined = 0,
  14. v3_1_1 = 4,
  15. v5 = 5,
  16. };
  17. constexpr char const* protocol_version_to_str(protocol_version v) {
  18. switch(v) {
  19. case protocol_version::undetermined: return "undetermined";
  20. case protocol_version::v3_1_1: return "v3_1_1";
  21. case protocol_version::v5: return "v5";
  22. default: return "unknown_protocol_version";
  23. }
  24. }
  25. inline
  26. std::ostream& operator<<(std::ostream& os, protocol_version val)
  27. {
  28. os << protocol_version_to_str(val);
  29. return os;
  30. }
  31. } // namespace MQTT_NS
  32. #endif // MQTT_PROTOCOL_VERSION_HPP