<h3>Specific improvements</h3>
<ol>
+ <li> New: Added an optional string parameter to the ParameterHandler::read_input ()
+ and ParameterHandler::read_input_from_string() functions.
+ When a line which equals this string is encountered, the parsing of parameters
+ is terminated.
+ <br>
+ (Denis Davydov, 2016/04/20)
+ </li>
+
<li> New: Added move operations to IndexSet.
<br>
* the file (if that's what the input stream represents) we are reading
* from; this is only used when creating output for error messages.
*
+ * If non-empty @p last_line is provided, the ParameterHandler object
+ * will stop parsing lines after encountering @p last_line .
+ * This is handy when adding extra data that shall be parsed manually.
+ *
* Return whether the read was successful.
*/
virtual bool read_input (std::istream &input,
- const std::string &filename = "input file");
+ const std::string &filename = "input file",
+ const std::string &last_line = "");
/**
* Read input from a file the name of which is given. The PathSearch class
* automatically generate the requested file with default values if the file
* did not exist. This file will not contain additional comments if
* <tt>write_stripped_file</tt> is <tt>true</tt>.
+ *
+ * If non-empty @p last_line is provided, the ParameterHandler object
+ * will stop parsing lines after encountering @p last_line .
+ * This is handy when adding extra data that shall be parsed manually.
*/
virtual bool read_input (const std::string &filename,
const bool optional = false,
- const bool write_stripped_file = false);
+ const bool write_stripped_file = false,
+ const std::string &last_line = "");
/**
* Read input from a string in memory. The lines in memory have to be
* separated by <tt>@\n</tt> characters.
*
+ * If non-empty @p last_line is provided, the ParameterHandler object
+ * will stop parsing lines after encountering @p last_line .
+ * This is handy when adding extra data that shall be parsed manually.
+ *
* Return whether the read was successful.
*/
- virtual bool read_input_from_string (const char *s);
+ virtual bool read_input_from_string (const char *s,
+ const std::string &last_line = "");
/**
* Read a parameter file in XML format. This could be from a file originally
bool ParameterHandler::read_input (std::istream &input,
- const std::string &filename)
+ const std::string &filename,
+ const std::string &last_line)
{
AssertThrow (input, ExcIO());
// scan_line. This makes the continuation line logic a lot simpler.
input_line = Utilities::trim (input_line);
+ // If we see the line which is the same as @p last_line ,
+ // terminate the parsing.
+ if (last_line.length() != 0 &&
+ input_line == last_line)
+ break;
+
// Check whether or not the current line should be joined with the next
// line before calling scan_line.
if (input_line.length() != 0 &&
bool ParameterHandler::read_input (const std::string &filename,
const bool optional,
- const bool write_compact)
+ const bool write_compact,
+ const std::string &last_line)
{
PathSearch search("PARAMETERS");
std::ifstream file_stream (openname.c_str());
AssertThrow(file_stream, ExcIO());
- return read_input (file_stream, filename);
+ return read_input (file_stream, filename, last_line);
}
catch (const PathSearch::ExcFileNotFound &)
{
-bool ParameterHandler::read_input_from_string (const char *s)
+bool ParameterHandler::read_input_from_string (const char *s,
+ const std::string &last_line)
{
std::istringstream input_stream (s);
- return read_input (input_stream, "input string");
+ return read_input (input_stream, "input string", last_line);
}