PropertyTree.hpp
Go to the documentation of this file.
1/*
2 Copyright 2019 SINTEF Digital, Mathematics and Cybernetics.
3
4 This file is part of the Open Porous Media project (OPM).
5
6 OPM is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 OPM is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with OPM. If not, see <http://www.gnu.org/licenses/>.
18*/
19
20#ifndef OPM_PROPERTYTREE_HEADER_INCLUDED
21#define OPM_PROPERTYTREE_HEADER_INCLUDED
22
23#include <iosfwd>
24#include <memory>
25#include <optional>
26
27namespace boost {
28namespace property_tree {
29 template<class T1, class T2, class T3> class basic_ptree;
31}
32}
33
34namespace Opm
35{
36
38public:
40 PropertyTree(const std::string& jsonFile);
43
44 template<class T>
45 void put(const std::string& key, const T& data);
46
47 template<class T>
48 T get(const std::string& key) const;
49
50 template<class T>
51 T get(const std::string& key, const T& defValue) const;
52
53 PropertyTree get_child(const std::string& key) const;
54
55 std::optional<PropertyTree> get_child_optional(const std::string& key) const;
56
58
59 void write_json(std::ostream& os, bool pretty) const;
60
61protected:
63
64 std::unique_ptr<boost::property_tree::ptree> tree_;
65};
66
67
68} // namespace Opm
69
70#endif // OPM_PROPERTYTREE_HEADER_INCLUDED
Definition: PropertyTree.hpp:37
PropertyTree & operator=(const PropertyTree &tree)
T get(const std::string &key, const T &defValue) const
std::unique_ptr< boost::property_tree::ptree > tree_
Definition: PropertyTree.hpp:64
void write_json(std::ostream &os, bool pretty) const
T get(const std::string &key) const
PropertyTree(const boost::property_tree::ptree &tree)
PropertyTree(const PropertyTree &tree)
std::optional< PropertyTree > get_child_optional(const std::string &key) const
void put(const std::string &key, const T &data)
PropertyTree get_child(const std::string &key) const
PropertyTree(const std::string &jsonFile)
Definition: PropertyTree.hpp:29
Definition: BlackoilPhases.hpp:27
Definition: PropertyTree.hpp:27