Skip to content
Snippets Groups Projects
Commit 3ce3fae9 authored by Daniel Hornung's avatar Daniel Hornung
Browse files

STY: adding a few consts

parent 4df5b416
No related branches found
No related tags found
2 merge requests!14ENH: New functions getEnumNameFromValue() and getEnumValueFromName(),!12F consolidation
Pipeline #12246 failed
......@@ -63,7 +63,7 @@ auto getEnumValueFromName<Importance>(const std::string &name) -> Importance {
// caosdb::entity::importance_names.cend(),
// [name](const auto& entry){ return entry.second == name; });
// Workaround: plaint old iteration:
for (auto entry: caosdb::entity::importance_names) {
for (auto const &entry: caosdb::entity::importance_names) {
if (entry.second == name) {
return entry.first;
}
......@@ -73,16 +73,17 @@ auto getEnumValueFromName<Importance>(const std::string &name) -> Importance {
template <>
auto getEnumValueFromName<AtomicDataType>(const std::string &name) -> AtomicDataType {
for (auto entry: caosdb::entity::atomicdatatype_names) {
for (auto const &entry: caosdb::entity::atomicdatatype_names) {
if (entry.second == name) {
return entry.first;
}
}
throw std::out_of_range(std::string("Could not find enum value for string '") + name + "'.");
}
template <>
auto getEnumValueFromName<Role>(const std::string &name) -> Role {
for (auto entry: caosdb::entity::role_names) {
for (auto const &entry: caosdb::entity::role_names) {
if (entry.second == name) {
return entry.first;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment