diff options
author | Mike Buland <eichlan@xagasoft.com> | 2007-09-13 06:21:54 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2007-09-13 06:21:54 +0000 |
commit | 8c0b390617ea42af40d409bd1fbc541e63321239 (patch) | |
tree | 4912a3c3b503a4ee76c03b36ab02623ee230d0b8 /src/archive.h | |
parent | cc1d8bdc45fa626b514bdace0cd026fa83dc8400 (diff) | |
download | libbu++-8c0b390617ea42af40d409bd1fbc541e63321239.tar.gz libbu++-8c0b390617ea42af40d409bd1fbc541e63321239.tar.bz2 libbu++-8c0b390617ea42af40d409bd1fbc541e63321239.tar.xz libbu++-8c0b390617ea42af40d409bd1fbc541e63321239.zip |
Sets now match Hashes better, and can be Archived.
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 |