]> https://gitweb.dealii.org/ - dealii.git/commitdiff
add test for parsing Map pattern in ParameterHandler 4143/head
authorTimo Heister <timo.heister@gmail.com>
Thu, 30 Mar 2017 13:53:45 +0000 (09:53 -0400)
committerTimo Heister <timo.heister@gmail.com>
Thu, 30 Mar 2017 16:44:53 +0000 (12:44 -0400)
I think this makes for a nice usage example.

tests/parameter_handler/parameter_handler_13.cc
tests/parameter_handler/parameter_handler_13.output

index 5802caf13f56cf32547d324714924a51e7afc547..994fd4af3eb1bbc2ed8d6247733cbc7023d32520 100644 (file)
@@ -34,6 +34,16 @@ void check (const char *p)
   prm.read_input (in);
 
   deallog << "test_13=" << prm.get ("test_13") << std::endl;
+
+  const std::vector<std::string> split_entries = Utilities::split_string_list (prm.get ("test_13"), ',');
+  for (const std::string &entry : split_entries)
+    {
+      const std::vector<std::string> parts = Utilities::split_string_list (entry, ':');
+      const std::string key = parts[0];
+      const std::string value = parts[1];
+      deallog << " found key = '" << key << "' value = '" << value << "'" << std::endl;
+    }
+
 }
 
 
index 360228008cc33d575de8b96e8c69e634d648c16e..1621b8d66ab3223365e2349e40aabcb78292efa5 100644 (file)
@@ -1,2 +1,5 @@
 
 DEAL::test_13=1 : b, 0: a, 1 : c
+DEAL:: found key = '1' value = 'b'
+DEAL:: found key = '0' value = 'a'
+DEAL:: found key = '1' value = 'c'

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.