summaryrefslogtreecommitdiff
path: root/src/archive.h
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2007-06-04 23:49:26 +0000
committerMike Buland <eichlan@xagasoft.com>2007-06-04 23:49:26 +0000
commitb7e40536df9bf9bbad3b2b7a59f33ebad25fc981 (patch)
tree1555062abe0e01e8d6d5b9b63ba81ab3c3d0168c /src/archive.h
parent326125aee0b8cd807a6a1d158398078ff6bfb1e1 (diff)
downloadlibbu++-b7e40536df9bf9bbad3b2b7a59f33ebad25fc981.tar.gz
libbu++-b7e40536df9bf9bbad3b2b7a59f33ebad25fc981.tar.bz2
libbu++-b7e40536df9bf9bbad3b2b7a59f33ebad25fc981.tar.xz
libbu++-b7e40536df9bf9bbad3b2b7a59f33ebad25fc981.zip
Added rudimentary object tracking to Archive, and rearranged the hash and
archive dependancies a little. I'll add docs for object tracking later...
Diffstat (limited to 'src/archive.h')
-rw-r--r--src/archive.h44
1 files changed, 42 insertions, 2 deletions
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 @@
3 3
4#include <stdint.h> 4#include <stdint.h>
5#include <string> 5#include <string>
6#include "archival.h" 6#include "bu/archival.h"
7#include "stream.h" 7#include "bu/stream.h"
8#include <list> 8#include <list>
9#include "bu/hash.h"
10#include "bu/list.h"
9 11
10namespace Bu 12namespace Bu
11{ 13{
@@ -117,8 +119,15 @@ namespace Bu
117 virtual Archive &operator&&(double &); 119 virtual Archive &operator&&(double &);
118 virtual Archive &operator&&(long double &); 120 virtual Archive &operator&&(long double &);
119 121
122 uint32_t getID( const void *ptr );
123 void assocPtrID( void **ptr, uint32_t id );
124 void readID( const void *ptr, uint32_t id );
125
120 private: 126 private:
121 Stream &rStream; 127 Stream &rStream;
128 uint32_t nNextID;
129 Hash<uint32_t,uint32_t> hPtrID;
130 Hash<uint32_t,List<void **> > hPtrDest;
122 }; 131 };
123 132
124 Archive &operator<<(Archive &, class Bu::Archival &); 133 Archive &operator<<(Archive &, class Bu::Archival &);
@@ -168,6 +177,37 @@ namespace Bu
168 177
169 return ar; 178 return ar;
170 } 179 }
180
181 template<typename key, typename value>
182 Archive &operator<<( Archive &ar, Hash<key,value> &h )
183 {
184 ar << h.size();
185 for( typename Hash<key,value>::iterator i = h.begin(); i != h.end(); i++ )
186 {
187 std::pair<key,value> p = *i;
188 ar << p.first << p.second;
189 }
190
191 return ar;
192 }
193
194 template<typename key, typename value>
195 Archive &operator>>( Archive &ar, Hash<key,value> &h )
196 {
197 h.clear();
198 uint32_t nSize;
199 ar >> nSize;
200
201 for( uint32_t j = 0; j < nSize; j++ )
202 {
203 key k; value v;
204 ar >> k >> v;
205 h.insert( k, v );
206 }
207
208 return ar;
209 }
210
171} 211}
172 212
173#endif 213#endif