aboutsummaryrefslogtreecommitdiff
path: root/src/stable/archivebinary.cpp
diff options
context:
space:
mode:
authorMike Buland <mbuland@penny-arcade.com>2022-04-20 14:04:47 -0700
committerMike Buland <mbuland@penny-arcade.com>2022-04-20 14:04:47 -0700
commitfd56cdd21a7c9c944ad189cf91ff24d3c2b0f975 (patch)
treef16f7e7f54399ef9c753beb87069eed8122dbccb /src/stable/archivebinary.cpp
parentd10e6a5ca0905f0ef2836cd98aebfb48e7f1e8a3 (diff)
downloadlibbu++-fd56cdd21a7c9c944ad189cf91ff24d3c2b0f975.tar.gz
libbu++-fd56cdd21a7c9c944ad189cf91ff24d3c2b0f975.tar.bz2
libbu++-fd56cdd21a7c9c944ad189cf91ff24d3c2b0f975.tar.xz
libbu++-fd56cdd21a7c9c944ad189cf91ff24d3c2b0f975.zip
Gradually moving to better archive structure.
It's dragging other new API changes along with it, including use of Blob and Text.
Diffstat (limited to '')
-rw-r--r--src/stable/archivebinary.cpp190
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
13Bu::ArchiveBinary::ArchiveBinary( Stream &rStream, bool bLoading ) : 14Bu::ArchiveBinary::ArchiveBinary( Stream &rStream, bool bLoading ) :
14 bLoading( bLoading ), 15 bLoading( bLoading ),
@@ -20,7 +21,7 @@ Bu::ArchiveBinary::ArchiveBinary( Stream &rStream, bool bLoading ) :
20Bu::ArchiveBinary::~ArchiveBinary() 21Bu::ArchiveBinary::~ArchiveBinary()
21{ 22{
22} 23}
23 24/*
24void Bu::ArchiveBinary::write( const void *pData, size_t nSize ) 25void 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
42void Bu::ArchiveBinary::write( bool rData )
43{
44 rStream.write( &rData, sizeof(rData) );
45}
46
47void Bu::ArchiveBinary::write( const unsigned char rData )
48{
49 rStream.write( &rData, sizeof(rData) );
50}
51
52void Bu::ArchiveBinary::write( char rData )
53{
54 rStream.write( &rData, sizeof(rData) );
55}
56
57void Bu::ArchiveBinary::write( signed char rData )
58{
59 rStream.write( &rData, sizeof(rData) );
60}
61
62void Bu::ArchiveBinary::write( unsigned short rData )
63{
64 rStream.write( &rData, sizeof(rData) );
65}
66
67void Bu::ArchiveBinary::write( signed short rData )
68{
69 rStream.write( &rData, sizeof(rData) );
70}
71
72void Bu::ArchiveBinary::write( unsigned int rData )
73{
74 rStream.write( &rData, sizeof(rData) );
75}
76
77void Bu::ArchiveBinary::write( signed int rData )
78{
79 rStream.write( &rData, sizeof(rData) );
80}
81
82void Bu::ArchiveBinary::write( unsigned long rData )
83{
84 rStream.write( &rData, sizeof(rData) );
85}
86
87void Bu::ArchiveBinary::write( signed long rData )
88{
89 rStream.write( &rData, sizeof(rData) );
90}
91
92void Bu::ArchiveBinary::write( unsigned long long rData )
93{
94 rStream.write( &rData, sizeof(rData) );
95}
96
97void Bu::ArchiveBinary::write( signed long long rData )
98{
99 rStream.write( &rData, sizeof(rData) );
100}
101
102void Bu::ArchiveBinary::write( float rData )
103{
104 rStream.write( &rData, sizeof(rData) );
105}
106
107void Bu::ArchiveBinary::write( double rData )
108{
109 rStream.write( &rData, sizeof(rData) );
110}
111
112void Bu::ArchiveBinary::write( long double rData )
113{
114 rStream.write( &rData, sizeof(rData) );
115}
116
117void 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
124void 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
131void Bu::ArchiveBinary::read( bool &rData )
132{
133 rStream.read( &rData, sizeof(rData) );
134}
135
136void Bu::ArchiveBinary::read( unsigned char &rData )
137{
138 rStream.read( &rData, sizeof(rData) );
139}
140
141void Bu::ArchiveBinary::read( char &rData )
142{
143 rStream.read( &rData, sizeof(rData) );
144}
145
146void Bu::ArchiveBinary::read( signed char &rData )
147{
148 rStream.read( &rData, sizeof(rData) );
149}
150
151void Bu::ArchiveBinary::read( unsigned short &rData )
152{
153 rStream.read( &rData, sizeof(rData) );
154}
155
156void Bu::ArchiveBinary::read( signed short &rData )
157{
158 rStream.read( &rData, sizeof(rData) );
159}
160
161void Bu::ArchiveBinary::read( unsigned int &rData )
162{
163 rStream.read( &rData, sizeof(rData) );
164}
165
166void Bu::ArchiveBinary::read( signed int &rData )
167{
168 rStream.read( &rData, sizeof(rData) );
169}
170
171void Bu::ArchiveBinary::read( unsigned long &rData )
172{
173 rStream.read( &rData, sizeof(rData) );
174}
175
176void Bu::ArchiveBinary::read( signed long &rData )
177{
178 rStream.read( &rData, sizeof(rData) );
179}
180
181void Bu::ArchiveBinary::read( unsigned long long &rData )
182{
183 rStream.read( &rData, sizeof(rData) );
184}
185
186void Bu::ArchiveBinary::read( signed long long &rData )
187{
188 rStream.read( &rData, sizeof(rData) );
189}
190
191void Bu::ArchiveBinary::read( float &rData )
192{
193 rStream.read( &rData, sizeof(rData) );
194}
195
196void Bu::ArchiveBinary::read( double &rData )
197{
198 rStream.read( &rData, sizeof(rData) );
199}
200
201void Bu::ArchiveBinary::read( long double &rData )
202{
203 rStream.read( &rData, sizeof(rData) );
204}
205
206void 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
216void 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
41void Bu::ArchiveBinary::close() 229void Bu::ArchiveBinary::close()