1 #ifndef _CommonTools_Utils_StringToEnumValue_h_
2 #define _CommonTools_Utils_StringToEnumValue_h_
6 #include <Reflex/Reflex.h>
24 template <
class MyType>
27 using namespace ROOT::Reflex;
29 Reflex::Type rflxType = Reflex::Type::ByTypeInfo(
typeid(MyType));
30 Reflex::Member member = rflxType.MemberByName(enumName);
33 std::ostringstream err;
34 err<<
"StringToEnumValue Failure trying to convert " << enumName <<
" to int value";
38 if (member.TypeOf().TypeInfo() !=
typeid(int)) {
40 std::ostringstream err;
41 err <<
"Type "<< member.TypeOf().Name() <<
" is not Enum";
44 return Object_Cast<int>(member.Get());
70 template <
class MyType>
73 using namespace ROOT::Reflex;
78 vector<string>::const_iterator str=enumNames.begin();
79 for (;str!=enumNames.end();++str){
80 ret.push_back( StringToEnumValue<MyType>(*str));
int StringToEnumValue(const std::string &enumName)