diff options
author | Mike Buland <eichlan@xagasoft.com> | 2012-11-05 22:41:51 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2012-11-05 22:41:51 +0000 |
commit | ec05778d5718a7912e506764d443a78d6a6179e3 (patch) | |
tree | 78a9a01532180030c095acefc45763f07c14edb8 /src/stable/archive.cpp | |
parent | b20414ac1fe80a71a90601f4cd1767fa7014a9ba (diff) | |
download | libbu++-ec05778d5718a7912e506764d443a78d6a6179e3.tar.gz libbu++-ec05778d5718a7912e506764d443a78d6a6179e3.tar.bz2 libbu++-ec05778d5718a7912e506764d443a78d6a6179e3.tar.xz libbu++-ec05778d5718a7912e506764d443a78d6a6179e3.zip |
Converted tabs to spaces with tabconv.
Diffstat (limited to 'src/stable/archive.cpp')
-rw-r--r-- | src/stable/archive.cpp | 76 |
1 files changed, 38 insertions, 38 deletions
diff --git a/src/stable/archive.cpp b/src/stable/archive.cpp index 13480e1..3769e0e 100644 --- a/src/stable/archive.cpp +++ b/src/stable/archive.cpp | |||
@@ -12,9 +12,9 @@ | |||
12 | #include "bu/sio.h" | 12 | #include "bu/sio.h" |
13 | 13 | ||
14 | Bu::Archive::Archive( Stream &rStream, bool bLoading ) : | 14 | Bu::Archive::Archive( Stream &rStream, bool bLoading ) : |
15 | bLoading( bLoading ), | 15 | bLoading( bLoading ), |
16 | rStream( rStream ), | 16 | rStream( rStream ), |
17 | nNextID( 1 ) | 17 | nNextID( 1 ) |
18 | { | 18 | { |
19 | } | 19 | } |
20 | 20 | ||
@@ -24,66 +24,66 @@ Bu::Archive::~Archive() | |||
24 | 24 | ||
25 | void Bu::Archive::write( const void *pData, size_t nSize ) | 25 | void Bu::Archive::write( const void *pData, size_t nSize ) |
26 | { | 26 | { |
27 | if( nSize == 0 || pData == NULL ) | 27 | if( nSize == 0 || pData == NULL ) |
28 | return; | 28 | return; |
29 | 29 | ||
30 | rStream.write( (const char *)pData, nSize ); | 30 | rStream.write( (const char *)pData, nSize ); |
31 | } | 31 | } |
32 | 32 | ||
33 | void Bu::Archive::read( void *pData, size_t nSize ) | 33 | void Bu::Archive::read( void *pData, size_t nSize ) |
34 | { | 34 | { |
35 | if( nSize == 0 || pData == NULL ) | 35 | if( nSize == 0 || pData == NULL ) |
36 | return; | 36 | return; |
37 | 37 | ||
38 | if( (size_t)rStream.read( (char *)pData, nSize ) < nSize ) | 38 | if( (size_t)rStream.read( (char *)pData, nSize ) < nSize ) |
39 | throw Bu::ExceptionBase("Insufficient data to unarchive object."); | 39 | throw Bu::ExceptionBase("Insufficient data to unarchive object."); |
40 | } | 40 | } |
41 | 41 | ||
42 | void Bu::Archive::close() | 42 | void Bu::Archive::close() |
43 | { | 43 | { |
44 | rStream.close(); | 44 | rStream.close(); |
45 | } | 45 | } |
46 | 46 | ||
47 | bool Bu::Archive::isLoading() | 47 | bool Bu::Archive::isLoading() |
48 | { | 48 | { |
49 | return bLoading; | 49 | return bLoading; |
50 | } | 50 | } |
51 | 51 | ||
52 | uint32_t Bu::Archive::getID( const void *ptr ) | 52 | uint32_t Bu::Archive::getID( const void *ptr ) |
53 | { | 53 | { |
54 | if( hPtrID.has( (ptrdiff_t)ptr ) ) | 54 | if( hPtrID.has( (ptrdiff_t)ptr ) ) |
55 | return hPtrID.get( (ptrdiff_t)ptr ); | 55 | return hPtrID.get( (ptrdiff_t)ptr ); |
56 | hPtrID.insert( (ptrdiff_t)ptr, nNextID ); | 56 | hPtrID.insert( (ptrdiff_t)ptr, nNextID ); |
57 | return nNextID++; | 57 | return nNextID++; |
58 | } | 58 | } |
59 | 59 | ||
60 | void Bu::Archive::assocPtrID( void **ptr, uint32_t id ) | 60 | void Bu::Archive::assocPtrID( void **ptr, uint32_t id ) |
61 | { | 61 | { |
62 | if( hPtrID.has( id ) ) | 62 | if( hPtrID.has( id ) ) |
63 | { | 63 | { |
64 | *ptr = (void *)hPtrID.get( id ); | 64 | *ptr = (void *)hPtrID.get( id ); |
65 | return; | 65 | return; |
66 | } | 66 | } |
67 | 67 | ||
68 | if( !hPtrDest.has( id ) ) | 68 | if( !hPtrDest.has( id ) ) |
69 | hPtrDest.insert( id, List<void **>() ); | 69 | hPtrDest.insert( id, List<void **>() ); |
70 | 70 | ||
71 | hPtrDest[id].getValue().append( ptr ); | 71 | hPtrDest[id].getValue().append( ptr ); |
72 | } | 72 | } |
73 | 73 | ||
74 | void Bu::Archive::readID( const void *ptr, uint32_t id ) | 74 | void Bu::Archive::readID( const void *ptr, uint32_t id ) |
75 | { | 75 | { |
76 | hPtrID.insert( id, (ptrdiff_t)ptr ); | 76 | hPtrID.insert( id, (ptrdiff_t)ptr ); |
77 | 77 | ||
78 | if( hPtrDest.has( id ) ) | 78 | if( hPtrDest.has( id ) ) |
79 | { | 79 | { |
80 | Bu::List<void **> &l = hPtrDest.get( id ); | 80 | Bu::List<void **> &l = hPtrDest.get( id ); |
81 | for( Bu::List<void **>::iterator i = l.begin(); i != l.end(); i++ ) | 81 | for( Bu::List<void **>::iterator i = l.begin(); i != l.end(); i++ ) |
82 | { | 82 | { |
83 | *(*i) = (void *)ptr; | 83 | *(*i) = (void *)ptr; |
84 | } | 84 | } |
85 | 85 | ||
86 | hPtrDest.erase( id ); | 86 | hPtrDest.erase( id ); |
87 | } | 87 | } |
88 | } | 88 | } |
89 | 89 | ||