diff options
Diffstat (limited to 'src/unstable/blob.cpp')
-rw-r--r-- | src/unstable/blob.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/unstable/blob.cpp b/src/unstable/blob.cpp index d343963..bf8cb5a 100644 --- a/src/unstable/blob.cpp +++ b/src/unstable/blob.cpp | |||
@@ -10,6 +10,9 @@ | |||
10 | #include "bu/exceptioninvaliditerator.h" | 10 | #include "bu/exceptioninvaliditerator.h" |
11 | #include "bu/exceptionindexoutofbounds.h" | 11 | #include "bu/exceptionindexoutofbounds.h" |
12 | 12 | ||
13 | // Temporary | ||
14 | #include "bu/string.h" | ||
15 | |||
13 | #include <string.h> | 16 | #include <string.h> |
14 | 17 | ||
15 | Bu::Blob::Blob() : | 18 | Bu::Blob::Blob() : |
@@ -97,6 +100,14 @@ Bu::Blob::Blob( const Bu::Blob::const_iterator &iStart, | |||
97 | pData[iSize] = 0; | 100 | pData[iSize] = 0; |
98 | } | 101 | } |
99 | 102 | ||
103 | Bu::Blob::Blob( const Bu::String &rSrc ) : | ||
104 | pData( 0 ), | ||
105 | iSize( rSrc.getSize() ) | ||
106 | { | ||
107 | pData = new char[rSrc.getSize()+1]; | ||
108 | memcpy( pData, rSrc.getStr(), iSize+1 ); | ||
109 | } | ||
110 | |||
100 | Bu::Blob::~Blob() | 111 | Bu::Blob::~Blob() |
101 | { | 112 | { |
102 | delete[] pData; | 113 | delete[] pData; |
@@ -117,6 +128,15 @@ int32_t Bu::Blob::getSize() const | |||
117 | return iSize; | 128 | return iSize; |
118 | } | 129 | } |
119 | 130 | ||
131 | void Bu::Blob::setData( const char *pSrc, int32_t iSize ) | ||
132 | { | ||
133 | delete[] pData; | ||
134 | pData = new char[iSize+1]; | ||
135 | memset( pData, iSize, 1 ); | ||
136 | this->iSize = iSize; | ||
137 | memcpy( pData, pSrc, iSize ); | ||
138 | } | ||
139 | |||
120 | char *Bu::Blob::getData() const | 140 | char *Bu::Blob::getData() const |
121 | { | 141 | { |
122 | return pData; | 142 | return pData; |
@@ -817,6 +837,13 @@ Bu::Formatter &Bu::operator<<( Bu::Formatter &rOut, const Bu::Blob &b ) | |||
817 | return rOut; | 837 | return rOut; |
818 | } | 838 | } |
819 | 839 | ||
840 | Bu::Formatter &Bu::operator>>( Bu::Formatter &fIn, Bu::Blob &b ) | ||
841 | { | ||
842 | Bu::String sTmp = fIn.readToken(); | ||
843 | b.setData( sTmp.getStr(), sTmp.getSize() ); | ||
844 | return fIn; | ||
845 | } | ||
846 | |||
820 | Bu::ArchiveBase &Bu::operator<<( Bu::ArchiveBase &ar, const Bu::Blob &b ) | 847 | Bu::ArchiveBase &Bu::operator<<( Bu::ArchiveBase &ar, const Bu::Blob &b ) |
821 | { | 848 | { |
822 | int32_t iSize = b.getSize(); | 849 | int32_t iSize = b.getSize(); |