diff options
Diffstat (limited to '')
-rw-r--r-- | src/tests/archive2.cpp | 95 |
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 | |||
5 | int giId = 0; | ||
6 | |||
7 | class A : public Bu::Archival | ||
8 | { | ||
9 | public: | ||
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 | |||
27 | class B : public Bu::Archival | ||
28 | { | ||
29 | public: | ||
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 | |||
53 | class C : public Bu::Archival | ||
54 | { | ||
55 | public: | ||
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 | |||
81 | void 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 | |||
90 | int main() | ||
91 | { | ||
92 | write(); | ||
93 | |||
94 | } | ||
95 | |||