]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Make all possible Short combinations of output work.
authorLuca Heltai <luca.heltai@sissa.it>
Tue, 28 Apr 2020 21:09:39 +0000 (23:09 +0200)
committerLuca Heltai <luca.heltai@sissa.it>
Tue, 28 Apr 2020 21:09:39 +0000 (23:09 +0200)
12 files changed:
include/deal.II/base/parameter_handler.h
source/base/parameter_handler.cc
tests/parameter_handler/parameter_acceptor_05.output
tests/parameter_handler/parameter_acceptor_06.output
tests/parameter_handler/parameter_acceptor_07.expect=run.output
tests/parameter_handler/parameter_acceptor_09.cc [new file with mode: 0644]
tests/parameter_handler/parameter_acceptor_09.output [new file with mode: 0644]
tests/parameter_handler/parameter_handler_25.output
tests/parameter_handler/parameter_handler_27.cc [new file with mode: 0644]
tests/parameter_handler/parameter_handler_27.output [new file with mode: 0644]
tests/parameter_handler/parameter_handler_28.cc [new file with mode: 0644]
tests/parameter_handler/parameter_handler_28.output [new file with mode: 0644]

index e91a3517bcde09c5d6b2b68a90d8306492ac4eab..80bdcebdcaa498f0fc9a4e04abe7a90856b75fa3 100644 (file)
@@ -852,20 +852,13 @@ public:
    * - format options: PRM, LaTeX, Description, XML, JSON
    * - stylistic options: Short, KeepDeclarationOrder
    *
-   * A valid combination of options is given in the following table:
+   * Only one format option may be specified at the time. Any function that
+   * accepts an OutputStyle as an option will throw if you specify more than
+   * one.
    *
-   * Stylistic options    | Default | PRM | LaTeX | Description | XML | JSON
-   * -------------------- | ------- | --- | ----- | ----------- | --- | ----
-   * Default              |    X    |  X  |   X   |      X      |  X  |  X
-   * Short                |    X    |  X  |   -   |      X      |  X  |  X
-   * KeepDeclarationOrder |    X    |  X  |   X   |      X      |  X  |  X
-   *
-   * Valid combinations are checked at the beginning of the functions that
-   * accept an OutputStyle as an input argument.
-   *
-   * Furthermore, a number of shortcuts of commonly used option combinations are
-   * provided. E.g., ShortPRM prints the parameters in the PRM
-   * format, while skipping the documentation.
+   * A number of shortcuts of commonly used option combinations are provided.
+   * E.g., ShortPRM prints the parameters in the PRM format, while skipping the
+   * documentation.
    */
   enum OutputStyle
   {
@@ -929,13 +922,13 @@ public:
     JSON = 0x0100,
 
     /**
-     * Write input for ParameterHandler without comments or changed default
+     * Write the content of ParameterHandler without comments or changed default
      * values.
      */
     ShortPRM = PRM | Short,
 
     /**
-     * Write input for ParameterHandler without comments or changed default
+     * Write the content of ParameterHandler without comments or changed default
      * values.
      *
      * @deprecated Use `ShortPRM` instead of `ShortText`.
@@ -943,16 +936,22 @@ public:
     ShortText = ShortPRM,
 
     /**
-     * Write input for ParameterHandler without comments or changed default
+     * Write the content of ParameterHandler without comments or changed default
      * values as a XML file.
      */
     ShortXML = XML | Short,
 
     /**
-     * Write input for ParameterHandler without comments or changed default
+     * Write the content of ParameterHandler without comments or changed default
      * values as a JSON file.
      */
     ShortJSON = JSON | Short,
+
+    /**
+     * Write the content of ParameterHandler without comments or changed default
+     * values as a LaTeX file.
+     */
+    ShortLaTeX = LaTeX | Short,
   };
 
 
@@ -1422,10 +1421,10 @@ public:
    * available.
    *
    * By using the flag <tt>Short</tt> in combination with <tt>PRM</tt>,
