diff options
author | Mike Buland <eichlan@xagasoft.com> | 2012-03-25 20:00:08 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2012-03-25 20:00:08 +0000 |
commit | 469bbcf0701e1eb8a6670c23145b0da87357e178 (patch) | |
tree | b5b062a16e46a6c5d3410b4e574cd0cc09057211 /src/archive.cpp | |
parent | ee1b79396076edc4e30aefb285fada03bb45e80d (diff) | |
download | libbu++-469bbcf0701e1eb8a6670c23145b0da87357e178.tar.gz libbu++-469bbcf0701e1eb8a6670c23145b0da87357e178.tar.bz2 libbu++-469bbcf0701e1eb8a6670c23145b0da87357e178.tar.xz libbu++-469bbcf0701e1eb8a6670c23145b0da87357e178.zip |
Code is all reorganized. We're about ready to release. I should write up a
little explenation of the arrangement.
Diffstat (limited to 'src/archive.cpp')
-rw-r--r-- | src/archive.cpp | 89 |
1 files changed, 0 insertions, 89 deletions
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 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2007-2011 Xagasoft, All rights reserved. | ||
3 | * | ||
4 | * This file is part of the libbu++ library and is released under the | ||
5 | * terms of the license contained in the file LICENSE. | ||
6 | */ | ||
7 | |||
8 | #include "bu/archive.h" | ||
9 | #include "bu/stream.h" | ||
10 | #include "bu/archival.h" | ||
11 | |||
12 | #include "bu/sio.h" | ||
13 | |||
14 | Bu::Archive::Archive( Stream &rStream, bool bLoading ) : | ||
15 | bLoading( bLoading ), | ||
16 | rStream( rStream ), | ||
17 | nNextID( 1 ) | ||
18 | { | ||
19 | } | ||
20 | |||
21 | Bu::Archive::~Archive() | ||
22 | { | ||
23 | } | ||
24 | |||
25 | void Bu::Archive::write( const void *pData, size_t nSize ) | ||
26 | { | ||
27 | if( nSize == 0 || pData == NULL ) | ||
28 | return; | ||
29 | |||
30 | rStream.write( (const char *)pData, nSize ); | ||
31 | } | ||
32 | |||
33 | void Bu::Archive::read( void *pData, size_t nSize ) | ||
34 | { | ||
35 | if( nSize == 0 || pData == NULL ) | ||
36 | return; | ||
37 | |||
38 | if( rStream.read( (char *)pData, nSize ) < nSize ) | ||
39 | throw Bu::ExceptionBase("Insufficient data to unarchive object."); | ||
40 | } | ||
41 | |||
42 | void Bu::Archive::close() | ||
43 | { | ||
44 | rStream.close(); | ||
45 | } | ||
46 | |||
47 | bool Bu::Archive::isLoading() | ||
48 | { | ||
49 | return bLoading; | ||
50 | } | ||
51 | |||
52 | uint32_t Bu::Archive::getID( const void *ptr ) | ||
53 | { | ||
54 | if( hPtrID.has( (ptrdiff_t)ptr ) ) | ||
55 | return hPtrID.get( (ptrdiff_t)ptr ); | ||
56 | hPtrID.insert( (ptrdiff_t)ptr, nNextID ); | ||
57 | return nNextID++; | ||
58 | } | ||
59 | |||
60 | void Bu::Archive::assocPtrID( void **ptr, uint32_t id ) | ||
61 | { | ||
62 | if( hPtrID.has( id ) ) | ||
63 | { | ||
64 | *ptr = (void *)hPtrID.get( id ); | ||
65 | return; | ||
66 | } | ||
67 | |||
68 | if( !hPtrDest.has( id ) ) | ||
69 | hPtrDest.insert( id, List<void **>() ); | ||
70 | |||
71 | hPtrDest[id].getValue().append( ptr ); | ||
72 | } | ||
73 | |||
74 | void Bu::Archive::readID( const void *ptr, uint32_t id ) | ||
75 | { | ||
76 | hPtrID.insert( id, (ptrdiff_t)ptr ); | ||
77 | |||
78 | if( hPtrDest.has( id ) ) | ||
79 | { | ||
80 | Bu::List<void **> &l = hPtrDest.get( id ); | ||
81 | for( Bu::List<void **>::iterator i = l.begin(); i != l.end(); i++ ) | ||
82 | { | ||
83 | *(*i) = (void *)ptr; | ||
84 | } | ||
85 | |||
86 | hPtrDest.erase( id ); | ||
87 | } | ||
88 | } | ||
89 | |||