aboutsummaryrefslogtreecommitdiff
path: root/src/unstable/blob.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/unstable/blob.cpp')
-rw-r--r--src/unstable/blob.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/unstable/blob.cpp b/src/unstable/blob.cpp
index 23987f3..c4148e1 100644
--- a/src/unstable/blob.cpp
+++ b/src/unstable/blob.cpp
@@ -55,6 +55,14 @@ Bu::Blob::Blob( const void *pSrc, int32_t iSize ) :
55 pData[iSize] = '\0'; 55 pData[iSize] = '\0';
56} 56}
57 57
58Bu::Blob::Blob( int32_t iSize ) :
59 pData( 0 ),
60 iSize( iSize )
61{
62 pData = new char[iSize+1];
63 memset( pData, iSize+1, 1 );
64}
65
58Bu::Blob::Blob( const Bu::Blob::const_iterator &iStart ) : 66Bu::Blob::Blob( const Bu::Blob::const_iterator &iStart ) :
59 pData( 0 ), 67 pData( 0 ),
60 iSize( 0 ) 68 iSize( 0 )
@@ -96,6 +104,14 @@ Bu::Blob::~Blob()
96 iSize = 0; 104 iSize = 0;
97} 105}
98 106
107void Bu::Blob::setSize( int32_t iSize )
108{
109 delete[] pData;
110 pData = new char[iSize+1];
111 memset( pData, iSize, 1 );
112 this->iSize = iSize;
113}
114
99int32_t Bu::Blob::getSize() const 115int32_t Bu::Blob::getSize() const
100{ 116{
101 return iSize; 117 return iSize;
@@ -795,3 +811,20 @@ Bu::Formatter &Bu::operator<<( Bu::Formatter &rOut, const Bu::Blob &b )
795 return rOut; 811 return rOut;
796} 812}
797 813
814Bu::ArchiveBase &operator<<( Bu::ArchiveBase &ar, const Bu::Blob &b )
815{
816 int32_t iSize = b.getSize();
817 ar << iSize;
818 ar.write( b.getData(), iSize );
819 return ar;
820}
821
822Bu::ArchiveBase &operator>>( Bu::ArchiveBase &ar, Bu::Blob &b )
823{
824 int32_t iSize;
825 ar >> iSize;
826 b.setSize( iSize );
827 ar.read( b.getData(), iSize );
828 return ar;
829}
830