diff options
-rw-r--r-- | src/stable/archivebase.cpp | 1 | ||||
-rw-r--r-- | src/stable/archivebase.h | 2 | ||||
-rw-r--r-- | src/unstable/blob.cpp | 33 | ||||
-rw-r--r-- | src/unstable/blob.h | 6 | ||||
-rw-r--r-- | src/unstable/settingsdriverini.cpp | 1 | ||||
-rw-r--r-- | src/unstable/settingsdrivertaf.cpp | 1 |
6 files changed, 43 insertions, 1 deletions
diff --git a/src/stable/archivebase.cpp b/src/stable/archivebase.cpp index d2d80a1..c1e886b 100644 --- a/src/stable/archivebase.cpp +++ b/src/stable/archivebase.cpp | |||
@@ -6,6 +6,7 @@ | |||
6 | */ | 6 | */ |
7 | 7 | ||
8 | #include "bu/archivebase.h" | 8 | #include "bu/archivebase.h" |
9 | #include "bu/blob.h" | ||
9 | 10 | ||
10 | Bu::ArchiveBase::ArchiveBase() | 11 | Bu::ArchiveBase::ArchiveBase() |
11 | { | 12 | { |
diff --git a/src/stable/archivebase.h b/src/stable/archivebase.h index d846c27..3fd5071 100644 --- a/src/stable/archivebase.h +++ b/src/stable/archivebase.h | |||
@@ -12,10 +12,10 @@ | |||
12 | #include <unistd.h> | 12 | #include <unistd.h> |
13 | 13 | ||
14 | #include "bu/variant.h" | 14 | #include "bu/variant.h" |
15 | #include "bu/blob.h" | ||
16 | 15 | ||
17 | namespace Bu | 16 | namespace Bu |
18 | { | 17 | { |
18 | class Blob; | ||
19 | class ArchiveBase | 19 | class ArchiveBase |
20 | { | 20 | { |
21 | public: | 21 | public: |
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 | ||
58 | Bu::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 | |||
58 | Bu::Blob::Blob( const Bu::Blob::const_iterator &iStart ) : | 66 | Bu::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 | ||
107 | void 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 | |||
99 | int32_t Bu::Blob::getSize() const | 115 | int32_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 | ||
814 | Bu::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 | |||
822 | Bu::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 | |||
diff --git a/src/unstable/blob.h b/src/unstable/blob.h index bda29d6..dfddb02 100644 --- a/src/unstable/blob.h +++ b/src/unstable/blob.h | |||
@@ -9,6 +9,7 @@ | |||
9 | #define BU_BLOB_H | 9 | #define BU_BLOB_H |
10 | 10 | ||
11 | #include "bu/config.h" | 11 | #include "bu/config.h" |
12 | #include "bu/archivebase.h" | ||
12 | 13 | ||
13 | namespace Bu | 14 | namespace Bu |
14 | { | 15 | { |
@@ -40,10 +41,12 @@ namespace Bu | |||
40 | Blob( const class BlobBuilder &rSrc ); | 41 | Blob( const class BlobBuilder &rSrc ); |
41 | Blob( const char *pSrc ); | 42 | Blob( const char *pSrc ); |
42 | Blob( const void *pSrc, int32_t iSize ); | 43 | Blob( const void *pSrc, int32_t iSize ); |
44 | Blob( int32_t iSize ); | ||
43 | Blob( const const_iterator &iStart ); | 45 | Blob( const const_iterator &iStart ); |
44 | Blob( const const_iterator &iStart, const const_iterator &iEnd ); | 46 | Blob( const const_iterator &iStart, const const_iterator &iEnd ); |
45 | virtual ~Blob(); | 47 | virtual ~Blob(); |
46 | 48 | ||
49 | void setSize( int32_t iSize ); | ||
47 | int32_t getSize() const; | 50 | int32_t getSize() const; |
48 | char *getData() const; | 51 | char *getData() const; |
49 | char *c_str() const; | 52 | char *c_str() const; |
@@ -161,6 +164,9 @@ namespace Bu | |||
161 | int32_t iSize; | 164 | int32_t iSize; |
162 | }; | 165 | }; |
163 | 166 | ||
167 | ArchiveBase &operator<<( ArchiveBase &ar, const Blob &s ); | ||
168 | ArchiveBase &operator>>( ArchiveBase &ar, Blob &s ); | ||
169 | |||
164 | template<typename T> | 170 | template<typename T> |
165 | uint32_t __calcHashCode( const T &k ); | 171 | uint32_t __calcHashCode( const T &k ); |
166 | 172 | ||
diff --git a/src/unstable/settingsdriverini.cpp b/src/unstable/settingsdriverini.cpp index 31bc146..751b63c 100644 --- a/src/unstable/settingsdriverini.cpp +++ b/src/unstable/settingsdriverini.cpp | |||
@@ -4,6 +4,7 @@ | |||
4 | #include "bu/buffer.h" | 4 | #include "bu/buffer.h" |
5 | 5 | ||
6 | #include "bu/sio.h" | 6 | #include "bu/sio.h" |
7 | #include "bu/blob.h" | ||
7 | 8 | ||
8 | #include <stdlib.h> | 9 | #include <stdlib.h> |
9 | 10 | ||
diff --git a/src/unstable/settingsdrivertaf.cpp b/src/unstable/settingsdrivertaf.cpp index d99d0ba..b1077ec 100644 --- a/src/unstable/settingsdrivertaf.cpp +++ b/src/unstable/settingsdrivertaf.cpp | |||
@@ -2,6 +2,7 @@ | |||
2 | 2 | ||
3 | #include "bu/file.h" | 3 | #include "bu/file.h" |
4 | #include "bu/taf.h" | 4 | #include "bu/taf.h" |
5 | #include "bu/blob.h" | ||
5 | 6 | ||
6 | #include <stdlib.h> | 7 | #include <stdlib.h> |
7 | 8 | ||