-   * <tt>XML</tt>, or <tt>JSON</tt> (or by using the shortcuts
-   * <tt>ShortPRM</tt>, <tt>ShortXML</tt>, or <tt>ShortJSON</tt>), a reduced
-   * output can be generated, only containing the values and skipping the
-   * documentation.
+   * <tt>XML</tt>, <tt>JSON</tt>, or <tt>LaTeX</tt> (or by using the shortcuts
+   * <tt>ShortPRM</tt>, <tt>ShortXML</tt>, <tt>ShortJSON</tt>, or
+   * <tt>ShortLaTeX</tt>), a reduced output can be generated, only containing
+   * the values and skipping the documentation.
    *
    * In <tt>XML</tt> format, the output starts with one root element
    * <tt>ParameterHandler</tt> in order to get a valid XML document and all
index 07716b8826af9f5f86bf326839631e7bfc48bb24..022c9182102a1a7f97b67be2f71bbd55fb9fec4c 100644 (file)
@@ -342,11 +342,8 @@ namespace
        ((style & ParameterHandler::Description) != 0) +
        ((style & ParameterHandler::LaTeX) != 0)) == 1,
       ExcMessage(
-        "You have chosen either no or multiple style formats. You can choose between: PRM, Description, LaTeX, XML, JSON."));
-
-    AssertThrow(((style & ParameterHandler::LaTeX) &&
-                 (style & ParameterHandler::Short)) == false,
-                ExcMessage("It is not possible to request short LaTex."));
+        "You have chosen either no or multiple style formats. You can choose "
+        "between: PRM, Description, LaTeX, XML, JSON."));
   }
 
 } // namespace
