aboutsummaryrefslogtreecommitdiff
path: root/src/archive.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/archive.cpp41
1 files changed, 40 insertions, 1 deletions
diff --git a/src/archive.cpp b/src/archive.cpp
index c759477..7208bae 100644
--- a/src/archive.cpp
+++ b/src/archive.cpp
@@ -2,7 +2,8 @@
2 2
3Bu::Archive::Archive( Stream &rStream, bool bLoading ) : 3Bu::Archive::Archive( Stream &rStream, bool bLoading ) :
4 bLoading( bLoading ), 4 bLoading( bLoading ),
5 rStream( rStream ) 5 rStream( rStream ),
6 nNextID( 1 )
6{ 7{
7} 8}
8 9
@@ -345,3 +346,41 @@ Bu::Archive &Bu::operator>>( Bu::Archive &ar, std::string &s )
345 return ar; 346 return ar;
346} 347}
347 348
349uint32_t Bu::Archive::getID( const void *ptr )
350{
351 if( hPtrID.has( (int)ptr ) )
352 return hPtrID.get( (int)ptr );
353 hPtrID.insert( (int)ptr, nNextID );
354 return nNextID++;
355}
356
357void Bu::Archive::assocPtrID( void **ptr, uint32_t id )
358{
359 if( hPtrID.has( id ) )
360 {
361 *ptr = (void *)hPtrID.get( id );
362 return;
363 }
364
365 if( !hPtrDest.has( id ) )
366 hPtrDest.insert( id, List<void **>() );
367
368 hPtrDest[id].value().append( ptr );
369}
370
371void Bu::Archive::readID( const void *ptr, uint32_t id )
372{
373 hPtrID.insert( id, (int)ptr );
374
375 if( hPtrDest.has( id ) )
376 {
377 Bu::List<void **> &l = hPtrDest.get( id );
378 for( Bu::List<void **>::iterator i = l.begin(); i != l.end(); i++ )
379 {
380 *(*i) = (void *)ptr;
381 }
382
383 hPtrDest.erase( id );
384 }
385}
386