Skip to content

Commit

Permalink
Use util::getEnv instead of lambda
Browse files Browse the repository at this point in the history
  • Loading branch information
Razvan Aguridan authored and dsarmany committed Sep 12, 2024
1 parent 6bb736e commit 9786d99
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
10 changes: 3 additions & 7 deletions src/multio/action/encode/GribEncoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "multio/util/DateTime.h"
#include "multio/util/Metadata.h"
#include "multio/util/Substitution.h"
#include "multio/util/Environment.h"

#include "multio/util/PrecisionTag.h"

Expand Down Expand Up @@ -237,13 +238,8 @@ std::optional<ValueSetter> valueSetter(GribEncoder& g, const std::string& key) {
}

std::string getUnstructuredGridType(const eckit::LocalConfiguration& config) {
return multio::util::replaceCurly(
config.getString("unstructured-grid-type"),
[](std::string_view replace) {
std::string lookUpKey{replace};
char* env = ::getenv(lookUpKey.c_str());
return env ? std::optional<std::string>{env} : std::optional<std::string>{};
});
std::optional<std::string_view> (*F)(std::string_view) = &multio::util::getEnv;
return multio::util::replaceCurly(config.getString("unstructured-grid-type"), F);
}

} // namespace
Expand Down
10 changes: 3 additions & 7 deletions src/multio/action/encode/GridDownloader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#include "multio/message/Glossary.h"
#include "multio/util/Substitution.h"
#include "multio/util/Environment.h"

namespace {
const std::unordered_map<std::string, int> latParamIds{
Expand Down Expand Up @@ -63,13 +64,8 @@ atlas::Grid readGrid(const std::string& name) {
}

std::string getUnstructuredGridType(const multio::config::ComponentConfiguration& compConf) {
return multio::util::replaceCurly(
compConf.parsedConfig().getString("unstructured-grid-type"),
[](std::string_view replace) {
std::string lookUpKey{replace};
char* env = ::getenv(lookUpKey.c_str());
return env ? std::optional<std::string>{env} : std::optional<std::string>{};
});
std::optional<std::string_view> (*F)(std::string_view) = &multio::util::getEnv;
return multio::util::replaceCurly(compConf.parsedConfig().getString("unstructured-grid-type"), F);
}

} // namespace
Expand Down

0 comments on commit 9786d99

Please sign in to comment.