From 469bbcf0701e1eb8a6670c23145b0da87357e178 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Sun, 25 Mar 2012 20:00:08 +0000 Subject: Code is all reorganized. We're about ready to release. I should write up a little explenation of the arrangement. --- src/archive.cpp | 89 --------------------------------------------------------- 1 file changed, 89 deletions(-) delete mode 100644 src/archive.cpp (limited to 'src/archive.cpp') diff --git a/src/archive.cpp b/src/archive.cpp deleted file mode 100644 index d300a87..0000000 --- a/src/archive.cpp +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (C) 2007-2011 Xagasoft, All rights reserved. - * - * This file is part of the libbu++ library and is released under the - * terms of the license contained in the file LICENSE. - */ - -#include "bu/archive.h" -#include "bu/stream.h" -#include "bu/archival.h" - -#include "bu/sio.h" - -Bu::Archive::Archive( Stream &rStream, bool bLoading ) : - bLoading( bLoading ), - rStream( rStream ), - nNextID( 1 ) -{ -} - -Bu::Archive::~Archive() -{ -} - -void Bu::Archive::write( const void *pData, size_t nSize ) -{ - if( nSize == 0 || pData == NULL ) - return; - - rStream.write( (const char *)pData, nSize ); -} - -void Bu::Archive::read( void *pData, size_t nSize ) -{ - if( nSize == 0 || pData == NULL ) - return; - - if( rStream.read( (char *)pData, nSize ) < nSize ) - throw Bu::ExceptionBase("Insufficient data to unarchive object."); -} - -void Bu::Archive::close() -{ - rStream.close(); -} - -bool Bu::Archive::isLoading() -{ - return bLoading; -} - -uint32_t Bu::Archive::getID( const void *ptr ) -{ - if( hPtrID.has( (ptrdiff_t)ptr ) ) - return hPtrID.get( (ptrdiff_t)ptr ); - hPtrID.insert( (ptrdiff_t)ptr, nNextID ); - return nNextID++; -} - -void Bu::Archive::assocPtrID( void **ptr, uint32_t id ) -{ - if( hPtrID.has( id ) ) - { - *ptr = (void *)hPtrID.get( id ); - return; - } - - if( !hPtrDest.has( id ) ) - hPtrDest.insert( id, List() ); - - hPtrDest[id].getValue().append( ptr ); -} - -void Bu::Archive::readID( const void *ptr, uint32_t id ) -{ - hPtrID.insert( id, (ptrdiff_t)ptr ); - - if( hPtrDest.has( id ) ) - { - Bu::List &l = hPtrDest.get( id ); - for( Bu::List::iterator i = l.begin(); i != l.end(); i++ ) - { - *(*i) = (void *)ptr; - } - - hPtrDest.erase( id ); - } -} - -- cgit v1.2.3