diff options
Diffstat (limited to 'src/archive.h')
-rw-r--r-- | src/archive.h | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/src/archive.h b/src/archive.h index 24c3a67..b5477bb 100644 --- a/src/archive.h +++ b/src/archive.h | |||
@@ -8,6 +8,7 @@ | |||
8 | #include <list> | 8 | #include <list> |
9 | #include "bu/hash.h" | 9 | #include "bu/hash.h" |
10 | #include "bu/list.h" | 10 | #include "bu/list.h" |
11 | #include "bu/set.h" | ||
11 | 12 | ||
12 | namespace Bu | 13 | namespace Bu |
13 | { | 14 | { |
@@ -235,7 +236,36 @@ namespace Bu | |||
235 | } | 236 | } |
236 | 237 | ||
237 | return ar; | 238 | return ar; |
238 | } | 239 | } |
240 | |||
241 | template<typename value> | ||
242 | Archive &operator<<( Archive &ar, Set<value> &h ) | ||
243 | { | ||
244 | ar << h.getSize(); | ||
245 | for( typename Set<value>::iterator i = h.begin(); i != h.end(); i++ ) | ||
246 | { | ||
247 | ar << (*i); | ||
248 | } | ||
249 | |||
250 | return ar; | ||
251 | } | ||
252 | |||
253 | template<typename value> | ||
254 | Archive &operator>>( Archive &ar, Set<value> &h ) | ||
255 | { | ||
256 | h.clear(); | ||
257 | uint32_t nSize; | ||
258 | ar >> nSize; | ||
259 | |||
260 | for( uint32_t j = 0; j < nSize; j++ ) | ||
261 | { | ||
262 | value v; | ||
263 | ar >> v; | ||
264 | h.insert( v ); | ||
265 | } | ||
266 | |||
267 | return ar; | ||
268 | } | ||
239 | } | 269 | } |
240 | 270 | ||
241 | #endif | 271 | #endif |