From f46c1888091e904dc9e6db26f01ec7aae1a0a31d Mon Sep 17 00:00:00 2001 From: AlexanderSinn Date: Thu, 1 Aug 2024 19:27:53 +0200 Subject: [PATCH] use squeryWithParser instead of squeryval in pp_make_parser --- Src/Base/AMReX_ParmParse.cpp | 41 +++++++++++++++++------------------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/Src/Base/AMReX_ParmParse.cpp b/Src/Base/AMReX_ParmParse.cpp index a56b1d14cd..5f650511c7 100644 --- a/Src/Base/AMReX_ParmParse.cpp +++ b/Src/Base/AMReX_ParmParse.cpp @@ -868,6 +868,24 @@ saddarr (const std::string& name, const std::vector& ref) ++entry.m_count; } +template +bool squeryWithParser (const ParmParse::Table& table, + const std::string& parser_prefix, + const std::string& name, + T& ref) +{ + std::vector vals; + bool exist = squeryarr(table, parser_prefix, name, vals, + ParmParse::FIRST, ParmParse::ALL, ParmParse::LAST); + if (!exist) { return false; } + + std::string combined_string; + for (auto const& v : vals) { + combined_string.append(v); + } + return pp_parser(table, parser_prefix, name, combined_string, ref); +} + // Initialize ParmParse. void ppinit (int argc, char** argv, const char* parfile, ParmParse::Table& table) @@ -967,8 +985,7 @@ pp_make_parser (std::string const& func, Vector const& vars, value_t v = 0; bool r = false; for (auto const& pf : prefixes) { - r = squeryval(table, parser_prefix, pf+s, v, - ParmParse::FIRST, ParmParse::LAST); + r = squeryWithParser(table, parser_prefix, pf+s, v); if (r) { break; } } if (r == false) { @@ -1858,26 +1875,6 @@ ParmParse::remove (const char* name) return static_cast(n); } -namespace { -template -bool squeryWithParser (const ParmParse::Table& table, - const std::string& parser_prefix, - const std::string& name, - T& ref) -{ - std::vector vals; - bool exist = squeryarr(table, parser_prefix, name, vals, - ParmParse::FIRST, ParmParse::ALL, ParmParse::LAST); - if (!exist) { return false; } - - std::string combined_string; - for (auto const& v : vals) { - combined_string.append(v); - } - return pp_parser(table, parser_prefix, name, combined_string, ref); -} -} - int ParmParse::queryWithParser (const char* name, int& ref) const {