aboutsummaryrefslogtreecommitdiff
path: root/src/tests
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/archivetags.cpp73
1 files changed, 73 insertions, 0 deletions
diff --git a/src/tests/archivetags.cpp b/src/tests/archivetags.cpp
new file mode 100644
index 0000000..f0587fd
--- /dev/null
+++ b/src/tests/archivetags.cpp
@@ -0,0 +1,73 @@
1
2class SubThing
3{
4public:
5 SubThing();
6 virtual ~SubThing();
7
8 Bu::Blob bData;
9 Bu::Text tName;
10};
11
12class Something
13{
14pubilc:
15 Something();
16 virtual ~Something();
17
18 int iAge;
19 int iSize;
20 int *aiNumber;
21 SubThing xThing;
22};
23
24Bu::Archive &operator<<( Bu::Archive &ar, const SubThing &st )
25{
26 Bu::Archive::Dictionary ds( ar );
27
28 return ar
29 << ar.tag("data") << st.bData
30 << ar.tag("name") << st.tName;
31}
32
33Bu::Archive &operator>>( Bu::Archive &ar, SubThing &st )
34{
35 Bu::Archive::Dictionary ds( ar );
36
37 return ar
38 >> ar.tag("data") >> st.bData
39 >> ar.tag("name") >> st.tName;
40}
41
42Bu::Archive &operator<<( Bu::Archive &ar, const Something &st )
43{
44 Bu::Archive::Dictionary ds( ar );
45 ar << ar.tag("age") << st.iAge;
46
47 ar.startList("number", st.iSize );
48 for( int j = 0; j < st.iSize; j++ )
49 {
50 ar << st.aiNumber[j];
51 }
52 ar.endList();
53 ar << ar.tag("thing") << st.xThing;
54 return ar;
55}
56
57Bu::Archive &operator>>( Bu::Archive &ar, Something &st )
58{
59 Bu::Archive::Dictionary ds( ar );
60 ar >> ar.tag("age") >> st.iAge;
61
62 ar.startList("number");
63 int iSize = ar.getListSize();
64 for( int j = 0; j < iSize; j++ )
65 {
66 ar >> st.aiNumber[j];
67 }
68 ar.endList();
69
70 ar >> ar.tag("thing") >> st.xThing;
71 return ar;
72}
73