/**
* Constructor.
- *
- * If @p skip_undefined is <code>true</code>, the parameter handler
- * will skip undefined sections and entries. This is useful for partially
- * parsing a parameter file, for example to obtain only the spatial dimension
- * of the problem. By default all entries and subsections are expected to be
- * declared.
*/
- ParameterHandler(const bool skip_undefined = false);
+ ParameterHandler();
/**
* Destructor. Declare this only to have a virtual destructor, which is
* will stop parsing lines after encountering @p last_line .
* This is handy when adding extra data that shall be parsed manually.
*
+ * If @p skip_undefined is <code>true</code>, the parameter handler
+ * will skip undefined sections and entries. This is useful for partially
+ * parsing a parameter file, for example to obtain only the spatial dimension
+ * of the problem. By default all entries and subsections are expected to be
+ * declared.
+ *
* The function sets the value of all parameters it encounters in the
* input file to the provided value. Parameters not explicitly listed
* in the input file are left at the value they previously held, which
*/
virtual void
parse_input(std::istream & input,
- const std::string &filename = "input file",
- const std::string &last_line = "");
+ const std::string &filename = "input file",
+ const std::string &last_line = "",
+ const bool skip_undefined = false);
/**
* Parse the given file to provide values for known parameter fields. The
* @endcode
*/
virtual void
- parse_input(const std::string &filename, const std::string &last_line = "");
+ parse_input(const std::string &filename,
+ const std::string &last_line = "",
+ const bool skip_undefined = false);
/**
* Parse input from a string to populate known parameter fields. The lines
* there for more information.
*/
virtual void
- parse_input_from_string(const char *s, const std::string &last_line = "");
+ parse_input_from_string(const char * s,
+ const std::string &last_line = "",
+ const bool skip_undefined = false);
/**
* Parse input from an XML stream to populate known parameter fields. This
*/
static const char path_separator = '.';
- /**
- * A flag to skip undefined entries.
- */
- const bool skip_undefined;
-
/**
* Path of presently selected subsections; empty list means top level
*/
*
* The function modifies its argument, but also takes it by value, so the
* caller's variable is not changed.
+ *
+ * If @p skip_undefined is <code>true</code>, the parser
+ * will skip undefined sections and entries. This is useful for partially
+ * parsing a parameter file, for example to obtain only the spatial dimension
+ * of the problem. By default all entries and subsections are expected to be
+ * declared.
*/
void
scan_line(std::string line,
const std::string &input_filename,
- const unsigned int current_line_n);
+ const unsigned int current_line_n,
+ const bool skip_undefined);
/**
* Print out the parameters of the subsection given by the
* will stop parsing lines after encountering @p last_line .
* This is handy when adding extra data that shall be parsed manually.
*
+ * If @p skip_undefined is <code>true</code>, the parameter handler
+ * will skip undefined sections and entries. This is useful for partially
+ * parsing a parameter file, for example to obtain only the spatial dimension
+ * of the problem. By default all entries and subsections are expected to be
+ * declared.
+ *
* @note This is the only overload of the three <tt>parse_input</tt>
* functions implemented by ParameterHandler overridden with new behavior by
* this class. This is because the other two <tt>parse_input</tt> functions
*/
virtual void
parse_input(std::istream & input,
- const std::string &filename = "input file",
- const std::string &last_line = "") override;
+ const std::string &filename = "input file",
+ const std::string &last_line = "",
+ const bool skip_undefined = false) override;
/**
* Overriding virtual functions which are overloaded (like
DEAL_II_NAMESPACE_OPEN
-ParameterHandler::ParameterHandler(const bool skip_undefined)
- : skip_undefined(skip_undefined)
- , entries(new boost::property_tree::ptree())
+ParameterHandler::ParameterHandler()
+ : entries(new boost::property_tree::ptree())
{}
void
ParameterHandler::parse_input(std::istream & input,
const std::string &filename,
- const std::string &last_line)
+ const std::string &last_line,
+ const bool skip_undefined)
{
AssertThrow(input, ExcIO());
//
// after unwinding the subsection stack, just re-throw the exception
auto scan_line_or_cleanup = [this,
+ &skip_undefined,
&saved_path](const std::string &line,
const std::string &filename,
const unsigned int line_number) {
try
{
- scan_line(line, filename, line_number);
+ scan_line(line, filename, line_number, skip_undefined);
}
catch (...)
{
void
ParameterHandler::parse_input(const std::string &filename,
- const std::string &last_line)
+ const std::string &last_line,
+ const bool skip_undefined)
{
PathSearch search("PARAMETERS");
std::string openname = search.find(filename);
std::ifstream file_stream(openname.c_str());
- parse_input(file_stream, filename, last_line);
+ parse_input(file_stream, filename, last_line, skip_undefined);
}
void
ParameterHandler::parse_input_from_string(const char * s,
- const std::string &last_line)
+ const std::string &last_line,
+ const bool skip_undefined)
{
std::istringstream input_stream(s);
- parse_input(input_stream, "input string", last_line);
+ parse_input(input_stream, "input string", last_line, skip_undefined);
}
void
ParameterHandler::scan_line(std::string line,
const std::string &input_filename,
- const unsigned int current_line_n)
+ const unsigned int current_line_n,
+ const bool skip_undefined)
{
// save a copy for some error messages
const std::string original_line = line;
void
MultipleParameterLoop::parse_input(std::istream & input,
const std::string &filename,
- const std::string &last_line)
+ const std::string &last_line,
+ const bool skip_undefined)
{
AssertThrow(input, ExcIO());
// Note that (to avoid infinite recursion) we have to explicitly call the
// base class version of parse_input and *not* a wrapper (which may be
// virtual and lead us back here)
- ParameterHandler::parse_input(input, filename, last_line);
+ ParameterHandler::parse_input(input, filename, last_line, skip_undefined);
init_branches();
}