1 #include <boost/archive/text_oarchive.hpp>
2 #include <boost/archive/text_iarchive.hpp>
3 #include <boost/serialization/base_object.hpp>
4 #include <boost/serialization/utility.hpp>
5 #include <boost/serialization/version.hpp>
6 #include <boost/serialization/split_member.hpp>
7 #include <boost/serialization/export.hpp>
15 #include "ser/s_caosVar.h"
16 #include "caosScript.h"
17 #include "ser/s_caosScript.h"
18 #include "ser/s_genome.h"
27 friend class boost::serialization::access
;
29 template<class Archive
>
30 void serialize(Archive
&ar
, const unsigned int version
) {
31 ar
& BOOST_SERIALIZATION_NVP(i
);
35 genomeFile
*tryLoadGenome() {
39 std::ifstream
genestream("data/Genetics/norn.bengal46.gen.brain.gen", std::ios::binary
| std::ios::in
);
40 // std::ifstream notestream("data/Genetics/norn.bengal46.gen.brain.gno", std::ios::binary | std::ios::in);
41 genestream
>> std::noskipws
>> *f
;
42 // f->readNotes(notestream);
44 std::cout
<< "pre-save, loaded " << f
->genes
.size() << " genes." << std::endl
;
45 } catch (std::exception
&e
) {
46 std::cerr
<< "Warning, genome load failed, skipping that test." << std::endl
;
47 std::cerr
<< "Exception was: " << e
.what() << std::endl
;
55 int main(int argc
, char **argv
) {
59 std::ofstream
ofs("sertest.dat");
60 caosVar null
, str
, intv
, floatv
;
61 caosScript
scr("c3", "<test input>");
64 str
.setString("Hello, world!");
68 std::istringstream
ss("inst sets va00 \"hello world\\n\" outv 42 outs \"\\n\" outs va00 slow stop rscr");
73 std::ifstream
ifs(argv
[1]);
79 boost::archive::text_oarchive
oa(ofs
);
81 oa
<< (const caosVar
&)null
<< (const caosVar
&)str
<< (const caosVar
&)intv
<< (const caosVar
&)floatv
;
82 oa
<< (const caosScript
&)scr
;
83 genomeFile
*f
= tryLoadGenome();
84 oa
<< (const genomeFile
* const)f
;
89 caosVar nnull
, nstr
, nintv
, nfloatv
;
93 std::ifstream
ifs("sertest.dat", std::ios::binary
);
94 boost::archive::text_iarchive
ia(ifs
);
96 std::cout
<< "v.i = " << v
.i
<< std::endl
;
97 ia
>> nnull
>> nstr
>> nintv
>> nfloatv
;
103 std::cerr
<< "Warning, no genome class found in output. Load failed maybe?" << std::endl
;
105 std::cout
<< "f->genes.size() = " << f
->genes
.size() << std::endl
;
111 #define D(x) std::cout << #x << " = " << x.dump() << std::endl
113 #define D(x) do { } while (0)
115 D(nnull
); D(nstr
); D(nintv
); D(nfloatv
);
116 std::cout
<< si
.installer
->dump() << std::endl
;