diff --git a/include/fc/reflect/reflect.hpp b/include/fc/reflect/reflect.hpp index 4deea27..044d77c 100644 --- a/include/fc/reflect/reflect.hpp +++ b/include/fc/reflect/reflect.hpp @@ -7,6 +7,7 @@ */ #include +#include #include #include #include @@ -148,7 +149,16 @@ template<> struct reflector { \ } \ static ENUM from_string( const char* s ) { \ BOOST_PP_SEQ_FOR_EACH( FC_REFLECT_ENUM_FROM_STRING, ENUM, FIELDS ) \ - return ENUM(atoi(s));\ + int64_t i; \ + try \ + { \ + i = boost::lexical_cast(s); \ + } \ + catch( const boost::bad_lexical_cast& e ) \ + { \ + fc::throw_bad_enum_cast( s, BOOST_PP_STRINGIZE(ENUM) ); \ + } \ + return ENUM(i);\ } \ }; \ }