handle parsing ints to enums
This commit is contained in:
parent
ad03011871
commit
725cae21eb
1 changed files with 6 additions and 0 deletions
|
@ -8,6 +8,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <util_stream_ops.hpp>
|
#include <util_stream_ops.hpp>
|
||||||
|
#include <string_util.hpp>
|
||||||
|
|
||||||
#include <foreach.hpp>
|
#include <foreach.hpp>
|
||||||
|
|
||||||
|
@ -74,6 +75,11 @@
|
||||||
inline std::istream &operator>>(std::istream &is, name &en) {\
|
inline std::istream &operator>>(std::istream &is, name &en) {\
|
||||||
std::string input;\
|
std::string input;\
|
||||||
is >> input;\
|
is >> input;\
|
||||||
|
if (isInt(input)) {\
|
||||||
|
en = static_cast<name>(std::stoul(input));\
|
||||||
|
return is;\
|
||||||
|
}\
|
||||||
|
toUpper(input);\
|
||||||
FOR_EACH(ENUM_FROM_STRING, name, __VA_ARGS__)\
|
FOR_EACH(ENUM_FROM_STRING, name, __VA_ARGS__)\
|
||||||
return is;\
|
return is;\
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue