29 out <<
"# Modifier Used: " << name_ << std::endl;
34 const std::string &base_name,
const bool &find_parameters,
const bool &find_sublists)
const
38 for (itr = pl.
begin(); itr != pl.
end(); ++itr) {
39 const std::string &name = pl.
name(itr);
40 std::size_t found = name.find(base_name);
62 auto ignore_names = exclude_parameters;
63 std::sort(ignore_names.begin(), ignore_names.end());
67 for (itr = pl.
begin(); itr != pl.
end(); ++itr) {
68 const std::string ¶m_name = pl.
name(itr);
70 if (!std::binary_search(ignore_names.begin(), ignore_names.end(), param_name)){
71 valid_pl.
setEntry(param_name, valid_pl_entry);
76 valid_pl.
remove(param_template_name);
87 auto ignore_names = exclude_sublists;
88 std::sort(ignore_names.begin(), ignore_names.end());
90 if (valid_pl.
isSublist(sublist_template_name)){
92 for (itr = pl.
begin(); itr != pl.
end(); ++itr) {
93 const std::string &subname = pl.
name(itr);
95 if (!std::binary_search(ignore_names.begin(), ignore_names.end(), subname)){
96 valid_pl.
set(subname, valid_pl_sublist);
101 valid_pl.
remove(sublist_template_name);
109 const bool &allow_base_name)
const
111 int replacements = 0;
112 bool delete_base_name =
true;
116 "Sublist can't have the same name as the parameter template name "
117 "without `allow_base_name=true`.");
118 delete_base_name =
false;
121 replacements = matches.
length();
122 for (
const std::string &match_name : matches){
125 if (delete_base_name){
126 valid_pl.
remove(base_name);
135 const bool remove_param)
const
137 int num_defaults = 0;
139 for (
const std::string &sublist_name : sublist_names){
144 sublist.
setEntry(param_name, pl_entry);
const std::string & name() const
The name of this ParameterList.
C++ Standard Library compatable filtered iterator.
ParameterList & setEntry(const std::string &name, U &&entry)
Set a parameter directly as a ParameterEntry.
ConstIterator end() const
An iterator pointing beyond the last entry.
T & get(const std::string &name, T def_value)
Return the parameter's value, or the default value if it is not there.
This object is held as the "value" in the Teuchos::ParameterList std::map.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Macro for throwing an exception with breakpointing to ease debugging.
static std::ostream & printLines(std::ostream &os, const std::string &linePrefix, const std::string &lines)
Print lines with prefix first.
ParameterList & set(std::string const &name, T &&value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
Templated set method.
A std::string utilities class for Teuchos.
bool isParameter(const std::string &name) const
Whether the given parameter exists in this list.
bool remove(std::string const &name, bool throwIfNotExists=true)
Remove a parameter (does not depend on the type of the parameter).
int expandParameters(const std::string ¶mTemplateName, ParameterList ¶mList, ParameterList &validParamList, const Array< std::string > &excludeParameters=Array< std::string >()) const
Create parameters in the valid parameter list using a template parameter from the valid parameter lis...
int setDefaultsInSublists(const std::string ¶mName, ParameterList ¶mList, const Array< std::string > &sublistNames, const bool removeParam=true) const
Copy a parameter into desired sublists.
Templated Parameter List class.
bool isSublist(const std::string &name) const
Whether the given sublist exists in this list.
Array< std::string > findMatchingBaseNames(const ParameterList ¶mList, const std::string &baseName, const bool &findParameters=true, const bool &findSublists=true) const
Find the parameters and/or sublists with matching base names.
virtual ~ParameterListModifier()
Destructor.
int expandSublistsUsingBaseName(const std::string &baseName, ParameterList ¶mList, ParameterList &validParamList, const bool &allowBaseName=true) const
Create sublists in the valid parameter list using a base name and the corresponding sublists in the p...
ConstIterator begin() const
An iterator pointing to the first entry.
A list of parameters of arbitrary type.
Parameter List Modifier class.
void push_back(const value_type &x)
int length() const
Return number of elements in the array.
ParameterList & sublist(const std::string &name, bool mustAlreadyExist=false, const std::string &docString="")
Creates an empty sublist and returns a reference to the sublist name. If the list already exists...
void printDoc(std::string const &docString, std::ostream &out) const
Print documentation for this parameter list modifier.
ParameterEntry & getEntry(const std::string &name)
Retrieves an entry with the name name.
ParameterListModifier()=default
Constructor.
int expandSublists(const std::string &sublistTemplateName, ParameterList ¶mList, ParameterList &validParamList, const Array< std::string > &excludeSublists=Array< std::string >()) const
Create sublists in the valid parameter list using a template parameter from the valid parameter list ...