aboutsummaryrefslogtreecommitdiff
path: root/src/archive.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/archive.cpp (renamed from src/old/serializer.cpp)103
1 files changed, 51 insertions, 52 deletions
diff --git a/src/old/serializer.cpp b/src/archive.cpp
index 636224e..5f5145c 100644
--- a/src/old/serializer.cpp
+++ b/src/archive.cpp
@@ -1,152 +1,150 @@
1#include "serializer.h" 1#include "archive.h"
2#include "serializable.h"
3#include <list>
4 2
5Serializer::Serializer(bool bLoading): 3Bu::Archive::Archive(bool bLoading):
6 bLoading(bLoading) 4 bLoading(bLoading)
7{ 5{
8} 6}
9Serializer::~Serializer() 7Bu::Archive::~Archive()
10{ 8{
11} 9}
12 10
13bool Serializer::isLoading() 11bool Bu::Archive::isLoading()
14{ 12{
15 return bLoading; 13 return bLoading;
16} 14}
17Serializer &Serializer::operator<<(bool p) 15Bu::Archive &Bu::Archive::operator<<(bool p)
18{ 16{
19 write( &p, sizeof(p) ); 17 write( &p, sizeof(p) );
20 return *this; 18 return *this;
21} 19}
22Serializer &Serializer::operator<<(int8_t p) 20Bu::Archive &Bu::Archive::operator<<(int8_t p)
23{ 21{
24 write( &p, sizeof(p) ); 22 write( &p, sizeof(p) );
25 return *this; 23 return *this;
26} 24}
27Serializer &Serializer::operator<<(int16_t p) 25Bu::Archive &Bu::Archive::operator<<(int16_t p)
28{ 26{
29 write( &p, sizeof(p) ); 27 write( &p, sizeof(p) );
30 return *this; 28 return *this;
31} 29}
32Serializer &Serializer::operator<<(int32_t p) 30Bu::Archive &Bu::Archive::operator<<(int32_t p)
33{ 31{
34 write( &p, sizeof(p) ); 32 write( &p, sizeof(p) );
35 return *this; 33 return *this;
36} 34}
37Serializer &Serializer::operator<<(int64_t p) 35Bu::Archive &Bu::Archive::operator<<(int64_t p)
38{ 36{
39 write( &p, sizeof(p) ); 37 write( &p, sizeof(p) );
40 return *this; 38 return *this;
41} 39}
42Serializer &Serializer::operator<<(uint8_t p) 40Bu::Archive &Bu::Archive::operator<<(uint8_t p)
43{ 41{
44 write( &p, sizeof(p) ); 42 write( &p, sizeof(p) );
45 return *this; 43 return *this;
46} 44}
47Serializer &Serializer::operator<<(uint16_t p) 45Bu::Archive &Bu::Archive::operator<<(uint16_t p)
48{ 46{
49 write( &p, sizeof(p) ); 47 write( &p, sizeof(p) );
50 return *this; 48 return *this;
51} 49}
52Serializer &Serializer::operator<<(uint32_t p) 50Bu::Archive &Bu::Archive::operator<<(uint32_t p)
53{ 51{
54 write( &p, sizeof(p) ); 52 write( &p, sizeof(p) );
55 return *this; 53 return *this;
56} 54}
57Serializer &Serializer::operator<<(uint64_t p) 55Bu::Archive &Bu::Archive::operator<<(uint64_t p)
58{ 56{
59 write( &p, sizeof(p) ); 57 write( &p, sizeof(p) );
60 return *this; 58 return *this;
61} 59}
62Serializer &Serializer::operator<<(long p) 60Bu::Archive &Bu::Archive::operator<<(long p)
63{ 61{
64 write( &p, sizeof(p) ); 62 write( &p, sizeof(p) );
65 return *this; 63 return *this;
66} 64}
67Serializer &Serializer::operator<<(float p) 65Bu::Archive &Bu::Archive::operator<<(float p)
68{ 66{
69 write( &p, sizeof(p) ); 67 write( &p, sizeof(p) );
70 return *this; 68 return *this;
71} 69}
72Serializer &Serializer::operator<<(double p) 70Bu::Archive &Bu::Archive::operator<<(double p)
73{ 71{
74 write( &p, sizeof(p) ); 72 write( &p, sizeof(p) );
75 return *this; 73 return *this;
76} 74}
77Serializer &Serializer::operator<<(long double p) 75Bu::Archive &Bu::Archive::operator<<(long double p)
78{ 76{
79 write( &p, sizeof(p) ); 77 write( &p, sizeof(p) );
80 return *this; 78 return *this;
81} 79}
82 80
83Serializer &Serializer::operator>>(bool &p) 81Bu::Archive &Bu::Archive::operator>>(bool &p)
84{ 82{
85 read( &p, sizeof(p) ); 83 read( &p, sizeof(p) );
86 return *this; 84 return *this;
87} 85}
88Serializer &Serializer::operator>>(int8_t &p) 86Bu::Archive &Bu::Archive::operator>>(int8_t &p)
89{ 87{
90 read( &p, sizeof(p) ); 88 read( &p, sizeof(p) );
91 return *this; 89 return *this;
92} 90}
93Serializer &Serializer::operator>>(int16_t &p) 91Bu::Archive &Bu::Archive::operator>>(int16_t &p)
94{ 92{
95 read( &p, sizeof(p) ); 93 read( &p, sizeof(p) );
96 return *this; 94 return *this;
97} 95}
98Serializer &Serializer::operator>>(int32_t &p) 96Bu::Archive &Bu::Archive::operator>>(int32_t &p)
99{ 97{
100 read( &p, sizeof(p) ); 98 read( &p, sizeof(p) );
101 return *this; 99 return *this;
102} 100}
103Serializer &Serializer::operator>>(int64_t &p) 101Bu::Archive &Bu::Archive::operator>>(int64_t &p)
104{ 102{
105 read( &p, sizeof(p) ); 103 read( &p, sizeof(p) );
106 return *this; 104 return *this;
107} 105}
108Serializer &Serializer::operator>>(uint8_t &p) 106Bu::Archive &Bu::Archive::operator>>(uint8_t &p)
109{ 107{
110 read( &p, sizeof(p) ); 108 read( &p, sizeof(p) );
111 return *this; 109 return *this;
112} 110}
113Serializer &Serializer::operator>>(uint16_t &p) 111Bu::Archive &Bu::Archive::operator>>(uint16_t &p)
114{ 112{
115 read( &p, sizeof(p) ); 113 read( &p, sizeof(p) );
116 return *this; 114 return *this;
117} 115}
118Serializer &Serializer::operator>>(uint32_t &p) 116Bu::Archive &Bu::Archive::operator>>(uint32_t &p)
119{ 117{
120 read( &p, sizeof(p) ); 118 read( &p, sizeof(p) );
121 return *this; 119 return *this;
122} 120}
123Serializer &Serializer::operator>>(uint64_t &p) 121Bu::Archive &Bu::Archive::operator>>(uint64_t &p)
124{ 122{
125 read( &p, sizeof(p) ); 123 read( &p, sizeof(p) );
126 return *this; 124 return *this;
127} 125}
128Serializer &Serializer::operator>>(long &p) 126Bu::Archive &Bu::Archive::operator>>(long &p)
129{ 127{
130 read( &p, sizeof(p) ); 128 read( &p, sizeof(p) );
131 return *this; 129 return *this;
132} 130}
133Serializer &Serializer::operator>>(float &p) 131Bu::Archive &Bu::Archive::operator>>(float &p)
134{ 132{
135 read( &p, sizeof(p) ); 133 read( &p, sizeof(p) );
136 return *this; 134 return *this;
137} 135}
138Serializer &Serializer::operator>>(double &p) 136Bu::Archive &Bu::Archive::operator>>(double &p)
139{ 137{
140 read( &p, sizeof(p) ); 138 read( &p, sizeof(p) );
141 return *this; 139 return *this;
142} 140}
143Serializer &Serializer::operator>>(long double &p) 141Bu::Archive &Bu::Archive::operator>>(long double &p)
144{ 142{
145 read( &p, sizeof(p) ); 143 read( &p, sizeof(p) );
146 return *this; 144 return *this;
147} 145}
148 146
149Serializer &Serializer::operator&&(bool &p) 147Bu::Archive &Bu::Archive::operator&&(bool &p)
150{ 148{
151 if (bLoading) 149 if (bLoading)
152 { 150 {
@@ -158,7 +156,7 @@ Serializer &Serializer::operator&&(bool &p)
158 } 156 }
159} 157}
160 158
161Serializer &Serializer::operator&&(int8_t &p) 159Bu::Archive &Bu::Archive::operator&&(int8_t &p)
162{ 160{
163 if (bLoading) 161 if (bLoading)
164 { 162 {
@@ -170,7 +168,7 @@ Serializer &Serializer::operator&&(int8_t &p)
170 } 168 }
171} 169}
172 170
173Serializer &Serializer::operator&&(int16_t &p) 171Bu::Archive &Bu::Archive::operator&&(int16_t &p)
174{ 172{
175 if (bLoading) 173 if (bLoading)
176 { 174 {
@@ -182,7 +180,7 @@ Serializer &Serializer::operator&&(int16_t &p)
182 } 180 }
183} 181}
184 182
185Serializer &Serializer::operator&&(int32_t &p) 183Bu::Archive &Bu::Archive::operator&&(int32_t &p)
186{ 184{
187 if (bLoading) 185 if (bLoading)
188 { 186 {
@@ -194,7 +192,7 @@ Serializer &Serializer::operator&&(int32_t &p)
194 } 192 }
195} 193}
196 194
197Serializer &Serializer::operator&&(int64_t &p) 195Bu::Archive &Bu::Archive::operator&&(int64_t &p)
198{ 196{
199 if (bLoading) 197 if (bLoading)
200 { 198 {
@@ -206,7 +204,7 @@ Serializer &Serializer::operator&&(int64_t &p)
206 } 204 }
207} 205}
208 206
209Serializer &Serializer::operator&&(uint8_t &p) 207Bu::Archive &Bu::Archive::operator&&(uint8_t &p)
210{ 208{
211 if (bLoading) 209 if (bLoading)
212 { 210 {
@@ -218,7 +216,7 @@ Serializer &Serializer::operator&&(uint8_t &p)
218 } 216 }
219} 217}
220 218
221Serializer &Serializer::operator&&(uint16_t &p) 219Bu::Archive &Bu::Archive::operator&&(uint16_t &p)
222{ 220{
223 if (bLoading) 221 if (bLoading)
224 { 222 {
@@ -230,7 +228,7 @@ Serializer &Serializer::operator&&(uint16_t &p)
230 } 228 }
231} 229}
232 230
233Serializer &Serializer::operator&&(uint32_t &p) 231Bu::Archive &Bu::Archive::operator&&(uint32_t &p)
234{ 232{
235 if (bLoading) 233 if (bLoading)
236 { 234 {
@@ -242,7 +240,7 @@ Serializer &Serializer::operator&&(uint32_t &p)
242 } 240 }
243} 241}
244 242
245Serializer &Serializer::operator&&(uint64_t &p) 243Bu::Archive &Bu::Archive::operator&&(uint64_t &p)
246{ 244{
247 if (bLoading) 245 if (bLoading)
248 { 246 {
@@ -254,7 +252,7 @@ Serializer &Serializer::operator&&(uint64_t &p)
254 } 252 }
255} 253}
256 254
257Serializer &Serializer::operator&&(float &p) 255Bu::Archive &Bu::Archive::operator&&(float &p)
258{ 256{
259 if (bLoading) 257 if (bLoading)
260 { 258 {
@@ -266,7 +264,7 @@ Serializer &Serializer::operator&&(float &p)
266 } 264 }
267} 265}
268 266
269Serializer &Serializer::operator&&(double &p) 267Bu::Archive &Bu::Archive::operator&&(double &p)
270{ 268{
271 if (bLoading) 269 if (bLoading)
272 { 270 {
@@ -278,7 +276,7 @@ Serializer &Serializer::operator&&(double &p)
278 } 276 }
279} 277}
280 278
281Serializer &Serializer::operator&&(long double &p) 279Bu::Archive &Bu::Archive::operator&&(long double &p)
282{ 280{
283 if (bLoading) 281 if (bLoading)
284 { 282 {
@@ -291,19 +289,20 @@ Serializer &Serializer::operator&&(long double &p)
291} 289}
292 290
293 291
294Serializer &operator<<(Serializer &s, Serializable &p) 292Bu::Archive &Bu::operator<<(Bu::Archive &s, Bu::Archable &p)
295{ 293{
296 p.serialize( s ); 294 p.archive( s );
297 return s; 295 return s;
298} 296}
299 297
300Serializer &operator>>(Serializer &s, Serializable &p) 298Bu::Archive &Bu::operator>>(Bu::Archive &s, Bu::Archable &p)
301{ 299{
302 p.serialize( s ); 300 p.archive( s );
303 return s; 301 return s;
304} 302}
305 303
306Serializer &operator&&(Serializer &s, Serializable &p) 304/*
305Bu::Archive &Bu::operator&&(Bu::Archive &s, Bu::Archable &p)
307{ 306{
308 if (s.isLoading()) 307 if (s.isLoading())
309 { 308 {
@@ -313,9 +312,9 @@ Serializer &operator&&(Serializer &s, Serializable &p)
313 { 312 {
314 return s << p; 313 return s << p;
315 } 314 }
316} 315}*/
317 316
318Serializer &operator<<( Serializer &ar, std::string &s ) 317Bu::Archive &Bu::operator<<( Bu::Archive &ar, std::string &s )
319{ 318{
320 ar << (uint32_t)s.length(); 319 ar << (uint32_t)s.length();
321 ar.write( s.c_str(), s.length() ); 320 ar.write( s.c_str(), s.length() );
@@ -323,7 +322,7 @@ Serializer &operator<<( Serializer &ar, std::string &s )
323 return ar; 322 return ar;
324} 323}
325 324
326Serializer &operator>>( Serializer &ar, std::string &s ) 325Bu::Archive &Bu::operator>>( Bu::Archive &ar, std::string &s )
327{ 326{
328 uint32_t l; 327 uint32_t l;
329 ar >> l; 328 ar >> l;