VPTissue Reference Manual
PTreeFile.h
Go to the documentation of this file.
1 #ifndef PTREE_FILE_H_INCLUDED
2 #define PTREE_FILE_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.hpp>
23 #include <boost/property_tree/xml_parser.hpp>
24 #include <string>
25 
26 namespace SimPT_Sim {
27 namespace Util {
28 
32 class PTreeFile
33 {
34 public:
36  static void Compress(const std::string& in_path, const std::string& out_path);
37 
39  static void Decompress(const std::string& in_path, const std::string& out_path);
40 
42  static bool IsGzipped(const std::string& path);
43 
45  static constexpr bool IsBoostGzipAvailable();
46 
48  static bool IsPTreeFile(const std::string& path);
49 
51  static std::string GetBaseNameExcludingLabel(const std::string& path);
52 
54  static std::string GetBaseNameIncludingLabel(const std::string& path);
55 
57  static std::string GetCompleteSuffix(const std::string& path);
58 
60  static std::string GetLabel(const std::string& path);
61 
63  static void Read(const std::string& path, boost::property_tree::ptree& pt);
64 
66  static void ReadXml(const std::string& path, boost::property_tree::ptree& pt);
67 
69  static void ReadXmlGz(const std::string& path, boost::property_tree::ptree& pt);
70 
72  static void Write(const std::string& path, const boost::property_tree::ptree& pt);
73 
75  static void WriteXml(const std::string& path, const boost::property_tree::ptree& pt);
76 
78  static void WriteXmlGz(const std::string& path, const boost::property_tree::ptree& pt);
79 };
80 
81 } // namespace
82 } // namespace
83 
84 #endif // end-of-include-guard
Utility interface for dealing with ptree xml or xml.gz files.
Definition: PTreeFile.h:32
static std::string GetBaseNameExcludingLabel(const std::string &path)
Base name excluding label (label encodes time step = chars from last "_" to first "...
Definition: PTreeFile.cpp:73
static constexpr bool IsBoostGzipAvailable()
Signal availability of boost iostreams with gzip capability.
Definition: PTreeFile.cpp:243
Namespace for the core simulator.
static std::string GetBaseNameIncludingLabel(const std::string &path)
Base name including label (label encodes time step = chars from last "_" to first "...
Definition: PTreeFile.cpp:90
static bool IsPTreeFile(const std::string &path)
Indicates whether the file has the appropriate extension.
Definition: PTreeFile.cpp:53
static std::string GetCompleteSuffix(const std::string &path)
Return complete suffix (everything following the first ".").
Definition: PTreeFile.cpp:60