From b7e40536df9bf9bbad3b2b7a59f33ebad25fc981 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Mon, 4 Jun 2007 23:49:26 +0000 Subject: Added rudimentary object tracking to Archive, and rearranged the hash and archive dependancies a little. I'll add docs for object tracking later... --- src/archive.h | 44 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) (limited to 'src/archive.h') diff --git a/src/archive.h b/src/archive.h index 2f782d3..05c6f57 100644 --- a/src/archive.h +++ b/src/archive.h @@ -3,9 +3,11 @@ #include #include -#include "archival.h" -#include "stream.h" +#include "bu/archival.h" +#include "bu/stream.h" #include +#include "bu/hash.h" +#include "bu/list.h" namespace Bu { @@ -117,8 +119,15 @@ namespace Bu virtual Archive &operator&&(double &); virtual Archive &operator&&(long double &); + uint32_t getID( const void *ptr ); + void assocPtrID( void **ptr, uint32_t id ); + void readID( const void *ptr, uint32_t id ); + private: Stream &rStream; + uint32_t nNextID; + Hash hPtrID; + Hash > hPtrDest; }; Archive &operator<<(Archive &, class Bu::Archival &); @@ -168,6 +177,37 @@ namespace Bu return ar; } + + template + Archive &operator<<( Archive &ar, Hash &h ) + { + ar << h.size(); + for( typename Hash::iterator i = h.begin(); i != h.end(); i++ ) + { + std::pair p = *i; + ar << p.first << p.second; + } + + return ar; + } + + template + Archive &operator>>( Archive &ar, Hash &h ) + { + h.clear(); + uint32_t nSize; + ar >> nSize; + + for( uint32_t j = 0; j < nSize; j++ ) + { + key k; value v; + ar >> k >> v; + h.insert( k, v ); + } + + return ar; + } + } #endif -- cgit v1.2.3