@@ -534,10 +531,7 @@ ParameterHandler::parse_input(const std::string &filename,
                               const bool assert_mandatory_entries_are_found)
 {
   std::ifstream is(filename);
-  AssertThrow(is,
-              ExcMessage("Invalid filename " + filename +
-                         " provided. File does not exist or "
-                         "can not be read from."));
+  AssertThrow(is, PathSearch::ExcFileNotFound(filename, "ParameterHandler"));
 
   std::string file_ending = filename.substr(filename.find_last_of('.') + 1);
   boost::algorithm::to_lower(file_ending);
@@ -672,8 +666,7 @@ namespace
   //
   // This function is strongly based on read_xml_recursively().
   void
-  recursively_remove_documentation_from_tree(
-    boost::property_tree::ptree &source)
+  recursively_compress_tree(boost::property_tree::ptree &source)
   {
     for (auto &p : source)
       {
@@ -691,7 +684,7 @@ namespace
         else
           {
             // it must be a subsection
-            recursively_remove_documentation_from_tree(p.second);
+            recursively_compress_tree(p.second);
           }
       }
   }
@@ -1272,11 +1265,11 @@ ParameterHandler::print_parameters(std::ostream &    out,
   // done recursively in our own code. take care of the two special formats
   // first
 
-  // explicity eliminate the documentation from the tree if requested
-  if (style & Short)
+  // explicity compress the tree if requested
+  if ((style & Short) && (style & (XML | JSON)))
     {
       // modify the copy of the tree
-      recursively_remove_documentation_from_tree(current_entries);
+      recursively_compress_tree(current_entries);
     }
 
   if (style & XML)
@@ -1436,8 +1429,6 @@ ParameterHandler::recursively_print_parameters(
                       << "# " << doc_line << '\n';
               }
 
-
-
             // print name and value of this entry
             out << std::setw(overall_indent_level * 2) << ""
                 << "set " << demangle(p.first)
@@ -1525,20 +1516,22 @@ ParameterHandler::recursively_print_parameters(
 
                 // if there is a documenting string, print it as well but
                 // don't escape to allow formatting/formulas
-                if (!(style & Short))
-                  if (!p.second.get<std::string>("documentation").empty())
-                    out << "{\\it Description:} "
-                        << p.second.get<std::string>("documentation") << "\n\n"
-                        << '\n';
-
-                // also output possible values, do not escape because the
-                // description internally will use LaTeX formatting
-                const unsigned int pattern_index =
-                  p.second.get<unsigned int>("pattern");
-                const std::string desc_str =
-                  patterns[pattern_index]->description(
-                    Patterns::PatternBase::LaTeX);
-                out << "{\\it Possible values:} " << desc_str << '\n';
+                if (!is_short &&
+                    !p.second.get<std::string>("documentation").empty())
+                  out << "{\\it Description:} "
+                      << p.second.get<std::string>("documentation") << "\n\n"
+                      << '\n';
+                if (!is_short)
+                  {
+                    // also output possible values, do not escape because the
+                    // description internally will use LaTeX formatting
+                    const unsigned int pattern_index =
+                      p.second.get<unsigned int>("pattern");
+                    const std::string desc_str =
+                      patterns[pattern_index]->description(
+                        Patterns::PatternBase::LaTeX);
+                    out << "{\\it Possible values:} " << desc_str << '\n';
+                  }
               }
             else if (is_alias_node(p.second) == true)
               {
@@ -1630,7 +1623,8 @@ ParameterHandler::recursively_print_parameters(
               out << '\n';
 
             // if there is a documenting string, print it as well
-            if (p.second.get<std::string>("documentation").length() != 0)
+            if (!is_short &&
+                p.second.get<std::string>("documentation").length() != 0)
               out << std::setw(overall_indent_level * 2 + longest_name + 10)
                   << ""
                   << "(" << p.second.get<std::string>("documentation") << ")"
@@ -1726,11 +1720,11 @@ ParameterHandler::recursively_print_parameters(
             if (overall_indent_level == 0)
               out << '\n';
           }
-        else if (style == Description)
+        else if (style & Description)
           {
             // nothing to do
           }
-        else if (style == LaTeX)
+        else if (style & LaTeX)
           {
             // nothing to do
           }
index 1ce6b94efc6cfe585b24fc188955ae6b4958ffc6..7357ac8dbab20816494032e786204e8a75d80c40 100644 (file)
@@ -9,4 +9,4 @@ DEAL:parameters:Second Class::Second int: 5
 DEAL:parameters:Second Class::Second string: bye bye
 DEAL::reading used_parameter_acceptor_05.xml
 DEAL::<?xml version="1.0" encoding="utf-8"?>
-DEAL::<ParameterHandler><First_20Class><First_20bool><value>true</value><default_value>true</default_value><documentation/><pattern>2</pattern><pattern_description>[Bool]</pattern_description><actions>2</actions></First_20bool><First_20double><value>7.7</value><default_value>7.7</default_value><documentation/><pattern>1</pattern><pattern_description>[Double -MAX_DOUBLE...MAX_DOUBLE (inclusive)]</pattern_description><actions>1</actions></First_20double><First_20int><value>3</value><default_value>3</default_value><documentation/><pattern>0</pattern><pattern_description>[Integer range -2147483648...2147483647 (inclusive)]</pattern_description><actions>0</actions></First_20int><First_20string><value>hello</value><default_value>hello</default_value><documentation/><pattern>3</pattern><pattern_description>[Anything]</pattern_description><actions>3</actions></First_20string></First_20Class><Second_20Class><Second_20bool><value>false</value><default_value>false</default_value><documentation/><pattern>6</pattern><pattern_description>[Bool]</pattern_description><actions>6</actions></Second_20bool><Second_20double><value>9.9</value><default_value>9.9</default_value><documentation/><pattern>5</pattern><pattern_description>[Double -MAX_DOUBLE...MAX_DOUBLE (inclusive)]</pattern_description><actions>5</actions></Second_20double><Second_20int><value>5</value><default_value>5</default_value><documentation/><pattern>4</pattern><pattern_description>[Integer range -2147483648...2147483647 (inclusive)]</pattern_description><actions>4</actions></Second_20int><Second_20string><value>bye bye</value><default_value>bye bye</default_value><documentation/><pattern>7</pattern><pattern_description>[Anything]</pattern_description><actions>7</actions></Second_20string></Second_20Class></ParameterHandler>
+DEAL::<ParameterHandler><First_20Class><First_20bool>true</First_20bool><First_20double>7.7</First_20double><First_20int>3</First_20int><First_20string>hello</First_20string></First_20Class><Second_20Class><Second_20bool>false</Second_20bool><Second_20double>9.9</Second_20double><Second_20int>5</Second_20int><Second_20string>bye bye</Second_20string></Second_20Class></ParameterHandler>
index 0da52b16978cfef4709b8a027b4c6f183a30ce1f..9391c612795d7e0c0d9f9c01e1a074bcf5b3b89b 100644 (file)
@@ -30,7 +30,6 @@ DEAL::
 DEAL::{\it Default:} true
 DEAL::
 DEAL::
-DEAL::{\it Possible values:} A boolean value (true or false)
 DEAL::\item {\it Parameter name:} {\tt First double}
 DEAL::\phantomsection\label{parameters:First Class/First double}
 DEAL::\label{parameters:First_20Class/First_20double}
@@ -41,10 +40,9 @@ DEAL::\index[prmindexfull]{First Class!First double}
 DEAL::{\it Value:} 7.7
 DEAL::
 DEAL::
-DEAL::{\it Default:} 7.700000
+DEAL::{\it Default:} 7.7
 DEAL::
 DEAL::
-DEAL::{\it Possible values:} A floating point number $v$ such that $-\text{MAX\_DOUBLE} \leq v \leq \text{MAX\_DOUBLE}$
 DEAL::\item {\it Parameter name:} {\tt First int}
 DEAL::\phantomsection\label{parameters:First Class/First int}
 DEAL::\label{parameters:First_20Class/First_20int}
@@ -58,7 +56,6 @@ DEAL::
 DEAL::{\it Default:} 3
 DEAL::
 DEAL::
-DEAL::{\it Possible values:} An integer $n$ such that $-2147483648\leq n \leq 2147483647$
 DEAL::\item {\it Parameter name:} {\tt First string}
 DEAL::\phantomsection\label{parameters:First Class/First string}
 DEAL::\label{parameters:First_20Class/First_20string}
@@ -72,7 +69,6 @@ DEAL::
 DEAL::{\it Default:} hello
 DEAL::
 DEAL::
-DEAL::{\it Possible values:} Any string
 DEAL::\end{itemize}
 DEAL::
 DEAL::\subsection{Parameters in section \tt Second Class}
@@ -92,7 +88,6 @@ DEAL::
 DEAL::{\it Default:} false
 DEAL::
 DEAL::
-DEAL::{\it Possible values:} A boolean value (true or false)
 DEAL::\item {\it Parameter name:} {\tt Second double}
 DEAL::\phantomsection\label{parameters:Second Class/Second double}
 DEAL::\label{parameters:Second_20Class/Second_20double}
@@ -103,10 +98,9 @@ DEAL::\index[prmindexfull]{Second Class!Second double}
 DEAL::{\it Value:} 9.9
 DEAL::
 DEAL::
-DEAL::{\it Default:} 9.900000
+DEAL::{\it Default:} 9.9
 DEAL::
 DEAL::
-DEAL::{\it Possible values:} A floating point number $v$ such that $-\text{MAX\_DOUBLE} \leq v \leq \text{MAX\_DOUBLE}$
 DEAL::\item {\it Parameter name:} {\tt Second int}
 DEAL::\phantomsection\label{parameters:Second Class/Second int}
 DEAL::\label{parameters:Second_20Class/Second_20int}
@@ -120,7 +114,6 @@ DEAL::
 DEAL::{\it Default:} 5
 DEAL::
 DEAL::
-DEAL::{\it Possible values:} An integer $n$ such that $-2147483648\leq n \leq 2147483647$
 DEAL::\item {\it Parameter name:} {\tt Second string}
 DEAL::\phantomsection\label{parameters:Second Class/Second string}
 DEAL::\label{parameters:Second_20Class/Second_20string}
@@ -134,5 +127,4 @@ DEAL::
 DEAL::{\it Default:} bye bye
 DEAL::
 DEAL::
-DEAL::{\it Possible values:} Any string
 DEAL::\end{itemize}
diff --git a/tests/parameter_handler/parameter_acceptor_09.cc b/tests/parameter_handler/parameter_acceptor_09.cc
new file mode 100644 (file)
index 0000000..152e77e
--- /dev/null
@@ -0,0 +1,62 @@
+//-----------------------------------------------------------
+//
+//    Copyright (C) 2020 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.md at
+//    the top level directory of deal.II.
+//
+//-----------------------------------------------------------
+
+// Test that ParameterAcceptor::initialize() works as expected
+
+
+#include <deal.II/base/parameter_acceptor.h>
+#include <deal.II/base/point.h>
+
+#include "../tests.h"
+
+// Test subsectioning
+
+class Test : public ParameterAcceptor
+{
+public:
+  Test()
+  {
+    add_parameter("A point", a_point);
+  };
+
+private:
+  Point<3> a_point;
+};
+
+void
+test_ext(const std::string &ext)
+{
+  Test a;
+
+  deallog << "Generate and read input." << ext << std::endl;
+  try
+    {
+      ParameterAcceptor::initialize("input." + ext);
+    }
+  catch (...)
+    {
+      // The above call must have created a file named input.ext
+      cat_file(("input." + ext).c_str());
+    }
+}
+
+int
+main()
+{
+  initlog();
+  test_ext("prm");
+  test_ext("xml");
+  test_ext("json");
+}
diff --git a/tests/parameter_handler/parameter_acceptor_09.output b/tests/parameter_handler/parameter_acceptor_09.output
new file mode 100644 (file)
index 0000000..f2d1ef7
--- /dev/null
@@ -0,0 +1,30 @@
+
+DEAL::Generate and read input.prm
+# Listing of Parameters
+# ---------------------
+subsection Test
+  set A point = 0, 0, 0
+end
+
+
+
+DEAL::Generate and read input.xml
+<?xml version="1.0" encoding="utf-8"?>
+<ParameterHandler><Test><A_20point><value>0, 0, 0</value><default_value>0, 0, 0</default_value><documentation/><pattern>1</pattern><pattern_description>[List of &lt;[Double -MAX_DOUBLE...MAX_DOUBLE (inclusive)]&gt; of length 3...3 (inclusive)]</pattern_description><actions>0,1</actions></A_20point></Test></ParameterHandler>
+
+DEAL::Generate and read input.json
+{
+    "Test":
+    {
+        "A_20point":
+        {
+            "value": "0, 0, 0",
+            "default_value": "0, 0, 0",
+            "documentation": "",
+            "pattern": "2",
+            "pattern_description": "[List of <[Double -MAX_DOUBLE...MAX_DOUBLE (inclusive)]> of length 3...3 (inclusive)]",
+            "actions": "0,1,2"
+        }
+    }
+}
+
index 469de723740891c2ec2de75d30aaebd188339e43..773966bd7c609534238334f4fbcd369511f644e5 100644 (file)
@@ -4,10 +4,10 @@ DEAL::successful
 DEAL::
 --------------------------------------------------------
 An error occurred in file <parameter_handler.cc> in function
-    void dealii::ParameterHandler::set(const string&, const string&)
-The violated condition was:
+    void dealii::ParameterHandler::set(const std::string &, const std::string &)
+The violated condition was: 
     false
-Additional information:
+Additional information: 
     You can't ask for entry <Precison> you have not yet declared.
 --------------------------------------------------------
 
@@ -15,10 +15,10 @@ DEAL::
 --------------------------------------------------------
 An error occurred in file <parameter_handler.cc> in function
     void dealii::ParameterHandler::assert_that_entries_have_been_set() const
-The violated condition was:
+The violated condition was: 
     entries_wrongly_not_set.size() == 0
-Additional information:
-    Not all entries of the parameter handler that were declared with `has_to_be_set = true` have been set. The following parameters
+Additional information: 
+    Not all entries of the parameter handler that were declared with `has_to_be_set = true` have been set. The following parameters 
 
   General.Precision
   General.dim
diff --git a/tests/parameter_handler/parameter_handler_27.cc b/tests/parameter_handler/parameter_handler_27.cc
new file mode 100644 (file)
index 0000000..b92f38f
--- /dev/null
@@ -0,0 +1,64 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2020 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.md at
+// the top level directory of deal.II.
+//
+// ---------------------------------------------------------------------
+
+
+
+// test ParameterHandler::print_parameters for different formats
+
+#include <deal.II/base/parameter_handler.h>
+
+#include "../tests.h"
+
+int
+main()
+{
+  initlog();
+
+  double      a         = 1.0;
+  bool        some_bool = true;
+  std::string a_string  = "Ciao";
+
+  ParameterHandler prm;
+  prm.enter_subsection("Testing");
+  prm.add_parameter("A double", a);
+  prm.add_parameter("A bool", some_bool);
+  prm.add_parameter("A string", a_string);
+  prm.leave_subsection();
+
+  deallog << "PRM format: " << std::endl
+          << "========================================" << std::endl;
+  prm.print_parameters("output.prm");
+  cat_file("output.prm");
+
+  deallog << "XML format: " << std::endl
+          << "========================================" << std::endl;
+  prm.print_parameters("output.xml");
+  cat_file("output.xml");
+
+  deallog << "JSON format: " << std::endl
+          << "========================================" << std::endl;
+  prm.print_parameters("output.json");
+  cat_file("output.json");
+
+  deallog << "LaTeX format: " << std::endl
+          << "========================================" << std::endl;
+  prm.print_parameters("output.tex");
+  cat_file("output.tex");
+
+  deallog << "Description format: " << std::endl
+          << "========================================" << std::endl;
+  prm.print_parameters("output.dsc", ParameterHandler::Description);
+  cat_file("output.dsc");
+}
diff --git a/tests/parameter_handler/parameter_handler_27.output b/tests/parameter_handler/parameter_handler_27.output
new file mode 100644 (file)
index 0000000..ddc7378
--- /dev/null
@@ -0,0 +1,117 @@
+
+DEAL::PRM format: 
+DEAL::========================================
+# Listing of Parameters
+# ---------------------
+subsection Testing
+  set A bool   = true
+  set A double = 1
+  set A string = Ciao
+end
+
+
+
+DEAL::XML format: 
+DEAL::========================================
+<?xml version="1.0" encoding="utf-8"?>
+<ParameterHandler><Testing><A_20bool><value>true</value><default_value>true</default_value><documentation/><pattern>1</pattern><pattern_description>[Bool]</pattern_description><actions>1</actions></A_20bool><A_20double><value>1</value><default_value>1</default_value><documentation/><pattern>0</pattern><pattern_description>[Double -MAX_DOUBLE...MAX_DOUBLE (inclusive)]</pattern_description><actions>0</actions></A_20double><A_20string><value>Ciao</value><default_value>Ciao</default_value><documentation/><pattern>2</pattern><pattern_description>[Anything]</pattern_description><actions>2</actions></A_20string></Testing></ParameterHandler>
+
+DEAL::JSON format: 
+DEAL::========================================
+{
+    "Testing":
+    {
+        "A_20bool":
+        {
+            "value": "true",
+            "default_value": "true",
+            "documentation": "",
+            "pattern": "1",
+            "pattern_description": "[Bool]",
+            "actions": "1"
+        },
+        "A_20double":
+        {
+            "value": "1",
+            "default_value": "1",
+            "documentation": "",
+            "pattern": "0",
+            "pattern_description": "[Double -MAX_DOUBLE...MAX_DOUBLE (inclusive)]",
+            "actions": "0"
+        },
+        "A_20string":
+        {
+            "value": "Ciao",
+            "default_value": "Ciao",
+            "documentation": "",
+            "pattern": "2",
+            "pattern_description": "[Anything]",
+            "actions": "2"
+        }
+    }
+}
+
+DEAL::LaTeX format: 
+DEAL::========================================
+\subsection{Global parameters}
+\label{parameters:global}
+
+
+
+\subsection{Parameters in section \tt Testing}
+\label{parameters:Testing}
+
+\begin{itemize}
+\item {\it Parameter name:} {\tt A bool}
+\phantomsection\label{parameters:Testing/A bool}
+\label{parameters:Testing/A_20bool}
+
+
+\index[prmindex]{A bool}
+\index[prmindexfull]{Testing!A bool}
+{\it Value:} true
+
+
+{\it Default:} true
+
+
+{\it Possible values:} A boolean value (true or false)
+\item {\it Parameter name:} {\tt A double}
+\phantomsection\label{parameters:Testing/A double}
+\label{parameters:Testing/A_20double}
+
+
+\index[prmindex]{A double}
+\index[prmindexfull]{Testing!A double}
+{\it Value:} 1
+
+
+{\it Default:} 1
+
+
+{\it Possible values:} A floating point number $v$ such that $-\text{MAX\_DOUBLE} \leq v \leq \text{MAX\_DOUBLE}$
+\item {\it Parameter name:} {\tt A string}
+\phantomsection\label{parameters:Testing/A string}
+\label{parameters:Testing/A_20string}
+
+
+\index[prmindex]{A string}
+\index[prmindexfull]{Testing!A string}
+{\it Value:} Ciao
+
+
+{\it Default:} Ciao
+
+
+{\it Possible values:} Any string
+\end{itemize}
+
+DEAL::Description format: 
+DEAL::========================================
+Listing of Parameters:
+
+subsection Testing
+  set A bool    =   A boolean value (true or false)
+  set A double  =   A floating point number v such that -MAX_DOUBLE <= v <= MAX_DOUBLE
+  set A string  =   Any string
+
diff --git a/tests/parameter_handler/parameter_handler_28.cc b/tests/parameter_handler/parameter_handler_28.cc
new file mode 100644 (file)
index 0000000..2972407
--- /dev/null
@@ -0,0 +1,65 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2020 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.md at
+// the top level directory of deal.II.
+//
+// ---------------------------------------------------------------------
+
+
+
+// test ParameterHandler::print_parameters for different formats in
+// combination with Short
+
+#include <deal.II/base/parameter_handler.h>
+
+#include "../tests.h"
+
+int
+main()
+{
+  initlog(1);
+
+  double a = 1.0;
+  double b = 2.0;
+
+  ParameterHandler prm;
+  prm.add_parameter("A double", a, "Documentation for a.");
+  prm.enter_subsection("Section two");
+  prm.add_parameter("Another double", b, "Documentation for b.");
+  prm.leave_subsection();
+
+  const auto style = ParameterHandler::Short;
+
+  deallog << "ShortPRM format: " << std::endl
+          << "========================================" << std::endl;
+  prm.print_parameters("output.prm", style);
+  cat_file("output.prm");
+
+  deallog << "ShortXML format: " << std::endl
+          << "========================================" << std::endl;
+  prm.print_parameters("output.xml", style);
+  cat_file("output.xml");
+
+  deallog << "ShortJSON format: " << std::endl
+          << "========================================" << std::endl;
+  prm.print_parameters("output.json", style);
+  cat_file("output.json");
+
+  deallog << "ShortLaTeX format: " << std::endl
+          << "========================================" << std::endl;
+  prm.print_parameters("output.tex", style);
+  cat_file("output.tex");
+
+  deallog << "Short | Description format: " << std::endl
+          << "========================================" << std::endl;
+  prm.print_parameters("output.dsc", ParameterHandler::Description | style);
+  cat_file("output.dsc");
+}
diff --git a/tests/parameter_handler/parameter_handler_28.output b/tests/parameter_handler/parameter_handler_28.output
new file mode 100644 (file)
index 0000000..d880f73
--- /dev/null
@@ -0,0 +1,73 @@
+
+DEAL::ShortPRM format: 
+DEAL::========================================
+set A double = 1
+subsection Section two
+  set Another double = 2
+end
+
+DEAL::ShortXML format: 
+DEAL::========================================
+<?xml version="1.0" encoding="utf-8"?>
+<ParameterHandler><A_20double>1</A_20double><Section_20two><Another_20double>2</Another_20double></Section_20two></ParameterHandler>
+
+DEAL::ShortJSON format: 
+DEAL::========================================
+{
+    "A_20double": "1",
+    "Section_20two": {
+        "Another_20double": "2"
+    }
+}
+
+DEAL::ShortLaTeX format: 
+DEAL::========================================
+\subsection{Global parameters}
+\label{parameters:global}
+
+
+\begin{itemize}
+\item {\it Parameter name:} {\tt A double}
+\phantomsection\label{parameters:A double}
+\label{parameters:A_20double}
+
+
+\index[prmindex]{A double}
+\index[prmindexfull]{A double}
+{\it Value:} 1
+
+
+{\it Default:} 1
+
+
+\end{itemize}
+
+
+
+\subsection{Parameters in section \tt Section two}
+\label{parameters:Section_20two}
+
+\begin{itemize}
+\item {\it Parameter name:} {\tt Another double}
+\phantomsection\label{parameters:Section two/Another double}
+\label{parameters:Section_20two/Another_20double}
+
+
+\index[prmindex]{Another double}
+\index[prmindexfull]{Section two!Another double}
+{\it Value:} 2
+
+
+{\it Default:} 2
+
+
+\end{itemize}
+
+DEAL::Short | Description format: 
+DEAL::========================================
+Listing of Parameters:
+
+set A double  =   A floating point number v such that -MAX_DOUBLE <= v <= MAX_DOUBLE
+subsection Section two
+  set Another double  =   A floating point number v such that -MAX_DOUBLE <= v <= MAX_DOUBLE
+

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.