1 #ifndef _utl_ConsecutiveEnumFactory_h_
2 #define _utl_ConsecutiveEnumFactory_h_
4 #include <utl/AugerException.h>
5 #include <utl/ThrowPolicy.h>
114 const char*
const tags[],
115 class NoConversionPolicy = ThrowPolicy<EnumType, utl::IOFailureException>,
116 EnumType first =
static_cast<EnumType
>(0)
125 std::ostringstream os;
126 os <<
"Cannot convert " << t <<
" to any of the valid enumerators:";
127 for (
unsigned int i = 0; i < kNumEnum; ++i)
128 os <<
' ' << tags[i];
129 os <<
" (with values from " << first <<
" to " << last <<
").";
130 return NoConversionPolicy::Handle(os.str());
135 const static unsigned int kNumEnum = last - first + 1;
141 if (first <= k && k <= last)
142 return static_cast<EnumType
>(k);
158 for (
unsigned int i = 0; i < kNumEnum; ++i)
160 return static_cast<EnumType
>(i);
Simple factory to create an enumerator for a given enumeration.
static EnumType Create(const int k)
int version of the overloaded creation method.
static EnumType Handle(const T &t)
Error handling.
static EnumType Create(const std::string &tag)
std::string version of the overloaded creation method.