<ol>
+ <li> Improved: Allow continuation lines in ParameterHandler.
+ <br>
+ (Alberto Sartori, 2015/09/04)
+
<li> Fixed: VectorTools::integrate_difference for VectorTools::Hdiv_seminorm
was computed incorrectly.
<br>
*
* Comments starting with \# are skipped.
*
+ * Continuation lines are allowed by means of the character <tt>\\</tt>,
+ * which must be the last character of the line.
+ *
* We propose to use the following scheme to name entries: start the first
* word with a capital letter and use lowercase letters further on. The same
* applies to the possible entry values to the right of the <tt>=</tt> sign.
try
{
std::string openname = search.find(filename);
- std::ifstream input (openname.c_str());
- AssertThrow(input, ExcIO());
+ std::ifstream file (openname.c_str());
+ AssertThrow(file, ExcIO());
- return read_input (input, filename);
+ std::string str;
+ std::string file_contents;
+
+ while (std::getline(file, str))
+ {
+ file_contents += str;
+ file_contents.push_back('\n');
+ }
+
+ return read_input_from_string (file_contents.c_str());
}
catch (const PathSearch::ExcFileNotFound &)
{
{
// create an istringstream representation and pass it off
// to the other functions doing this work
- std::istringstream in (s);
+
+ // concatenate the lines ending with "\"
+
+ std::istringstream file(s);
+ std::string str;
+ std::string file_contents;
+ bool is_concatenated(false);
+ while (std::getline(file, str))
+ {
+ // if this str must be concatenated with the previous one
+ // we strip the whitespaces
+ if (is_concatenated)
+ {
+ const std::size_t str_begin = str.find_first_not_of(" \t");
+ if (str_begin == std::string::npos)
+ str = ""; // no content
+ else
+ str.erase(0,str_begin); // trim whitespaces from left
+ }
+
+ if ((std::find(str.begin(),str.end(),'\\') != str.end()) && str.find_last_of('\\') == str.length()-1)
+ {
+ str.erase(str.length()-1); // remove '\'
+ file_contents += str;
+ is_concatenated = true; // next line must be concatenated = true
+ }
+ else
+ {
+ is_concatenated = false; // next line must be concatenated = false
+ file_contents += str;
+ file_contents.push_back('\n');
+ }
+ }
+ std::istringstream in (file_contents);
return read_input (in, "input string");
}
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2003 - 2014 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+
+#include "../tests.h"
+#include <deal.II/base/logstream.h>
+#include <deal.II/base/parameter_handler.h>
+#include <fstream>
+
+
+int main ()
+{
+ std::ofstream logfile("output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ ParameterHandler prm;
+ prm.enter_subsection ("Testing");
+ prm.declare_entry ("Function",
+ "a",
+ Patterns::List(Patterns::Selection("a|b|c|d|e|f|g|h")));
+ prm.leave_subsection ();
+
+ prm.read_input(SOURCE_DIR "/prm/parameter_handler_backslash_01.prm");
+
+ std::string list;
+ prm.enter_subsection ("Testing");
+ list = prm.get ("Function");
+ prm.leave_subsection ();
+
+ deallog << list << std::endl;
+
+ return 0;
+}
--- /dev/null
+
+DEAL::a, b, c
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2003 - 2014 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+
+#include "../tests.h"
+#include <deal.II/base/logstream.h>
+#include <deal.II/base/parameter_handler.h>
+#include <fstream>
+
+
+int main ()
+{
+ std::ofstream logfile("output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ ParameterHandler prm;
+ prm.enter_subsection ("Testing");
+ prm.declare_entry ("Function",
+ "a",
+ Patterns::List(Patterns::Selection("a|b|c|d|e|f|g|h")));
+ prm.leave_subsection ();
+
+ prm.read_input(SOURCE_DIR "/prm/parameter_handler_backslash_02.prm");
+
+ std::string list;
+ prm.enter_subsection ("Testing");
+ list = prm.get ("Function");
+ prm.leave_subsection ();
+
+ deallog << list << std::endl;
+
+ return 0;
+}
--- /dev/null
+
+DEAL::a,b,c
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2003 - 2014 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+
+#include "../tests.h"
+#include <deal.II/base/logstream.h>
+#include <deal.II/base/parameter_handler.h>
+#include <fstream>
+
+
+int main ()
+{
+ std::ofstream logfile("output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ ParameterHandler prm;
+ prm.enter_subsection ("Testing");
+ prm.declare_entry ("Function",
+ "a",
+ Patterns::List(Patterns::Selection("a|b|c|d|e|f|g|h")));
+ prm.leave_subsection ();
+
+ prm.read_input(SOURCE_DIR "/prm/parameter_handler_backslash_03.prm");
+
+ std::string list;
+ prm.enter_subsection ("Testing");
+ list = prm.get ("Function");
+ prm.leave_subsection ();
+
+ deallog << list << std::endl;
+
+ return 0;
+}
--- /dev/null
+
+DEAL::a, b, c
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2003 - 2014 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+
+#include "../tests.h"
+#include <deal.II/base/logstream.h>
+#include <deal.II/base/parameter_handler.h>
+#include <fstream>
+
+
+int main ()
+{
+ std::ofstream logfile("output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ ParameterHandler prm;
+ prm.enter_subsection ("Testing");
+ prm.declare_entry ("Function",
+ "a",
+ Patterns::List(Patterns::Selection("a|b|c|d|e|f|g|h")));
+ prm.leave_subsection ();
+
+ prm.read_input(SOURCE_DIR "/prm/parameter_handler_backslash_04.prm");
+
+ std::string list;
+ prm.enter_subsection ("Testing");
+ list = prm.get ("Function");
+ prm.leave_subsection ();
+
+ deallog << list << std::endl;
+
+ return 0;
+}
--- /dev/null
+
+DEAL::a, b, c
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2003 - 2014 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+
+#include "../tests.h"
+#include <deal.II/base/logstream.h>
+#include <deal.II/base/parameter_handler.h>
+#include <fstream>
+
+
+int main ()
+{
+ std::ofstream logfile("output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ ParameterHandler prm;
+ prm.enter_subsection ("Testing");
+ prm.declare_entry ("Function_1",
+ "a",
+ Patterns::List(Patterns::Selection("a|b|c")));
+ prm.declare_entry ("Function_2",
+ "d",
+ Patterns::List(Patterns::Selection("d|e|f")));
+ prm.leave_subsection ();
+
+ prm.read_input(SOURCE_DIR "/prm/parameter_handler_backslash_05.prm");
+
+ std::string list_1;
+ std::string list_2;
+ prm.enter_subsection ("Testing");
+ list_1 = prm.get ("Function_1");
+ list_2 = prm.get ("Function_2");
+ prm.leave_subsection ();
+
+ deallog << list_1 << std::endl;
+ deallog << list_2 << std::endl;
+
+ return 0;
+}
--- /dev/null
+
+DEAL::a, b, c
+DEAL::d, e, f
--- /dev/null
+#Listing of Parameters
+#---------------------
+subsection Testing
+ set Function = a, \
+ b, \
+ c
+end
--- /dev/null
+#Listing of Parameters
+#---------------------
+subsection Testing
+ set Function = a,\
+ \
+ b,\
+\
+ c
+end
--- /dev/null
+#Listing of Parameters
+#---------------------
+subsection Testing
+ set Function = a,\ # first term
+ b,\ # second
+ c # third
+end
--- /dev/null
+#Listing of Parameters
+#---------------------
+subsection Testing
+ set Function = a,\ b,
+ c
+end
--- /dev/null
+# a blank line will break the continuation
+
+# Listing of Parameters
+# ---------------------
+subsection Testing
+ set Function_1 = a, \
+
+ b, \
+ c
+
+ set Function_2 = d, e, \
+\
+\
+ \
+ f
+end
+
+