VPTissue Reference Manual
PTreeUtils.h
Go to the documentation of this file.
1 #ifndef PTREEUTILS_H_INCLUDED
2 #define PTREEUTILS_H_INCLUDED
3 /*
4  * Copyright 2011-2016 Universiteit Antwerpen
5  *
6  * Licensed under the EUPL, Version 1.1 or as soon they will be approved by
7  * the European Commission - subsequent versions of the EUPL (the "Licence");
8  * You may not use this work except in compliance with the Licence.
9  * You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl5
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the Licence is distributed on an "AS IS" basis,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the Licence for the specific language governing
15  * permissions and limitations under the Licence.
16  */
22 #include <boost/property_tree/ptree_fwd.hpp>
23 
24 #include <list>
25 #include <set>
26 #include <string>
27 #include <utility>
28 
29 namespace SimPT_Sim {
30 namespace Util {
31 
36 {
37 public:
45  static void CopyNonExistingChildren(
46  const boost::property_tree::ptree& src,
47  boost::property_tree::ptree& dst,
48  const std::set<std::string>& ignore = std::set<std::string>());
49 
50  static void CopyStructure(
51  const boost::property_tree::ptree& src,
52  boost::property_tree::ptree& dst,
53  const std::string& fill_value,
54  const std::set<std::string>& ignore = std::set<std::string>());
55 
63  static void RemoveNonExistingChildren(
64  const boost::property_tree::ptree& src,
65  boost::property_tree::ptree& dst,
66  const std::set<std::string>& ignore = std::set<std::string>());
67 
75  static void FillPTree(boost::property_tree::ptree& pt1, const boost::property_tree::ptree& pt2);
76 
85  static std::list<std::pair<std::string, std::string>>
86  Flatten(const boost::property_tree::ptree& pt, bool indexedArray = false, const std::string& path = "");
87 
96  static const boost::property_tree::ptree&
97  GetIndexedChild(const boost::property_tree::ptree& pt, const std::string& path);
98 
108  static void PutIndexedChild(
109  boost::property_tree::ptree& pt,
110  const std::string& path,
111  const boost::property_tree::ptree& child);
112 };
113 
114 } // namespace
115 } // namespace
116 
117 #endif // include-guard
static const boost::property_tree::ptree & GetIndexedChild(const boost::property_tree::ptree &pt, const std::string &path)
Returns a reference to the subptree in the given ptree, taking indexes of array-elements (of PTreeUti...
Definition: PTreeUtils.cpp:152
static void RemoveNonExistingChildren(const boost::property_tree::ptree &src, boost::property_tree::ptree &dst, const std::set< std::string > &ignore=std::set< std::string >())
Removes every node in 'destination' ptree if that node doesn't exist in 'source' ptree.
Definition: PTreeUtils.cpp:235
static void FillPTree(boost::property_tree::ptree &pt1, const boost::property_tree::ptree &pt2)
Fill the first ptree with the second ptree.
Definition: PTreeUtils.cpp:111
A collection of functions for manipulating the structure of ptrees.
Definition: PTreeUtils.h:35
static void PutIndexedChild(boost::property_tree::ptree &pt, const std::string &path, const boost::property_tree::ptree &child)
Put the child in the given ptree on the given path.
Definition: PTreeUtils.cpp:193
Namespace for the core simulator.
static std::list< std::pair< std::string, std::string > > Flatten(const boost::property_tree::ptree &pt, bool indexedArray=false, const std::string &path="")
Flattens a ptree from a given path.
Definition: PTreeUtils.cpp:130
static void CopyNonExistingChildren(const boost::property_tree::ptree &src, boost::property_tree::ptree &dst, const std::set< std::string > &ignore=std::set< std::string >())
Copies every node from 'source' ptree if that node doesn't exist in 'destination' ptree...
Definition: PTreeUtils.cpp:68