19
19
#include < cctype>
20
20
#include < vector>
21
21
#include < list>
22
+ #include < set>
23
+ #include < string>
22
24
23
25
extern " C" void amrex_init_namelist (const char *);
24
26
extern " C" void amrex_finalize_namelist ();
@@ -1112,23 +1114,30 @@ ParmParse::hasUnusedInputs (const std::string& prefix)
1112
1114
1113
1115
static
1114
1116
void
1115
- get_unused_inputs (std::vector<std::string>& unused, const ParmParse::Table& table,
1116
- const std::string& prefix)
1117
+ get_entries_under_prefix (std::vector<std::string>& found_entries,
1118
+ const ParmParse::Table& table,
1119
+ const std::string& prefix,
1120
+ const bool only_unused = false ,
1121
+ const bool add_values = false )
1117
1122
{
1118
1123
const std::string prefixdot = prefix.empty () ? std::string () : prefix+" ." ;
1119
1124
for (auto const & entry : table) {
1120
- if (! entry.m_queried ) {
1125
+ if ((! only_unused) || (only_unused && ! entry.m_queried ) ) {
1121
1126
if (entry.m_name .substr (0 ,prefixdot.size ()) == prefixdot) {
1122
- std::string tmp (entry.m_name + " =" );
1123
- for (auto const & v : entry.m_vals ) {
1124
- tmp += " " + v;
1127
+ std::string tmp (entry.m_name );
1128
+ if (add_values) {
1129
+ tmp.append (" =" );
1130
+ for (auto const & v : entry.m_vals ) {
1131
+ tmp += " " + v;
1132
+ }
1125
1133
}
1126
- unused .emplace_back (std::move (tmp));
1134
+ found_entries .emplace_back (std::move (tmp));
1127
1135
}
1128
1136
}
1129
1137
1130
1138
if (entry.m_table ) {
1131
- get_unused_inputs (unused, table, prefix);
1139
+ get_entries_under_prefix (found_entries, table, prefix,
1140
+ only_unused, add_values);
1132
1141
}
1133
1142
}
1134
1143
}
@@ -1137,10 +1146,18 @@ std::vector<std::string>
1137
1146
ParmParse::getUnusedInputs (const std::string& prefix)
1138
1147
{
1139
1148
std::vector<std::string> r;
1140
- get_unused_inputs (r, g_table, prefix);
1149
+ get_entries_under_prefix (r, g_table, prefix, true , true );
1141
1150
return r;
1142
1151
}
1143
1152
1153
+ std::set<std::string>
1154
+ ParmParse::getEntries (const std::string& prefix)
1155
+ {
1156
+ std::vector<std::string> r;
1157
+ get_entries_under_prefix (r, g_table, prefix, false , false );
1158
+ return std::set<std::string>(r.begin (), r.end ());
1159
+ }
1160
+
1144
1161
void
1145
1162
ParmParse::Finalize ()
1146
1163
{
0 commit comments