Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
amdis
amdis-core
Commits
0756da59
Commit
0756da59
authored
Jan 22, 2018
by
Praetorius, Simon
Browse files
Initfile with Dune::ParameterTree
parent
5da43678
Changes
2
Hide whitespace changes
Inline
Side-by-side
dune/amdis/Initfile.cpp
View file @
0756da59
...
...
@@ -9,7 +9,7 @@
#include
<unistd.h>
#endif
#include
<
boost/property_tree/json_
parser.h
pp
>
#include
<
dune/common/parametertree
parser.h
h
>
// a parser for arithmetic expressions
// #include <muParser.h>
...
...
@@ -56,8 +56,7 @@ namespace AMDiS
test_exit
(
file_exists
(
fn
),
"init-file '"
,
fn
,
"' cannot be opened for reading"
);
using
boost
::
property_tree
::
json_parser
::
read_json
;
read_json
(
fn
,
pt
);
Dune
::
ParameterTreeParser
::
readINITree
(
fn
,
pt
);
}
...
...
dune/amdis/Initfile.hpp
View file @
0756da59
...
...
@@ -7,15 +7,15 @@
#include
<list>
#include
<vector>
#define BOOST_BIND_NO_PLACEHOLDERS
#include
<boost/lexical_cast.hpp>
#include
<boost/numeric/conversion/cast.hpp>
#include
<boost/tokenizer.hpp>
#include
<boost/property_tree/ptree.hpp>
#include
<dune/common/fvector.hh>
#include
<dune/common/parametertree.hh>
// #include <boost/property_tree/ptree.hpp>
#include
<dune/common/std/optional.hh>
#include
<dune/amdis/Output.hpp>
#include
<dune/amdis/common/Math.hpp>
...
...
@@ -197,13 +197,15 @@ namespace AMDiS
template
<
class
T
>
static
boost
::
optional
<
T
>
get
(
std
::
string
tag
)
static
Dune
::
Std
::
optional
<
T
>
get
(
std
::
string
key
)
{
using
path
=
boost
::
property_tree
::
ptree
::
path_type
;
replaceAll
(
tag
,
"->"
,
">"
);
auto
tagPath
=
path
(
tag
,
'>'
);
return
singlett
().
pt
.
get_optional
<
T
>
(
tagPath
);
replaceAll
(
key
,
"->"
,
"."
);
try
{
return
singlett
().
pt
.
get
<
T
>
(
key
);
}
catch
(...)
{
return
Dune
::
Std
::
nullopt
;
}
}
...
...
@@ -230,10 +232,9 @@ namespace AMDiS
if
(
debugInfo
==
-
1
)
debugInfo
=
singlett
().
getMsgInfo
();
using
path
=
boost
::
property_tree
::
ptree
::
path_type
;
replaceAll
(
tag
,
"->"
,
">"
);
auto
tagPath
=
path
(
tag
,
'>'
);
singlett
().
pt
.
put
(
tagPath
,
value
);
replaceAll
(
tag
,
"->"
,
"."
);
// auto tagPath = path(tag, '>');
// singlett().pt.put(tagPath, value);
// update msg parameters msgInfo, msgWait, paramInfo
singlett
().
getInternalParameters
();
...
...
@@ -303,8 +304,8 @@ namespace AMDiS
int
paramInfo
=
1
;
int
breakOnMissingTag
=
0
;
///
boost:property_t
ree to read/store parameter values
boost
::
property_tree
::
pt
ree
pt
;
///
ParameterT
ree to read/store parameter values
Dune
::
ParameterT
ree
pt
;
};
using
Parameters
=
Initfile
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment