VPTissue Reference Manual
XmlGzExporter.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2011-2016 Universiteit Antwerpen
3  *
4  * Licensed under the EUPL, Version 1.1 or as soon they will be approved by
5  * the European Commission - subsequent versions of the EUPL (the "Licence");
6  * You may not use this work except in compliance with the Licence.
7  * You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl5
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the Licence is distributed on an "AS IS" basis,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the Licence for the specific language governing
13  * permissions and limitations under the Licence.
14  */
20 #include "../../cpp_simptshell/exporters/XmlGzExporter.h"
21 
22 #include <fstream>
23 #include "fileformats/PTreeFile.h"
24 #include "sim/Sim.h"
25 
26 namespace SimPT_Shell {
27 
28 using namespace std;
29 using namespace SimPT_Sim::Util;
30 using namespace SimPT_Sim;
31 
32 bool XmlGzExporter::Export(shared_ptr<Sim> sim, const string& file_path, bool overwrite)
33 {
34  if (!overwrite && ifstream(file_path).good()) {
35  return false; // Don't overwrite
36  }
37 
38  bool status = false;
39  try {
40  PTreeFile::WriteXmlGz(file_path, sim->ToPtree());
41  }
42  catch(...) {
43  status = false;
44  }
45  return status;
46 }
47 
49 {
50  return "xml.gz";
51 }
52 
53 } // namespace
STL namespace.
Interface for PTreeFile.
Namespace for miscellaneous utilities.
Definition: PTreeFile.cpp:44
Namespace for SimPT shell package.
Definition: Client.cpp:50
static std::string GetFileExtension()
File extension associated with this export format.
static bool Export(std::shared_ptr< SimPT_Sim::Sim > sim, const std::string &filename, bool overwrite=true)
Export state to xml.
Namespace for the core simulator.
Sim, the actual simulator.