25#include "magic_enum/magic_enum.hpp"
42 template<
typename T> T ToEnum(
const std::string name, std::string prop_name =
"property") {
43 auto result = magic_enum::enum_cast<T>(name);
44 if (!result.has_value()) result = magic_enum::enum_cast<T>(
"k" + name);
45 if (!result.has_value()) {
46 RMGLog::OutFormat(
RMGLog::error,
"Illegal '{}' {} specified", name, prop_name);
47 throw std::bad_cast();
48 }
else return result.value();
61 template<
typename T> std::string GetCandidates(
const char delim =
' ') {
62 auto v = magic_enum::enum_names<T>();
64 for (
const auto& s : v) {
65 auto name = s[0] ==
'k' ? s.substr(1, std::string::npos) : s;
66 cand += std::string(name) + delim;
68 return cand.substr(0, cand.size() - 1);
81 template<
typename T> std::string GetCandidate(T t) {
82 auto s = magic_enum::enum_name<T>(t);
83 auto name = s[0] ==
'k' ? s.substr(1, std::string::npos) : s;
84 return std::string(name);
@ error
Print only errors.
Definition RMGLog.hh:72