9#include <boost/algorithm/string/predicate.hpp>
25ModeIndex &typeStringLookup() {
26 static ModeIndex typeLookup;
36 const ModeIndex &lookup = typeStringLookup();
37 std::vector<std::string> modes;
38 modes.reserve(lookup.index.size());
39 for (
const auto &iter : lookup.index) {
42 modes.emplace_back(iter.second);
53 const ModeIndex &lookup = typeStringLookup();
54 auto iter = lookup.index.find(mode);
55 if (iter != lookup.index.end()) {
58 std::ostringstream os;
59 os <<
"DeltaEMode::asString - Unknown energy transfer mode: " << mode;
60 throw std::invalid_argument(os.str());
70 const ModeIndex &lookup = typeStringLookup();
72 auto emode = std::find_if(lookup.index.cbegin(), lookup.index.cend(),
73 [&modeStr](
auto it) { return boost::iequals(it.second, modeStr); });
75 if (emode != lookup.index.cend()) {
80 throw std::invalid_argument(
"DeltaEMode::fromString - Unknown energy transfer mode: " + modeStr);
std::map< DeltaEMode::Type, std::string > index
static std::string asString(const Type mode)
Return a string representation of the given mode.
static const std::vector< std::string > availableTypes()
Returns the string list of available modes.
static Type fromString(const std::string &modeStr)
Returns the emode from the given string.
Type
Define the available energy transfer modes It is important to assign enums proper numbers,...
@ Undefined
this mode should not be displayed among modes availible to select but may have string representation