inline macros that shouldn't have been there

This commit is contained in:
Fabian Posch 2024-01-11 13:27:57 -05:00
parent 03dd4df851
commit d117e5c274
2 changed files with 17 additions and 21 deletions

View file

@ -107,7 +107,23 @@ static std::unordered_map<std::string, JobStatusType> job_status_type_st {
{"unknown", JobStatusType::UNKNOWN}
};
ENUM_CLASS_OPS(JobStatusType, job_status_type_st);
inline std::string to_string(JobStatusType const &value) {
std::string str = "unknown";
for (auto& it : job_status_type_st) {
if (it.second == value) {
str = it.first;
break;
}
}
return str;
};
inline std::ostream& operator<<(std::ostream& os, JobStatusType const &rhs) {
os << to_string(rhs);
return os;
}
// macro for registering enum classes for PQXX

View file

@ -35,24 +35,4 @@
#define DEBUG_PRINT(msg) do {} while (0)
#endif
#define ENUM_CLASS_OPS(T, lookup_table) \
\
inline std::string to_string(T const &value) { \
std::string str = "unknown"; \
\
for (auto& it : lookup_table) { \
if (it.second == value) { \
str = it.first; \
break; \
} \
} \
\
return str; \
}; \
\
inline std::ostream& operator<<(std::ostream& os, T const &rhs) { \
os << to_string(rhs); \
return os; \
};
#endif