]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Added initialize with input_stream, and optional prm. 5116/head
authorLuca Heltai <luca.heltai@sissa.it>
Mon, 25 Sep 2017 11:49:13 +0000 (13:49 +0200)
committerLuca Heltai <luca.heltai@sissa.it>
Tue, 26 Sep 2017 17:19:25 +0000 (19:19 +0200)
include/deal.II/base/parameter_acceptor.h
source/base/parameter_acceptor.cc

index 334cfb5b4810bc352edf630c63c42a49d3a21eb2..fc271cb7f057b738e152480c0339609dd1368cb8 100644 (file)
@@ -379,7 +379,21 @@ public:
    */
   static void initialize(const std::string &filename="",
                          const std::string &output_filename="",
-                         const ParameterHandler::OutputStyle output_style_for_prm_format=ParameterHandler::ShortText);
+                         const ParameterHandler::OutputStyle output_style_for_prm_format=ParameterHandler::ShortText,
+                         ParameterHandler &prm = ParameterAcceptor::prm);
+
+  /**
+   * Call declare_all_parameters(), read the parameters from the `input_stream`
+   * in `prm` format, and then call parse_all_parameters().
+   *
+   * An exception is thrown if the `input_stream` is invalid.
+   *
+   * @param input_stream Input stream
+   * @param prm The ParameterHandler to use
+   */
+  static void initialize(std::istream &input_stream,
+                         ParameterHandler &prm = ParameterAcceptor::prm);
+
 
   /**
    * Clear class list and global parameter file.
index 105ef2fa8684fd437bf7b7c8ee43f524b22cdbb7..7e771efa575b355429eebd1c7781092948314ff3 100644 (file)
@@ -51,9 +51,10 @@ std::string ParameterAcceptor::get_section_name() const
 void
 ParameterAcceptor::initialize(const std::string &filename,
                               const std::string &output_filename,
-                              const ParameterHandler::OutputStyle output_style_for_prm_format)
+                              const ParameterHandler::OutputStyle output_style_for_prm_format,
+                              ParameterHandler &prm)
 {
-  declare_all_parameters();
+  declare_all_parameters(prm);
   if (filename != "")
     {
       // check the extension of input file
@@ -118,7 +119,19 @@ ParameterAcceptor::initialize(const std::string &filename,
     }
 
   // Finally do the parsing.
-  parse_all_parameters();
+  parse_all_parameters(prm);
+}
+
+
+
+void ParameterAcceptor::initialize(std::istream &input_stream,
+                                   ParameterHandler &prm)
+
+{
+  AssertThrow(input_stream, ExcIO());
+  declare_all_parameters(prm);
+  prm.parse_input(input_stream);
+  parse_all_parameters(prm);
 }
 
 void

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.