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

ParmParse: Refactoring II #4035

Merged
merged 1 commit into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
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
32 changes: 11 additions & 21 deletions Src/Base/AMReX_ParmParse.H
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
#include <AMReX_Config.H>

#include <AMReX_BLassert.H>
#include <AMReX_INT.H>
#include <AMReX_TypeTraits.H>

#include <array>
#include <iosfwd>
#include <unordered_map>
#include <set>
#include <string>
#include <string_view>
Expand Down Expand Up @@ -1032,8 +1034,15 @@ public:
//! Returns [prefix.]* parameters.
[[nodiscard]] static std::set<std::string> getEntries (const std::string& prefix = std::string());

struct PP_entry;
using Table = std::vector<PP_entry>;
struct PP_entry {
// There can be multiple occurrences for a given name (e.g.,
// multiple lines starting with `foo =` in inputs. For each
// occurrence, there can be multiple values. Thus, the use of
// vector<vector<std::string>>.
std::vector<std::vector<std::string>> m_vals;
mutable Long m_count = 0;
};
using Table = std::unordered_map<std::string, PP_entry>;

[[nodiscard]] const Table& table() const {return *m_table;}

Expand All @@ -1048,25 +1057,6 @@ protected:
Table* m_table;
};

struct ParmParse::PP_entry
{
PP_entry (std::string a_name, std::vector<std::string> a_vals)
: m_name(std::move(a_name)), m_vals(std::move(a_vals)) {}

PP_entry (std::string a_name, std::string const& a_val)
: m_name(std::move(a_name)), m_vals({a_val}) {}

[[nodiscard]] std::string const& name () const noexcept { return m_name; }

[[nodiscard]] std::string print() const;

std::string m_name;
std::vector<std::string> m_vals;
mutable bool m_unused = true;
};

std::ostream& operator<< (std::ostream& os, const ParmParse::PP_entry& pp);

}

#endif /* AMREX_PARMPARSE_H_ */
Loading
Loading