Template Function RMGTools::ToEnum¶
Function Documentation¶
-
template<typename T>
T RMGTools::ToEnum(const std::string name, std::string prop_name = "property")¶ Converts a
std::stringto an enumeration value.This function attempts to cast the provided
std::stringinto an enum value of type T, using the provided string (optionally with an added prefix"k"). If both attempts fail, an error is logged and astd::bad_castis thrown.- Template Parameters:
T – The enumeration type.
- Parameters:
name – The
std::stringrepresenting the enumeration value.prop_name – The property name used for logging if the conversion fails (default:
"property").
- Throws:
std::bad_cast – If the conversion is not successful.
- Returns:
The enum value corresponding to the given string.