00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef MTL_STRING_TO_ENUM_INCLUDE
00013 #define MTL_STRING_TO_ENUM_INCLUDE
00014
00015 #include <string>
00016 #include <boost/numeric/mtl/operation/size.hpp>
00017
00018 namespace mtl {
00019
00027 template <typename EnumType, typename Array>
00028 EnumType inline string_to_enum(const std::string& s, const Array& l, EnumType)
00029 {
00030 std::size_t i;
00031 for (i= 0; i < size(l) && std::string(l[i]) != s; i++) ;
00032 MTL_THROW_IF(i == size(l), runtime_error("Search string not found"));
00033 return EnumType(i);
00034 }
00035
00036 }
00037
00038 #endif // MTL_STRING_TO_ENUM_INCLUDE