Skip to content
Repos

DevPlaceApp

C++ 532 B24 lines Opens in site

Directory Raw Download

#include "model/Role.hpp"

#include <cctype>

#include "spec/WireEnums.hpp"

namespace dp {

const std::array<Role, Role::kCount>& Role::all() {
  static const std::array<Role, kCount> values = {Role(Role::Public), Role(Role::Member)};
  return values;
}

const char* Role::raw() const { return spec::WireEnums::kRole[static_cast<std::size_t>(value_)]; }

std::optional<Role> Role::fromRaw(const std::string& raw) {
  for (const auto& v : all()) {
    if (raw == v.raw()) return v;
  }
  return std::nullopt;
}


}  // namespace dp
39.9ms