From fd56cdd21a7c9c944ad189cf91ff24d3c2b0f975 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Wed, 20 Apr 2022 14:04:47 -0700 Subject: Gradually moving to better archive structure. It's dragging other new API changes along with it, including use of Blob and Text. --- src/stable/archivebinary.cpp | 190 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 189 insertions(+), 1 deletion(-) (limited to 'src/stable/archivebinary.cpp') 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 @@ #include "bu/stream.h" #include "bu/sio.h" +#include "bu/text.h" Bu::ArchiveBinary::ArchiveBinary( Stream &rStream, bool bLoading ) : bLoading( bLoading ), @@ -20,7 +21,7 @@ Bu::ArchiveBinary::ArchiveBinary( Stream &rStream, bool bLoading ) : Bu::ArchiveBinary::~ArchiveBinary() { } - +/* void Bu::ArchiveBinary::write( const void *pData, size_t nSize ) { if( nSize == 0 || pData == NULL ) @@ -36,6 +37,193 @@ void Bu::ArchiveBinary::read( void *pData, size_t nSize ) if( (size_t)rStream.read( (char *)pData, nSize ) < nSize ) throw Bu::ExceptionBase("Insufficient data to unarchive object."); +}*/ + +void Bu::ArchiveBinary::write( bool rData ) +{ + rStream.write( &rData, sizeof(rData) ); +} + +void Bu::ArchiveBinary::write( const unsigned char rData ) +{ + rStream.write( &rData, sizeof(rData) ); +} + +void Bu::ArchiveBinary::write( char rData ) +{ + rStream.write( &rData, sizeof(rData) ); +} + +void Bu::ArchiveBinary::write( signed char rData ) +{ + rStream.write( &rData, sizeof(rData) ); +} + +void Bu::ArchiveBinary::write( unsigned short rData ) +{ + rStream.write( &rData, sizeof(rData) ); +} + +void Bu::ArchiveBinary::write( signed short rData ) +{ + rStream.write( &rData, sizeof(rData) ); +} + +void Bu::ArchiveBinary::write( unsigned int rData ) +{ + rStream.write( &rData, sizeof(rData) ); +} + +void Bu::ArchiveBinary::write( signed int rData ) +{ + rStream.write( &rData, sizeof(rData) ); +} + +void Bu::ArchiveBinary::write( unsigned long rData ) +{ + rStream.write( &rData, sizeof(rData) ); +} + +void Bu::ArchiveBinary::write( signed long rData ) +{ + rStream.write( &rData, sizeof(rData) ); +} + +void Bu::ArchiveBinary::write( unsigned long long rData ) +{ + rStream.write( &rData, sizeof(rData) ); +} + +void Bu::ArchiveBinary::write( signed long long rData ) +{ + rStream.write( &rData, sizeof(rData) ); +} + +void Bu::ArchiveBinary::write( float rData ) +{ + rStream.write( &rData, sizeof(rData) ); +} + +void Bu::ArchiveBinary::write( double rData ) +{ + rStream.write( &rData, sizeof(rData) ); +} + +void Bu::ArchiveBinary::write( long double rData ) +{ + rStream.write( &rData, sizeof(rData) ); +} + +void Bu::ArchiveBinary::write( const Bu::Blob &rData ) +{ + int32_t iSize = rData.getSize(); + write( iSize ); + rStream.write( rData.getData(), iSize ); +} + +void Bu::ArchiveBinary::write( const Bu::Text &rData ) +{ + int32_t iSize = rData.getSize(); + write( iSize ); + rStream.write( rData.getData(), iSize ); +} + +void Bu::ArchiveBinary::read( bool &rData ) +{ + rStream.read( &rData, sizeof(rData) ); +} + +void Bu::ArchiveBinary::read( unsigned char &rData ) +{ + rStream.read( &rData, sizeof(rData) ); +} + +void Bu::ArchiveBinary::read( char &rData ) +{ + rStream.read( &rData, sizeof(rData) ); +} + +void Bu::ArchiveBinary::read( signed char &rData ) +{ + rStream.read( &rData, sizeof(rData) ); +} + +void Bu::ArchiveBinary::read( unsigned short &rData ) +{ + rStream.read( &rData, sizeof(rData) ); +} + +void Bu::ArchiveBinary::read( signed short &rData ) +{ + rStream.read( &rData, sizeof(rData) ); +} + +void Bu::ArchiveBinary::read( unsigned int &rData ) +{ + rStream.read( &rData, sizeof(rData) ); +} + +void Bu::ArchiveBinary::read( signed int &rData ) +{ + rStream.read( &rData, sizeof(rData) ); +} + +void Bu::ArchiveBinary::read( unsigned long &rData ) +{ + rStream.read( &rData, sizeof(rData) ); +} + +void Bu::ArchiveBinary::read( signed long &rData ) +{ + rStream.read( &rData, sizeof(rData) ); +} + +void Bu::ArchiveBinary::read( unsigned long long &rData ) +{ + rStream.read( &rData, sizeof(rData) ); +} + +void Bu::ArchiveBinary::read( signed long long &rData ) +{ + rStream.read( &rData, sizeof(rData) ); +} + +void Bu::ArchiveBinary::read( float &rData ) +{ + rStream.read( &rData, sizeof(rData) ); +} + +void Bu::ArchiveBinary::read( double &rData ) +{ + rStream.read( &rData, sizeof(rData) ); +} + +void Bu::ArchiveBinary::read( long double &rData ) +{ + rStream.read( &rData, sizeof(rData) ); +} + +void Bu::ArchiveBinary::read( Bu::Blob &rData ) +{ + int32_t iSize; + read( iSize ); + char *pBuf = new char[iSize]; + rStream.read( pBuf, iSize ); + rData.set( pBuf, iSize ); + delete[] pBuf; +} + +void Bu::ArchiveBinary::read( Bu::Text &rData ) +{ + /* + int32_t iSize; + read( iSize ); + char *pBuf = new char[iSize]; + rStream.read( pBuf, iSize ); + rData.set( pBuf, iSize ); + delete[] pBuf; + */ + throw Bu::ExceptionBase("Cannot read Bu::Text objects yet."); } void Bu::ArchiveBinary::close() -- cgit v1.2.3