Skip to content
Repos

DevPlaceApp

C++ 906 B24 lines Opens in site

Directory Raw Download

#include "model/NotificationType.hpp"

#include <cctype>

#include "spec/WireEnums.hpp"

namespace dp {

const std::array<NotificationType, NotificationType::kCount>& NotificationType::all() {
  static const std::array<NotificationType, kCount> values = {NotificationType(NotificationType::Comment), NotificationType(NotificationType::Reply), NotificationType(NotificationType::Mention), NotificationType(NotificationType::Vote), NotificationType(NotificationType::Message), NotificationType(NotificationType::Issue), NotificationType(NotificationType::Badge)};
  return values;
}

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

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


}  // namespace dp
37.3ms