Initial Commit

Had to recreate repo because it was corrupted. FML.
This commit is contained in:
Mark Hoekveen
2018-06-30 14:17:13 +02:00
parent 3ae66d7969
commit 6c2c697a58
12 changed files with 994 additions and 0 deletions
+27
View File
@@ -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) "]"; \
} \
}