// clang-format off
// DO NOT EDIT: this file is auto-generated by caf-generate-enum-strings.
// Run the target update-enum-strings if this file is out of sync.
#include "caf/config.hpp"
#include "caf/string_view.hpp"

CAF_PUSH_DEPRECATED_WARNING

#include "caf/io/basp/message_type.hpp"

#include <string>

namespace caf {
namespace io {
namespace basp {

std::string to_string(message_type x) {
  switch(x) {
    default:
      return "???";
    case message_type::server_handshake:
      return "server_handshake";
    case message_type::client_handshake:
      return "client_handshake";
    case message_type::direct_message:
      return "direct_message";
    case message_type::routed_message:
      return "routed_message";
    case message_type::monitor_message:
      return "monitor_message";
    case message_type::down_message:
      return "down_message";
    case message_type::heartbeat:
      return "heartbeat";
  };
}

bool from_string(string_view in, message_type& out) {
  if (in == "server_handshake") {
    out = message_type::server_handshake;
    return true;
  } else if (in == "client_handshake") {
    out = message_type::client_handshake;
    return true;
  } else if (in == "direct_message") {
    out = message_type::direct_message;
    return true;
  } else if (in == "routed_message") {
    out = message_type::routed_message;
    return true;
  } else if (in == "monitor_message") {
    out = message_type::monitor_message;
    return true;
  } else if (in == "down_message") {
    out = message_type::down_message;
    return true;
  } else if (in == "heartbeat") {
    out = message_type::heartbeat;
    return true;
  } else {
    return false;
  }
}

bool from_integer(std::underlying_type_t<message_type> in,
                  message_type& out) {
  auto result = static_cast<message_type>(in);
  switch(result) {
    default:
      return false;
    case message_type::server_handshake:
    case message_type::client_handshake:
    case message_type::direct_message:
    case message_type::routed_message:
    case message_type::monitor_message:
    case message_type::down_message:
    case message_type::heartbeat:
      out = result;
      return true;
  };
}

} // namespace basp
} // namespace io
} // namespace caf

CAF_POP_WARNINGS
