From 9786d99b26763649bd1d2b3c55ea5e48d7850797 Mon Sep 17 00:00:00 2001 From: Razvan Aguridan Date: Mon, 26 Aug 2024 09:09:17 +0000 Subject: [PATCH] Use util::getEnv instead of lambda --- src/multio/action/encode/GribEncoder.cc | 10 +++------- src/multio/action/encode/GridDownloader.cc | 10 +++------- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/src/multio/action/encode/GribEncoder.cc b/src/multio/action/encode/GribEncoder.cc index c577491e..528139ee 100644 --- a/src/multio/action/encode/GribEncoder.cc +++ b/src/multio/action/encode/GribEncoder.cc @@ -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" @@ -237,13 +238,8 @@ std::optional 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{env} : std::optional{}; - }); + std::optional (*F)(std::string_view) = &multio::util::getEnv; + return multio::util::replaceCurly(config.getString("unstructured-grid-type"), F); } } // namespace diff --git a/src/multio/action/encode/GridDownloader.cc b/src/multio/action/encode/GridDownloader.cc index 22aed6fe..2bd2eac6 100644 --- a/src/multio/action/encode/GridDownloader.cc +++ b/src/multio/action/encode/GridDownloader.cc @@ -26,6 +26,7 @@ #include "multio/message/Glossary.h" #include "multio/util/Substitution.h" +#include "multio/util/Environment.h" namespace { const std::unordered_map latParamIds{ @@ -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{env} : std::optional{}; - }); + std::optional (*F)(std::string_view) = &multio::util::getEnv; + return multio::util::replaceCurly(compConf.parsedConfig().getString("unstructured-grid-type"), F); } } // namespace