BCESolve
bceserialization.hpp
1// This file is part of the BCESolve library for games of incomplete
2// information
3// Copyright (C) 2022 Benjamin A. Brooks
4//
5// BCESolve free software: you can redistribute it and/or modify it
6// under the terms of the GNU General Public License as published by
7// the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
9//
10// BCESolve is distributed in the hope that it will be useful, but
11// WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13// General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with this program. If not, see
17// <http://www.gnu.org/licenses/>.
18//
19// Benjamin A. Brooks
20// ben@benjaminbrooks.net
21// Chicago, IL
22
23#ifndef BCESERIALIZATION_HPP
24#define BCESERIALIZATION_HPP
25
26#include "bcedata.hpp"
27#include <boost/archive/text_iarchive.hpp>
28#include <boost/archive/text_oarchive.hpp>
29#include <boost/serialization/utility.hpp>
30
31void saveBCEData(const BCEData & data, const char* filename)
32{
33 ofstream ofs(filename);
34
35 if (ofs.good())
36 {
37 boost::archive::text_oarchive oa(ofs);
38 oa << data;
39 }
40 else
42}
43
44void loadBCEData(BCEData & data, const char* filename)
45{
46 ifstream ifs(filename);
47
48 if (ifs.good())
49 {
50 boost::archive::text_iarchive ia(ifs);
51 ia >> data;
52 }
53 else
55}
56
57#endif
Exception class for BCESolve.
Definition: bceexception.hpp:33
@ FailedOpen
Definition: bceexception.hpp:46