summaryrefslogtreecommitdiff
path: root/src/tests/archive2.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests/archive2.cpp')
-rw-r--r--src/tests/archive2.cpp95
1 files changed, 95 insertions, 0 deletions
diff --git a/src/tests/archive2.cpp b/src/tests/archive2.cpp
new file mode 100644
index 0000000..6d3c2c1
--- /dev/null
+++ b/src/tests/archive2.cpp
@@ -0,0 +1,95 @@
1#include "bu/archive.h"
2#include "bu/archival.h"
3#include "bu/file.h"
4
5int giId = 0;
6
7class A : public Bu::Archival
8{
9public:
10 A() :
11 iId( giId++ )
12 {
13 }
14
15 virtual ~A()
16 {
17 }
18
19 virtual void archive( Bu::Archive &ar )
20 {
21 ar && iId;
22 }
23
24 int iId;
25};
26
27class B : public Bu::Archival
28{
29public:
30 B() :
31 iId( giId++ ),
32 a1( new A ),
33 a2( new A )
34 {
35 }
36
37 virtual ~B()
38 {
39 delete a1;
40 delete a2;
41 }
42
43 virtual void archive( Bu::Archive &ar )
44 {
45 //ar && iId && a1 && a2;
46 ar << iId << a1 << a2;
47 }
48
49 int iId;
50 A *a1, *a2;
51};
52
53class C : public Bu::Archival
54{
55public:
56 C() :
57 iId( giId++ ),
58 a( new A ),
59 b( new B )
60 {
61 }
62
63 virtual ~C()
64 {
65 delete a;
66 delete b;
67 }
68
69 virtual void archive( Bu::Archive &ar )
70 {
71 //ar && iId && a && b;
72 ar << iId;
73 ar << a << b;
74 }
75
76 int iId;
77 A *a;
78 B *b;
79};
80
81void write()
82{
83 C *c = new C;
84
85 Bu::File f( "test.archive", "wb");
86 Bu::Archive ar( f, Bu::Archive::save );
87 ar << c;
88}
89
90int main()
91{
92 write();
93
94}
95