24 template <
class ContainerType>
25 Size indexOf(
const ContainerType& cont,
const typename ContainerType::value_type& val)
27 auto it = std::find(cont.begin(), cont.end(), val);
32 return std::distance(cont.begin(), it);
44 template <
class EnumType>
45 std::vector<std::string>
enumNames(
const std::string* names, EnumType size_value)
47 std::vector<std::string> result;
48 result.reserve(
static_cast<size_t>(size_value));
49 for (
size_t i = 0; i < static_cast<size_t>(size_value); ++i)
51 result.push_back(names[i]);
70 template <
class EnumType>
71 const std::string&
enumToName(
const std::string* names, EnumType value, EnumType size_value,
const char* size_name,
const char* function)
73 if (value == size_value)
77 return names[
static_cast<size_t>(value)];
94 template <
class EnumType>
95 EnumType
enumFromName(
const std::string* names, EnumType size_value,
const std::string& name,
const char* message,
const char* function)
97 const std::string*
first = names;
98 const std::string* last = names +
static_cast<size_t>(size_value);
99 const auto it = std::find(
first, last, name);
104 return static_cast<EnumType
>(it -
first);
Element could not be found exception.
Definition Exception.h:657
Invalid value exception.
Definition Exception.h:306
OpenMS looks in the< code > OPENMS_THERMO_MANAGED_DIR</code > environment variable first
Definition common-cmake-parameters.doxygen:179
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition Types.h:97
const std::string & enumToName(const std::string *names, EnumType value, EnumType size_value, const char *size_name, const char *function)
Converts an enum value to its entry in names.
Definition EnumHelpers.h:71
EnumType enumFromName(const std::string *names, EnumType size_value, const std::string &name, const char *message, const char *function)
Converts a name to the enum value at its index in names.
Definition EnumHelpers.h:95
Size indexOf(const ContainerType &cont, const typename ContainerType::value_type &val)
Definition EnumHelpers.h:25
std::vector< std::string > enumNames(const std::string *names, EnumType size_value)
Returns the names of all enum values, i.e. the first size_value entries of names.
Definition EnumHelpers.h:45
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19