inline macros that shouldn't have been there
This commit is contained in:
parent
03dd4df851
commit
d117e5c274
2 changed files with 17 additions and 21 deletions
|
|
@ -107,7 +107,23 @@ static std::unordered_map<std::string, JobStatusType> job_status_type_st {
|
||||||
{"unknown", JobStatusType::UNKNOWN}
|
{"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
|
// macro for registering enum classes for PQXX
|
||||||
|
|
||||||
|
|
|
||||||
20
src/util.h
20
src/util.h
|
|
@ -35,24 +35,4 @@
|
||||||
#define DEBUG_PRINT(msg) do {} while (0)
|
#define DEBUG_PRINT(msg) do {} while (0)
|
||||||
#endif
|
#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
|
#endif
|
||||||
Loading…
Reference in a new issue