]> https://gitweb.dealii.org/ - dealii.git/commitdiff
fix write json of demangled alias parameters 13917/head
authorMagdalena Schreter <schreter.magdalena@gmail.com>
Mon, 6 Jun 2022 16:55:32 +0000 (18:55 +0200)
committerMagdalena Schreter <schreter.magdalena@gmail.com>
Mon, 6 Jun 2022 17:08:25 +0000 (19:08 +0200)
source/base/parameter_handler.cc
tests/parameter_handler/parameter_handler_write_json.cc
tests/parameter_handler/parameter_handler_write_json.output

index f22211794f21cb1da9741bb8335c38bbc4b48676..316e40271d78017e965271fd16c977d6e388234d 100644 (file)
@@ -335,18 +335,18 @@ namespace
 
   /**
    * Demangle all parameters recursively and attach them to @p tree_out.
-   * @p parameter_node indicates, whether a given node @p tree_in
-   * is a parameter node (as opposed to being a subsection or alias
-   * node).
+   * @p is_parameter_or_alias_node indicates, whether a given node
+   * @p tree_in is a parameter node or an alias node (as opposed to being
+   * a subsection).
    */
   void
   recursively_demangle(const boost::property_tree::ptree &tree_in,
                        boost::property_tree::ptree &      tree_out,
-                       const bool parameter_node = false)
+                       const bool is_parameter_or_alias_node = false)
   {
     for (const auto &p : tree_in)
       {
-        if (parameter_node)
+        if (is_parameter_or_alias_node)
           {
             tree_out.put_child(p.first, p.second);
           }
@@ -357,7 +357,10 @@ namespace
             if (const auto val = p.second.get_value_optional<std::string>())
               temp.put_value<std::string>(*val);
 
-            recursively_demangle(p.second, temp, is_parameter_node(p.second));
+            recursively_demangle(p.second,
+                                 temp,
+                                 is_parameter_node(p.second) ||
+                                   is_alias_node(p.second));
             tree_out.put_child(demangle(p.first), temp);
           }
       }
index 86422f080e515818ac0be7c0d5635a1ad4c51e8f..c81e6dd24db1902bd210874c4b87541d65553ef9 100644 (file)
@@ -16,7 +16,8 @@
 
 
 // check ParameterHandler::print_parameters (..., JSON). have a few
-// names that contain all sorts of weird (for JSON) characters
+// names that contain all sorts of weird (for JSON) characters and
+// aliased parameters.
 
 #include <deal.II/base/parameter_handler.h>
 
@@ -31,6 +32,7 @@ main()
   ParameterHandler prm;
   prm.declare_entry("int1", "1", Patterns::Integer(), "doc 1");
   prm.declare_entry("int2", "2", Patterns::Integer(), "doc 2");
+  prm.declare_alias("int2", "int2_alias");
   prm.enter_subsection("ss1");
   {
     prm.declare_entry("double 1", "1.234", Patterns::Double(), "doc 3");
@@ -38,6 +40,7 @@ main()
     prm.enter_subsection("ss2");
     {
       prm.declare_entry("double 2", "4.321", Patterns::Double(), "doc 4");
+      prm.declare_alias("double 2", "double 2 alias");
     }
     prm.leave_subsection();
   }
index ab55c98c3e40a83222e87d55e18dbaf5de25da69..e4400657f88644423a0368265cc800081da8b93f 100644 (file)
         "pattern": "1",
         "pattern_description": "[Integer range -2147483648...2147483647 (inclusive)]"
     },
+    "int2_alias":
+    {
+        "alias": "int2",
+        "deprecation_status": "false"
+    },
     "Testing%testing":
     {
         "double+double":
                 "documentation": "doc 4",
                 "pattern": "3",
                 "pattern_description": "[Double -MAX_DOUBLE...MAX_DOUBLE (inclusive)]"
+            },
+            "double 2 alias":
+            {
+                "alias": "double 2",
+                "deprecation_status": "false"
             }
         }
     }
 {
     "int1": "1",
     "int2": "2",
+    "int2_alias":
+    {
+        "alias": "int2",
+        "deprecation_status": "false"
+    },
     "Testing%testing":
     {
         "double+double": "6.1415926",
         "double 1": "1.234",
         "ss2":
         {
-            "double 2": "4.321"
+            "double 2": "4.321",
+            "double 2 alias":
+            {
+                "alias": "double 2",
+                "deprecation_status": "false"
+            }
         }
     }
 }

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.