Initial Commit
Had to recreate repo because it was corrupted. FML.
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
// Have enum names be convertible to strings
|
||||
// From https://stackoverflow.com/a/5094430
|
||||
// by James McNellis
|
||||
// with slight adjustments
|
||||
// Retrieved 14-10-2017
|
||||
#include <boost/preprocessor.hpp>
|
||||
|
||||
#define X_DEFINE_ENUM_WITH_STRING_CONVERSIONS_TOSTRING_CASE(r, data, elem) \
|
||||
case elem : return BOOST_PP_STRINGIZE(elem);
|
||||
|
||||
#define ENUM_STRING(name, enumerators) \
|
||||
enum name { \
|
||||
BOOST_PP_SEQ_ENUM(enumerators) \
|
||||
}; \
|
||||
\
|
||||
inline const char* ToString(name v) \
|
||||
{ \
|
||||
switch (v) \
|
||||
{ \
|
||||
BOOST_PP_SEQ_FOR_EACH( \
|
||||
X_DEFINE_ENUM_WITH_STRING_CONVERSIONS_TOSTRING_CASE, \
|
||||
name, \
|
||||
enumerators \
|
||||
) \
|
||||
default: return "[Unknown " BOOST_PP_STRINGIZE(name) "]"; \
|
||||
} \
|
||||
}
|
||||
Reference in New Issue
Block a user