diff options
Diffstat (limited to 'src/stable/archivebinary.cpp')
-rw-r--r-- | src/stable/archivebinary.cpp | 190 |
1 files changed, 189 insertions, 1 deletions
diff --git a/src/stable/archivebinary.cpp b/src/stable/archivebinary.cpp index 3f05947..04e80d2 100644 --- a/src/stable/archivebinary.cpp +++ b/src/stable/archivebinary.cpp | |||
@@ -9,6 +9,7 @@ | |||
9 | #include "bu/stream.h" | 9 | #include "bu/stream.h" |
10 | 10 | ||
11 | #include "bu/sio.h" | 11 | #include "bu/sio.h" |
12 | #include "bu/text.h" | ||
12 | 13 | ||
13 | Bu::ArchiveBinary::ArchiveBinary( Stream &rStream, bool bLoading ) : | 14 | Bu::ArchiveBinary::ArchiveBinary( Stream &rStream, bool bLoading ) : |
14 | bLoading( bLoading ), | 15 | bLoading( bLoading ), |
@@ -20,7 +21,7 @@ Bu::ArchiveBinary::ArchiveBinary( Stream &rStream, bool bLoading ) : | |||
20 | Bu::ArchiveBinary::~ArchiveBinary() | 21 | Bu::ArchiveBinary::~ArchiveBinary() |
21 | { | 22 | { |
22 | } | 23 | } |
23 | 24 | /* | |
24 | void Bu::ArchiveBinary::write( const void *pData, size_t nSize ) | 25 | void Bu::ArchiveBinary::write( const void *pData, size_t nSize ) |
25 | { | 26 | { |
26 | if( nSize == 0 || pData == NULL ) | 27 | if( nSize == 0 || pData == NULL ) |
@@ -36,6 +37,193 @@ void Bu::ArchiveBinary::read( void *pData, size_t nSize ) | |||
36 | 37 | ||
37 | if( (size_t)rStream.read( (char *)pData, nSize ) < nSize ) | 38 | if( (size_t)rStream.read( (char *)pData, nSize ) < nSize ) |
38 | throw Bu::ExceptionBase("Insufficient data to unarchive object."); | 39 | throw Bu::ExceptionBase("Insufficient data to unarchive object."); |
40 | }*/ | ||
41 | |||
42 | void Bu::ArchiveBinary::write( bool rData ) | ||
43 | { | ||
44 | rStream.write( &rData, sizeof(rData) ); | ||
45 | } | ||
46 | |||
47 | void Bu::ArchiveBinary::write( const unsigned char rData ) | ||
48 | { | ||
49 | rStream.write( &rData, sizeof(rData) ); | ||
50 | } | ||
51 | |||
52 | void Bu::ArchiveBinary::write( char rData ) | ||
53 | { | ||
54 | rStream.write( &rData, sizeof(rData) ); | ||
55 | } | ||
56 | |||
57 | void Bu::ArchiveBinary::write( signed char rData ) | ||
58 | { | ||
59 | rStream.write( &rData, sizeof(rData) ); | ||
60 | } | ||
61 | |||
62 | void Bu::ArchiveBinary::write( unsigned short rData ) | ||
63 | { | ||
64 | rStream.write( &rData, sizeof(rData) ); | ||
65 | } | ||
66 | |||
67 | void Bu::ArchiveBinary::write( signed short rData ) | ||
68 | { | ||
69 | rStream.write( &rData, sizeof(rData) ); | ||
70 | } | ||
71 | |||
72 | void Bu::ArchiveBinary::write( unsigned int rData ) | ||
73 | { | ||
74 | rStream.write( &rData, sizeof(rData) ); | ||
75 | } | ||
76 | |||
77 | void Bu::ArchiveBinary::write( signed int rData ) | ||
78 | { | ||
79 | rStream.write( &rData, sizeof(rData) ); | ||
80 | } | ||
81 | |||
82 | void Bu::ArchiveBinary::write( unsigned long rData ) | ||
83 | { | ||
84 | rStream.write( &rData, sizeof(rData) ); | ||
85 | } | ||
86 | |||
87 | void Bu::ArchiveBinary::write( signed long rData ) | ||
88 | { | ||
89 | rStream.write( &rData, sizeof(rData) ); | ||
90 | } | ||
91 | |||
92 | void Bu::ArchiveBinary::write( unsigned long long rData ) | ||
93 | { | ||
94 | rStream.write( &rData, sizeof(rData) ); | ||
95 | } | ||
96 | |||
97 | void Bu::ArchiveBinary::write( signed long long rData ) | ||
98 | { | ||
99 | rStream.write( &rData, sizeof(rData) ); | ||
100 | } | ||
101 | |||
102 | void Bu::ArchiveBinary::write( float rData ) | ||
103 | { | ||
104 | rStream.write( &rData, sizeof(rData) ); | ||
105 | } | ||
106 | |||
107 | void Bu::ArchiveBinary::write( double rData ) | ||
108 | { | ||
109 | rStream.write( &rData, sizeof(rData) ); | ||
110 | } | ||
111 | |||
112 | void Bu::ArchiveBinary::write( long double rData ) | ||
113 | { | ||
114 | rStream.write( &rData, sizeof(rData) ); | ||
115 | } | ||
116 | |||
117 | void Bu::ArchiveBinary::write( const Bu::Blob &rData ) | ||
118 | { | ||
119 | int32_t iSize = rData.getSize(); | ||
120 | write( iSize ); | ||
121 | rStream.write( rData.getData(), iSize ); | ||
122 | } | ||
123 | |||
124 | void Bu::ArchiveBinary::write( const Bu::Text &rData ) | ||
125 | { | ||
126 | int32_t iSize = rData.getSize(); | ||
127 | write( iSize ); | ||
128 | rStream.write( rData.getData(), iSize ); | ||
129 | } | ||
130 | |||
131 | void Bu::ArchiveBinary::read( bool &rData ) | ||
132 | { | ||
133 | rStream.read( &rData, sizeof(rData) ); | ||
134 | } | ||
135 | |||
136 | void Bu::ArchiveBinary::read( unsigned char &rData ) | ||
137 | { | ||
138 | rStream.read( &rData, sizeof(rData) ); | ||
139 | } | ||
140 | |||
141 | void Bu::ArchiveBinary::read( char &rData ) | ||
142 | { | ||
143 | rStream.read( &rData, sizeof(rData) ); | ||
144 | } | ||
145 | |||
146 | void Bu::ArchiveBinary::read( signed char &rData ) | ||
147 | { | ||
148 | rStream.read( &rData, sizeof(rData) ); | ||
149 | } | ||
150 | |||
151 | void Bu::ArchiveBinary::read( unsigned short &rData ) | ||
152 | { | ||
153 | rStream.read( &rData, sizeof(rData) ); | ||
154 | } | ||
155 | |||
156 | void Bu::ArchiveBinary::read( signed short &rData ) | ||
157 | { | ||
158 | rStream.read( &rData, sizeof(rData) ); | ||
159 | } | ||
160 | |||
161 | void Bu::ArchiveBinary::read( unsigned int &rData ) | ||
162 | { | ||
163 | rStream.read( &rData, sizeof(rData) ); | ||
164 | } | ||
165 | |||
166 | void Bu::ArchiveBinary::read( signed int &rData ) | ||
167 | { | ||
168 | rStream.read( &rData, sizeof(rData) ); | ||
169 | } | ||
170 | |||
171 | void Bu::ArchiveBinary::read( unsigned long &rData ) | ||
172 | { | ||
173 | rStream.read( &rData, sizeof(rData) ); | ||
174 | } | ||
175 | |||
176 | void Bu::ArchiveBinary::read( signed long &rData ) | ||
177 | { | ||
178 | rStream.read( &rData, sizeof(rData) ); | ||
179 | } | ||
180 | |||
181 | void Bu::ArchiveBinary::read( unsigned long long &rData ) | ||
182 | { | ||
183 | rStream.read( &rData, sizeof(rData) ); | ||
184 | } | ||
185 | |||
186 | void Bu::ArchiveBinary::read( signed long long &rData ) | ||
187 | { | ||
188 | rStream.read( &rData, sizeof(rData) ); | ||
189 | } | ||
190 | |||
191 | void Bu::ArchiveBinary::read( float &rData ) | ||
192 | { | ||
193 | rStream.read( &rData, sizeof(rData) ); | ||
194 | } | ||
195 | |||
196 | void Bu::ArchiveBinary::read( double &rData ) | ||
197 | { | ||
198 | rStream.read( &rData, sizeof(rData) ); | ||
199 | } | ||
200 | |||
201 | void Bu::ArchiveBinary::read( long double &rData ) | ||
202 | { | ||
203 | rStream.read( &rData, sizeof(rData) ); | ||
204 | } | ||
205 | |||
206 | void Bu::ArchiveBinary::read( Bu::Blob &rData ) | ||
207 | { | ||
208 | int32_t iSize; | ||
209 | read( iSize ); | ||
210 | char *pBuf = new char[iSize]; | ||
211 | rStream.read( pBuf, iSize ); | ||
212 | rData.set( pBuf, iSize ); | ||
213 | delete[] pBuf; | ||
214 | } | ||
215 | |||
216 | void Bu::ArchiveBinary::read( Bu::Text &rData ) | ||
217 | { | ||
218 | /* | ||
219 | int32_t iSize; | ||
220 | read( iSize ); | ||
221 | char *pBuf = new char[iSize]; | ||
222 | rStream.read( pBuf, iSize ); | ||
223 | rData.set( pBuf, iSize ); | ||
224 | delete[] pBuf; | ||
225 | */ | ||
226 | throw Bu::ExceptionBase("Cannot read Bu::Text objects yet."); | ||
39 | } | 227 | } |
40 | 228 | ||
41 | void Bu::ArchiveBinary::close() | 229 | void Bu::ArchiveBinary::close() |