diff options
author | Mike Buland <eichlan@xagasoft.com> | 2008-09-24 05:52:36 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2008-09-24 05:52:36 +0000 |
commit | 6119b465b19e9be095971a33c63b0fa9a0e8a224 (patch) | |
tree | 3dafeb91d18290790417477939179526a27de38b /src/archive.h | |
parent | 5aec71241c874a2249c14025a7df1eddc1c14654 (diff) | |
download | libbu++-6119b465b19e9be095971a33c63b0fa9a0e8a224.tar.gz libbu++-6119b465b19e9be095971a33c63b0fa9a0e8a224.tar.bz2 libbu++-6119b465b19e9be095971a33c63b0fa9a0e8a224.tar.xz libbu++-6119b465b19e9be095971a33c63b0fa9a0e8a224.zip |
Wow, I realized that the Bu::Array class wasn't finished, and went ahead and
wrote it, it's pretty feature complete, index, append, iterators. You can't
delete anything yet, exactly, but that's tricky in an array anyway, basically
you just want to be able to remove elements from the end, and that's halfway
there.
Also, fixed some documentation and minor issues in Bu::Set, and made the
Bu::Archive include fewer other classes while still defining archive oprators
for them. I think I may yet move those into the headers for the classes that
are being stored instead, makes a little more sense.
I also would like to move the Exception classes out of the exceptions.h file
and into the appropriate class' files'. There still should probably be a
couple of general ones in there, or maybe just in exceptionbase.h, we'll see.
Diffstat (limited to '')
-rw-r--r-- | src/archive.h | 45 |
1 files changed, 38 insertions, 7 deletions
diff --git a/src/archive.h b/src/archive.h index 1d57724..519b2a7 100644 --- a/src/archive.h +++ b/src/archive.h | |||
@@ -13,7 +13,7 @@ | |||
13 | #include <list> | 13 | #include <list> |
14 | #include "bu/hash.h" | 14 | #include "bu/hash.h" |
15 | #include "bu/list.h" | 15 | #include "bu/list.h" |
16 | #include "bu/set.h" | 16 | //#include "bu/set.h" |
17 | #include "bu/util.h" | 17 | #include "bu/util.h" |
18 | 18 | ||
19 | namespace Bu | 19 | namespace Bu |
@@ -298,11 +298,12 @@ namespace Bu | |||
298 | return ar; | 298 | return ar; |
299 | } | 299 | } |
300 | 300 | ||
301 | template<typename value> | 301 | template<typename value, int inc, typename valuealloc> class Array; |
302 | Archive &operator<<( Archive &ar, Set<value> &h ) | 302 | template<typename value, int inc, typename valuealloc> |
303 | Archive &operator<<( Archive &ar, Array<value, inc, valuealloc> &h ) | ||
303 | { | 304 | { |
304 | ar << h.getSize(); | 305 | ar << h.getSize(); |
305 | for( typename Set<value>::iterator i = h.begin(); i != h.end(); i++ ) | 306 | for( typename Array<value, inc, valuealloc>::iterator i = h.begin(); i != h.end(); i++ ) |
306 | { | 307 | { |
307 | ar << (*i); | 308 | ar << (*i); |
308 | } | 309 | } |
@@ -310,17 +311,47 @@ namespace Bu | |||
310 | return ar; | 311 | return ar; |
311 | } | 312 | } |
312 | 313 | ||
313 | template<typename value> | 314 | template<typename value, int inc, typename valuealloc> |
314 | Archive &operator>>( Archive &ar, Set<value> &h ) | 315 | Archive &operator>>(Archive &ar, Array<value, inc, valuealloc> &h ) |
315 | { | 316 | { |
316 | h.clear(); | 317 | h.clear(); |
317 | long nSize; | 318 | long nSize; |
318 | ar >> nSize; | 319 | ar >> nSize; |
319 | 320 | ||
321 | h.setCapacity( nSize ); | ||
320 | for( long j = 0; j < nSize; j++ ) | 322 | for( long j = 0; j < nSize; j++ ) |
321 | { | 323 | { |
322 | value v; | 324 | value v; |
323 | ar >> v; | 325 | ar >> v; |
326 | h.append( v ); | ||
327 | } | ||
328 | return ar; | ||
329 | } | ||
330 | |||
331 | template<typename key, typename b, typename c, typename d> class Set; | ||
332 | template<typename key, typename b, typename c, typename d> | ||
333 | Archive &operator<<( Archive &ar, Set<key, b, c, d> &h ) | ||
334 | { | ||
335 | ar << h.getSize(); | ||
336 | for( typename Set<key, b, c, d>::iterator i = h.begin(); i != h.end(); i++ ) | ||
337 | { | ||
338 | ar << (*i); | ||
339 | } | ||
340 | |||
341 | return ar; | ||
342 | } | ||
343 | |||
344 | template<typename key, typename b, typename c, typename d> | ||
345 | Archive &operator>>( Archive &ar, Set<key, b, c, d> &h ) | ||
346 | { | ||
347 | h.clear(); | ||
348 | long nSize; | ||
349 | ar >> nSize; | ||
350 | |||
351 | for( long j = 0; j < nSize; j++ ) | ||
352 | { | ||
353 | key v; | ||
354 | ar >> v; | ||
324 | h.insert( v ); | 355 | h.insert( v ); |
325 | } | 356 | } |
326 | 357 | ||