Template Function RMGTools::ToEnum

Function Documentation

template<typename T>
T RMGTools::ToEnum(const std::string name, std::string prop_name = "property")

Converts a std::string to an enumeration value.

This function attempts to cast the provided std::string into 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 a std::bad_cast is thrown.

Template Parameters:

T – The enumeration type.

Parameters:
  • name – The std::string representing 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.