Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use squeryWithParser instead of squeryval in pp_make_parser #4060

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 19 additions & 22 deletions Src/Base/AMReX_ParmParse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -868,6 +868,24 @@ saddarr (const std::string& name, const std::vector<T>& ref)
++entry.m_count;
}

template <class T>
bool squeryWithParser (const ParmParse::Table& table,
const std::string& parser_prefix,
const std::string& name,
T& ref)
{
std::vector<std::string> 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)
Expand Down Expand Up @@ -967,8 +985,7 @@ pp_make_parser (std::string const& func, Vector<std::string> 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) {
Expand Down Expand Up @@ -1858,26 +1875,6 @@ ParmParse::remove (const char* name)
return static_cast<int>(n);
}

namespace {
template <class T>
bool squeryWithParser (const ParmParse::Table& table,
const std::string& parser_prefix,
const std::string& name,
T& ref)
{
std::vector<std::string> 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
{
Expand Down
Loading