diff options
author | Mike Buland <mbuland@penny-arcade.com> | 2022-04-20 14:04:47 -0700 |
---|---|---|
committer | Mike Buland <mbuland@penny-arcade.com> | 2022-04-20 14:04:47 -0700 |
commit | fd56cdd21a7c9c944ad189cf91ff24d3c2b0f975 (patch) | |
tree | f16f7e7f54399ef9c753beb87069eed8122dbccb /src/tests | |
parent | d10e6a5ca0905f0ef2836cd98aebfb48e7f1e8a3 (diff) | |
download | libbu++-fd56cdd21a7c9c944ad189cf91ff24d3c2b0f975.tar.gz libbu++-fd56cdd21a7c9c944ad189cf91ff24d3c2b0f975.tar.bz2 libbu++-fd56cdd21a7c9c944ad189cf91ff24d3c2b0f975.tar.xz libbu++-fd56cdd21a7c9c944ad189cf91ff24d3c2b0f975.zip |
Gradually moving to better archive structure.
It's dragging other new API changes along with it, including use of Blob
and Text.
Diffstat (limited to 'src/tests')
-rw-r--r-- | src/tests/archivetags.cpp | 73 |
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 | |||
2 | class SubThing | ||
3 | { | ||
4 | public: | ||
5 | SubThing(); | ||
6 | virtual ~SubThing(); | ||
7 | |||
8 | Bu::Blob bData; | ||
9 | Bu::Text tName; | ||
10 | }; | ||
11 | |||
12 | class Something | ||
13 | { | ||
14 | pubilc: | ||
15 | Something(); | ||
16 | virtual ~Something(); | ||
17 | |||
18 | int iAge; | ||
19 | int iSize; | ||
20 | int *aiNumber; | ||
21 | SubThing xThing; | ||
22 | }; | ||
23 | |||
24 | Bu::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 | |||
33 | Bu::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 | |||
42 | Bu::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 | |||
57 | Bu::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 | |||