5 * Created by Bryan Donlan on Sun 21 May 2006
6 * Copyright (c) 2006 Bryan Donlan. All rights reserved.
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
20 #include <boost/archive/text_oarchive.hpp>
21 #include <boost/archive/text_iarchive.hpp>
24 //#include "ser/s_map.h"
25 #include "ser/s_Scriptorium.h"
26 #include "serialization.h"
31 // Note: this file may require an exorbitant amount of RAM to compile
32 // You have been warned.
34 void caosVM::c_SERS_MAPP() {
35 VM_PARAM_STRING(filename
)
37 std::ofstream
outf(filename
.c_str(), std::ios::binary
);
39 boost::archive::text_oarchive
oa(outf
);
40 oa
<< (const Map
&)world
.map
;
41 std::string
test("TEST MARKER ETC");
42 oa
<< (const std::string
&) test
;
48 void caosVM::c_SERL_MAPP() {
49 VM_PARAM_STRING(filename
);
51 std::ifstream
inf(filename
.c_str(), std::ios::binary
);
53 boost::archive::text_iarchive
ia(inf
);
56 ia
>> world
.map
; // if this fails the game will explode
57 } catch (std::exception
&e
) {
58 std::cerr
<< "Deserialization failed; game is in an unknown state!" << std::endl
;
59 std::cerr
<< "Exception was: " << e
.what() << std::endl
;
60 std::cerr
<< "Aborting..." << std::endl
;
67 void caosVM::c_SERS_SCRP() {
68 VM_PARAM_STRING(filename
);
69 std::ofstream
ofs(filename
.c_str(), std::ios::binary
);
71 boost::archive::text_oarchive
oa(ofs
);
72 oa
<< (const Scriptorium
&)world
.scriptorium
;
77 void caosVM::c_SERL_SCRP() {
78 VM_PARAM_STRING(filename
);
79 std::ifstream
inf(filename
.c_str(), std::ios::binary
);
81 boost::archive::text_iarchive
ia(inf
);
83 ia
>> world
.scriptorium
; // if this fails the game will explode
84 } catch (std::exception
&e
) {
85 std::cerr
<< "Deserialization failed; game is in an unknown state!" << std::endl
;
86 std::cerr
<< "Exception was: " << e
.what() << std::endl
;
87 std::cerr
<< "Aborting..." << std::endl
;