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
This commit is part of merge request !14. Comments created here will be created in the context of that merge request.
...@@ -63,7 +63,7 @@ auto getEnumValueFromName<Importance>(const std::string &name) -> Importance { ...@@ -63,7 +63,7 @@ auto getEnumValueFromName<Importance>(const std::string &name) -> Importance {
// caosdb::entity::importance_names.cend(), // caosdb::entity::importance_names.cend(),
// [name](const auto& entry){ return entry.second == name; }); // [name](const auto& entry){ return entry.second == name; });
// Workaround: plaint old iteration: // Workaround: plaint old iteration:
for (auto entry: caosdb::entity::importance_names) { for (auto const &entry: caosdb::entity::importance_names) {
if (entry.second == name) { if (entry.second == name) {
return entry.first; return entry.first;
} }
...@@ -73,16 +73,17 @@ auto getEnumValueFromName<Importance>(const std::string &name) -> Importance { ...@@ -73,16 +73,17 @@ auto getEnumValueFromName<Importance>(const std::string &name) -> Importance {
template <> template <>
auto getEnumValueFromName<AtomicDataType>(const std::string &name) -> AtomicDataType { 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) { if (entry.second == name) {
return entry.first; return entry.first;
} }
} }
throw std::out_of_range(std::string("Could not find enum value for string '") + name + "'."); throw std::out_of_range(std::string("Could not find enum value for string '") + name + "'.");
} }
template <> template <>
auto getEnumValueFromName<Role>(const std::string &name) -> Role { 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) { if (entry.second == name) {
return entry.first; 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