diff options
Diffstat (limited to 'src/stable')
-rw-r--r-- | src/stable/archive.cpp | 84 | ||||
-rw-r--r-- | src/stable/archive.h | 46 | ||||
-rw-r--r-- | src/stable/archivebinary.cpp | 190 | ||||
-rw-r--r-- | src/stable/archivebinary.h | 40 | ||||
-rw-r--r-- | src/stable/crypt.cpp | 4 | ||||
-rw-r--r-- | src/stable/membuf.cpp | 5 | ||||
-rw-r--r-- | src/stable/membuf.h | 2 | ||||
-rw-r--r-- | src/stable/string.cpp | 12 |
8 files changed, 339 insertions, 44 deletions
diff --git a/src/stable/archive.cpp b/src/stable/archive.cpp index df9b1ff..829e7eb 100644 --- a/src/stable/archive.cpp +++ b/src/stable/archive.cpp | |||
@@ -17,181 +17,205 @@ Bu::Archive::~Archive() | |||
17 | 17 | ||
18 | Bu::Archive &Bu::operator<<( Bu::Archive &ar, bool p) | 18 | Bu::Archive &Bu::operator<<( Bu::Archive &ar, bool p) |
19 | { | 19 | { |
20 | ar.write( &p, sizeof(p) ); | 20 | ar.write( p ); |
21 | return ar; | 21 | return ar; |
22 | } | 22 | } |
23 | 23 | ||
24 | Bu::Archive &Bu::operator<<( Bu::Archive &ar, char p) | 24 | Bu::Archive &Bu::operator<<( Bu::Archive &ar, char p) |
25 | { | 25 | { |
26 | ar.write( &p, sizeof(p) ); | 26 | ar.write( p ); |
27 | return ar; | 27 | return ar; |
28 | } | 28 | } |
29 | 29 | ||
30 | Bu::Archive &Bu::operator<<( Bu::Archive &ar, signed char p) | 30 | Bu::Archive &Bu::operator<<( Bu::Archive &ar, signed char p) |
31 | { | 31 | { |
32 | ar.write( &p, sizeof(p) ); | 32 | ar.write( p ); |
33 | return ar; | 33 | return ar; |
34 | } | 34 | } |
35 | 35 | ||
36 | Bu::Archive &Bu::operator<<( Bu::Archive &ar, unsigned char p) | 36 | Bu::Archive &Bu::operator<<( Bu::Archive &ar, unsigned char p) |
37 | { | 37 | { |
38 | ar.write( &p, sizeof(p) ); | 38 | ar.write( p ); |
39 | return ar; | 39 | return ar; |
40 | } | 40 | } |
41 | 41 | ||
42 | Bu::Archive &Bu::operator<<( Bu::Archive &ar, signed short p) | 42 | Bu::Archive &Bu::operator<<( Bu::Archive &ar, signed short p) |
43 | { | 43 | { |
44 | ar.write( &p, sizeof(p) ); | 44 | ar.write( p ); |
45 | return ar; | 45 | return ar; |
46 | } | 46 | } |
47 | 47 | ||
48 | Bu::Archive &Bu::operator<<( Bu::Archive &ar, unsigned short p) | 48 | Bu::Archive &Bu::operator<<( Bu::Archive &ar, unsigned short p) |
49 | { | 49 | { |
50 | ar.write( &p, sizeof(p) ); | 50 | ar.write( p ); |
51 | return ar; | 51 | return ar; |
52 | } | 52 | } |
53 | 53 | ||
54 | Bu::Archive &Bu::operator<<( Bu::Archive &ar, signed int p) | 54 | Bu::Archive &Bu::operator<<( Bu::Archive &ar, signed int p) |
55 | { | 55 | { |
56 | ar.write( &p, sizeof(p) ); | 56 | ar.write( p ); |
57 | return ar; | 57 | return ar; |
58 | } | 58 | } |
59 | 59 | ||
60 | Bu::Archive &Bu::operator<<( Bu::Archive &ar, unsigned int p) | 60 | Bu::Archive &Bu::operator<<( Bu::Archive &ar, unsigned int p) |
61 | { | 61 | { |
62 | ar.write( &p, sizeof(p) ); | 62 | ar.write( p ); |
63 | return ar; | 63 | return ar; |
64 | } | 64 | } |
65 | 65 | ||
66 | Bu::Archive &Bu::operator<<( Bu::Archive &ar, signed long p) | 66 | Bu::Archive &Bu::operator<<( Bu::Archive &ar, signed long p) |
67 | { | 67 | { |
68 | ar.write( &p, sizeof(p) ); | 68 | ar.write( p ); |
69 | return ar; | 69 | return ar; |
70 | } | 70 | } |
71 | 71 | ||
72 | Bu::Archive &Bu::operator<<( Bu::Archive &ar, unsigned long p) | 72 | Bu::Archive &Bu::operator<<( Bu::Archive &ar, unsigned long p) |
73 | { | 73 | { |
74 | ar.write( &p, sizeof(p) ); | 74 | ar.write( p ); |
75 | return ar; | 75 | return ar; |
76 | } | 76 | } |
77 | 77 | ||
78 | Bu::Archive &Bu::operator<<( Bu::Archive &ar, signed long long p) | 78 | Bu::Archive &Bu::operator<<( Bu::Archive &ar, signed long long p) |
79 | { | 79 | { |
80 | ar.write( &p, sizeof(p) ); | 80 | ar.write( p ); |
81 | return ar; | 81 | return ar; |
82 | } | 82 | } |
83 | 83 | ||
84 | Bu::Archive &Bu::operator<<( Bu::Archive &ar, unsigned long long p) | 84 | Bu::Archive &Bu::operator<<( Bu::Archive &ar, unsigned long long p) |
85 | { | 85 | { |
86 | ar.write( &p, sizeof(p) ); | 86 | ar.write( p ); |
87 | return ar; | 87 | return ar; |
88 | } | 88 | } |
89 | 89 | ||
90 | Bu::Archive &Bu::operator<<( Bu::Archive &ar, float p) | 90 | Bu::Archive &Bu::operator<<( Bu::Archive &ar, float p) |
91 | { | 91 | { |
92 | ar.write( &p, sizeof(p) ); | 92 | ar.write( p ); |
93 | return ar; | 93 | return ar; |
94 | } | 94 | } |
95 | 95 | ||
96 | Bu::Archive &Bu::operator<<( Bu::Archive &ar, double p) | 96 | Bu::Archive &Bu::operator<<( Bu::Archive &ar, double p) |
97 | { | 97 | { |
98 | ar.write( &p, sizeof(p) ); | 98 | ar.write( p ); |
99 | return ar; | 99 | return ar; |
100 | } | 100 | } |
101 | 101 | ||
102 | Bu::Archive &Bu::operator<<( Bu::Archive &ar, long double p) | 102 | Bu::Archive &Bu::operator<<( Bu::Archive &ar, long double p) |
103 | { | 103 | { |
104 | ar.write( &p, sizeof(p) ); | 104 | ar.write( p ); |
105 | return ar; | ||
106 | } | ||
107 | |||
108 | Bu::Archive &Bu::operator<<( Bu::Archive &ar, const Bu::Blob &p) | ||
109 | { | ||
110 | ar.write( p ); | ||
111 | return ar; | ||
112 | } | ||
113 | |||
114 | Bu::Archive &Bu::operator<<( Bu::Archive &ar, const Bu::Text &p) | ||
115 | { | ||
116 | ar.write( p ); | ||
105 | return ar; | 117 | return ar; |
106 | } | 118 | } |
107 | 119 | ||
108 | Bu::Archive &Bu::operator>>( Bu::Archive &ar, bool &p) | 120 | Bu::Archive &Bu::operator>>( Bu::Archive &ar, bool &p) |
109 | { | 121 | { |
110 | ar.read( &p, sizeof(p) ); | 122 | ar.read( p ); |
111 | return ar; | 123 | return ar; |
112 | } | 124 | } |
113 | 125 | ||
114 | Bu::Archive &Bu::operator>>( Bu::Archive &ar, char &p) | 126 | Bu::Archive &Bu::operator>>( Bu::Archive &ar, char &p) |
115 | { | 127 | { |
116 | ar.read( &p, sizeof(p) ); | 128 | ar.read( p ); |
117 | return ar; | 129 | return ar; |
118 | } | 130 | } |
119 | 131 | ||
120 | Bu::Archive &Bu::operator>>( Bu::Archive &ar, signed char &p) | 132 | Bu::Archive &Bu::operator>>( Bu::Archive &ar, signed char &p) |
121 | { | 133 | { |
122 | ar.read( &p, sizeof(p) ); | 134 | ar.read( p ); |
123 | return ar; | 135 | return ar; |
124 | } | 136 | } |
125 | 137 | ||
126 | Bu::Archive &Bu::operator>>( Bu::Archive &ar, unsigned char &p) | 138 | Bu::Archive &Bu::operator>>( Bu::Archive &ar, unsigned char &p) |
127 | { | 139 | { |
128 | ar.read( &p, sizeof(p) ); | 140 | ar.read( p ); |
129 | return ar; | 141 | return ar; |
130 | } | 142 | } |
131 | 143 | ||
132 | Bu::Archive &Bu::operator>>( Bu::Archive &ar, signed short &p) | 144 | Bu::Archive &Bu::operator>>( Bu::Archive &ar, signed short &p) |
133 | { | 145 | { |
134 | ar.read( &p, sizeof(p) ); | 146 | ar.read( p ); |
135 | return ar; | 147 | return ar; |
136 | } | 148 | } |
137 | 149 | ||
138 | Bu::Archive &Bu::operator>>( Bu::Archive &ar, unsigned short &p) | 150 | Bu::Archive &Bu::operator>>( Bu::Archive &ar, unsigned short &p) |
139 | { | 151 | { |
140 | ar.read( &p, sizeof(p) ); | 152 | ar.read( p ); |
141 | return ar; | 153 | return ar; |
142 | } | 154 | } |
143 | 155 | ||
144 | Bu::Archive &Bu::operator>>( Bu::Archive &ar, signed int &p) | 156 | Bu::Archive &Bu::operator>>( Bu::Archive &ar, signed int &p) |
145 | { | 157 | { |
146 | ar.read( &p, sizeof(p) ); | 158 | ar.read( p ); |
147 | return ar; | 159 | return ar; |
148 | } | 160 | } |
149 | 161 | ||
150 | Bu::Archive &Bu::operator>>( Bu::Archive &ar, unsigned int &p) | 162 | Bu::Archive &Bu::operator>>( Bu::Archive &ar, unsigned int &p) |
151 | { | 163 | { |
152 | ar.read( &p, sizeof(p) ); | 164 | ar.read( p ); |
153 | return ar; | 165 | return ar; |
154 | } | 166 | } |
155 | 167 | ||
156 | Bu::Archive &Bu::operator>>( Bu::Archive &ar, signed long &p) | 168 | Bu::Archive &Bu::operator>>( Bu::Archive &ar, signed long &p) |
157 | { | 169 | { |
158 | ar.read( &p, sizeof(p) ); | 170 | ar.read( p ); |
159 | return ar; | 171 | return ar; |
160 | } | 172 | } |
161 | 173 | ||
162 | Bu::Archive &Bu::operator>>( Bu::Archive &ar, unsigned long &p) | 174 | Bu::Archive &Bu::operator>>( Bu::Archive &ar, unsigned long &p) |
163 | { | 175 | { |
164 | ar.read( &p, sizeof(p) ); | 176 | ar.read( p ); |
165 | return ar; | 177 | return ar; |
166 | } | 178 | } |
167 | 179 | ||
168 | Bu::Archive &Bu::operator>>( Bu::Archive &ar, signed long long &p) | 180 | Bu::Archive &Bu::operator>>( Bu::Archive &ar, signed long long &p) |
169 | { | 181 | { |
170 | ar.read( &p, sizeof(p) ); | 182 | ar.read( p ); |
171 | return ar; | 183 | return ar; |
172 | } | 184 | } |
173 | 185 | ||
174 | Bu::Archive &Bu::operator>>( Bu::Archive &ar, unsigned long long &p) | 186 | Bu::Archive &Bu::operator>>( Bu::Archive &ar, unsigned long long &p) |
175 | { | 187 | { |
176 | ar.read( &p, sizeof(p) ); | 188 | ar.read( p ); |
177 | return ar; | 189 | return ar; |
178 | } | 190 | } |
179 | 191 | ||
180 | Bu::Archive &Bu::operator>>( Bu::Archive &ar, float &p) | 192 | Bu::Archive &Bu::operator>>( Bu::Archive &ar, float &p) |
181 | { | 193 | { |
182 | ar.read( &p, sizeof(p) ); | 194 | ar.read( p ); |
183 | return ar; | 195 | return ar; |
184 | } | 196 | } |
185 | 197 | ||
186 | Bu::Archive &Bu::operator>>( Bu::Archive &ar, double &p) | 198 | Bu::Archive &Bu::operator>>( Bu::Archive &ar, double &p) |
187 | { | 199 | { |
188 | ar.read( &p, sizeof(p) ); | 200 | ar.read( p ); |
189 | return ar; | 201 | return ar; |
190 | } | 202 | } |
191 | 203 | ||
192 | Bu::Archive &Bu::operator>>( Bu::Archive &ar, long double &p) | 204 | Bu::Archive &Bu::operator>>( Bu::Archive &ar, long double &p) |
193 | { | 205 | { |
194 | ar.read( &p, sizeof(p) ); | 206 | ar.read( p ); |
207 | return ar; | ||
208 | } | ||
209 | |||
210 | Bu::Archive &Bu::operator>>( Bu::Archive &ar, Bu::Blob &p) | ||
211 | { | ||
212 | ar.read( p ); | ||
213 | return ar; | ||
214 | } | ||
215 | |||
216 | Bu::Archive &Bu::operator>>( Bu::Archive &ar, Bu::Text &p) | ||
217 | { | ||
218 | ar.read( p ); | ||
195 | return ar; | 219 | return ar; |
196 | } | 220 | } |
197 | 221 | ||
diff --git a/src/stable/archive.h b/src/stable/archive.h index 45d9af6..2cd340c 100644 --- a/src/stable/archive.h +++ b/src/stable/archive.h | |||
@@ -16,6 +16,8 @@ | |||
16 | 16 | ||
17 | namespace Bu | 17 | namespace Bu |
18 | { | 18 | { |
19 | class Text; | ||
20 | |||
19 | class Archive | 21 | class Archive |
20 | { | 22 | { |
21 | public: | 23 | public: |
@@ -29,10 +31,46 @@ namespace Bu | |||
29 | }; | 31 | }; |
30 | 32 | ||
31 | virtual void close()=0; | 33 | virtual void close()=0; |
32 | virtual void write( const void *pData, size_t iLength )=0; | 34 | // virtual void write( const void *pData, size_t iLength )=0; |
33 | virtual void read( void *pData, size_t iLength )=0; | 35 | // virtual void read( void *pData, size_t iLength )=0; |
34 | virtual bool isLoading()=0; | 36 | virtual bool isLoading()=0; |
35 | 37 | ||
38 | virtual void write( bool rData )=0; | ||
39 | virtual void write( unsigned char rData )=0; | ||
40 | virtual void write( char rData )=0; | ||
41 | virtual void write( signed char rData )=0; | ||
42 | virtual void write( unsigned short rData )=0; | ||
43 | virtual void write( signed short rData )=0; | ||
44 | virtual void write( unsigned int rData )=0; | ||
45 | virtual void write( signed int rData )=0; | ||
46 | virtual void write( unsigned long rData )=0; | ||
47 | virtual void write( signed long rData )=0; | ||
48 | virtual void write( unsigned long long rData )=0; | ||
49 | virtual void write( signed long long rData )=0; | ||
50 | virtual void write( float rData )=0; | ||
51 | virtual void write( double rData )=0; | ||
52 | virtual void write( long double rData )=0; | ||
53 | virtual void write( const Bu::Blob &rData )=0; | ||
54 | virtual void write( const Bu::Text &rData )=0; | ||
55 | |||
56 | virtual void read( bool &rData )=0; | ||
57 | virtual void read( unsigned char &rData )=0; | ||
58 | virtual void read( char &rData )=0; | ||
59 | virtual void read( signed char &rData )=0; | ||
60 | virtual void read( unsigned short &rData )=0; | ||
61 | virtual void read( signed short &rData )=0; | ||
62 | virtual void read( unsigned int &rData )=0; | ||
63 | virtual void read( signed int &rData )=0; | ||
64 | virtual void read( unsigned long &rData )=0; | ||
65 | virtual void read( signed long &rData )=0; | ||
66 | virtual void read( unsigned long long &rData )=0; | ||
67 | virtual void read( signed long long &rData )=0; | ||
68 | virtual void read( float &rData )=0; | ||
69 | virtual void read( double &rData )=0; | ||
70 | virtual void read( long double &rData )=0; | ||
71 | virtual void read( Bu::Blob &rData )=0; | ||
72 | virtual void read( Bu::Text &rData )=0; | ||
73 | |||
36 | virtual void setProperty( const Bu::Blob &rKey, | 74 | virtual void setProperty( const Bu::Blob &rKey, |
37 | const Bu::Variant &rValue )=0; | 75 | const Bu::Variant &rValue )=0; |
38 | virtual Bu::Variant getProperty( const Bu::Blob &rKey ) const=0; | 76 | virtual Bu::Variant getProperty( const Bu::Blob &rKey ) const=0; |
@@ -65,6 +103,8 @@ namespace Bu | |||
65 | Archive &operator<<( Archive &ar, float p ); | 103 | Archive &operator<<( Archive &ar, float p ); |
66 | Archive &operator<<( Archive &ar, double p ); | 104 | Archive &operator<<( Archive &ar, double p ); |
67 | Archive &operator<<( Archive &ar, long double p ); | 105 | Archive &operator<<( Archive &ar, long double p ); |
106 | Archive &operator<<( Archive &ar, const Bu::Blob &p ); | ||
107 | Archive &operator<<( Archive &ar, const Bu::Text &p ); | ||
68 | 108 | ||
69 | Archive &operator>>( Archive &ar, bool &p ); | 109 | Archive &operator>>( Archive &ar, bool &p ); |
70 | Archive &operator>>( Archive &ar, char &p ); | 110 | Archive &operator>>( Archive &ar, char &p ); |
@@ -81,6 +121,8 @@ namespace Bu | |||
81 | Archive &operator>>( Archive &ar, float &p ); | 121 | Archive &operator>>( Archive &ar, float &p ); |
82 | Archive &operator>>( Archive &ar, double &p ); | 122 | Archive &operator>>( Archive &ar, double &p ); |
83 | Archive &operator>>( Archive &ar, long double &p ); | 123 | Archive &operator>>( Archive &ar, long double &p ); |
124 | Archive &operator>>( Archive &ar, Bu::Blob &p ); | ||
125 | Archive &operator>>( Archive &ar, Bu::Text &p ); | ||
84 | }; | 126 | }; |
85 | 127 | ||
86 | #endif | 128 | #endif |
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 | ||
13 | Bu::ArchiveBinary::ArchiveBinary( Stream &rStream, bool bLoading ) : | 14 | Bu::ArchiveBinary::ArchiveBinary( Stream &rStream, bool bLoading ) : |
14 | bLoading( bLoading ), | 15 | bLoading( bLoading ), |
@@ -20,7 +21,7 @@ Bu::ArchiveBinary::ArchiveBinary( Stream &rStream, bool bLoading ) : | |||
20 | Bu::ArchiveBinary::~ArchiveBinary() | 21 | Bu::ArchiveBinary::~ArchiveBinary() |
21 | { | 22 | { |
22 | } | 23 | } |
23 | 24 | /* | |
24 | void Bu::ArchiveBinary::write( const void *pData, size_t nSize ) | 25 | void 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 | |||
42 | void Bu::ArchiveBinary::write( bool rData ) | ||
43 | { | ||
44 | rStream.write( &rData, sizeof(rData) ); | ||
45 | } | ||
46 | |||
47 | void Bu::ArchiveBinary::write( const unsigned char rData ) | ||
48 | { | ||
49 | rStream.write( &rData, sizeof(rData) ); | ||
50 | } | ||
51 | |||
52 | void Bu::ArchiveBinary::write( char rData ) | ||
53 | { | ||
54 | rStream.write( &rData, sizeof(rData) ); | ||
55 | } | ||
56 | |||
57 | void Bu::ArchiveBinary::write( signed char rData ) | ||
58 | { | ||
59 | rStream.write( &rData, sizeof(rData) ); | ||
60 | } | ||
61 | |||
62 | void Bu::ArchiveBinary::write( unsigned short rData ) | ||
63 | { | ||
64 | rStream.write( &rData, sizeof(rData) ); | ||
65 | } | ||
66 | |||
67 | void Bu::ArchiveBinary::write( signed short rData ) | ||
68 | { | ||
69 | rStream.write( &rData, sizeof(rData) ); | ||
70 | } | ||
71 | |||
72 | void Bu::ArchiveBinary::write( unsigned int rData ) | ||
73 | { | ||
74 | rStream.write( &rData, sizeof(rData) ); | ||
75 | } | ||
76 | |||
77 | void Bu::ArchiveBinary::write( signed int rData ) | ||
78 | { | ||
79 | rStream.write( &rData, sizeof(rData) ); | ||
80 | } | ||
81 | |||
82 | void Bu::ArchiveBinary::write( unsigned long rData ) | ||
83 | { | ||
84 | rStream.write( &rData, sizeof(rData) ); | ||
85 | } | ||
86 | |||
87 | void Bu::ArchiveBinary::write( signed long rData ) | ||
88 | { | ||
89 | rStream.write( &rData, sizeof(rData) ); | ||
90 | } | ||
91 | |||
92 | void Bu::ArchiveBinary::write( unsigned long long rData ) | ||
93 | { | ||
94 | rStream.write( &rData, sizeof(rData) ); | ||
95 | } | ||
96 | |||
97 | void Bu::ArchiveBinary::write( signed long long rData ) | ||
98 | { | ||
99 | rStream.write( &rData, sizeof(rData) ); | ||
100 | } | ||
101 | |||
102 | void Bu::ArchiveBinary::write( float rData ) | ||
103 | { | ||
104 | rStream.write( &rData, sizeof(rData) ); | ||
105 | } | ||
106 | |||
107 | void Bu::ArchiveBinary::write( double rData ) | ||
108 | { | ||
109 | rStream.write( &rData, sizeof(rData) ); | ||
110 | } | ||
111 | |||
112 | void Bu::ArchiveBinary::write( long double rData ) | ||
113 | { | ||
114 | rStream.write( &rData, sizeof(rData) ); | ||
115 | } | ||
116 | |||
117 | void 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 | |||
124 | void 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 | |||
131 | void Bu::ArchiveBinary::read( bool &rData ) | ||
132 | { | ||
133 | rStream.read( &rData, sizeof(rData) ); | ||
134 | } | ||
135 | |||
136 | void Bu::ArchiveBinary::read( unsigned char &rData ) | ||
137 | { | ||
138 | rStream.read( &rData, sizeof(rData) ); | ||
139 | } | ||
140 | |||
141 | void Bu::ArchiveBinary::read( char &rData ) | ||
142 | { | ||
143 | rStream.read( &rData, sizeof(rData) ); | ||
144 | } | ||
145 | |||
146 | void Bu::ArchiveBinary::read( signed char &rData ) | ||
147 | { | ||
148 | rStream.read( &rData, sizeof(rData) ); | ||
149 | } | ||
150 | |||
151 | void Bu::ArchiveBinary::read( unsigned short &rData ) | ||
152 | { | ||
153 | rStream.read( &rData, sizeof(rData) ); | ||
154 | } | ||
155 | |||
156 | void Bu::ArchiveBinary::read( signed short &rData ) | ||
157 | { | ||
158 | rStream.read( &rData, sizeof(rData) ); | ||
159 | } | ||
160 | |||
161 | void Bu::ArchiveBinary::read( unsigned int &rData ) | ||
162 | { | ||
163 | rStream.read( &rData, sizeof(rData) ); | ||
164 | } | ||
165 | |||
166 | void Bu::ArchiveBinary::read( signed int &rData ) | ||
167 | { | ||
168 | rStream.read( &rData, sizeof(rData) ); | ||
169 | } | ||
170 | |||
171 | void Bu::ArchiveBinary::read( unsigned long &rData ) | ||
172 | { | ||
173 | rStream.read( &rData, sizeof(rData) ); | ||
174 | } | ||
175 | |||
176 | void Bu::ArchiveBinary::read( signed long &rData ) | ||
177 | { | ||
178 | rStream.read( &rData, sizeof(rData) ); | ||
179 | } | ||
180 | |||
181 | void Bu::ArchiveBinary::read( unsigned long long &rData ) | ||
182 | { | ||
183 | rStream.read( &rData, sizeof(rData) ); | ||
184 | } | ||
185 | |||
186 | void Bu::ArchiveBinary::read( signed long long &rData ) | ||
187 | { | ||
188 | rStream.read( &rData, sizeof(rData) ); | ||
189 | } | ||
190 | |||
191 | void Bu::ArchiveBinary::read( float &rData ) | ||
192 | { | ||
193 | rStream.read( &rData, sizeof(rData) ); | ||
194 | } | ||
195 | |||
196 | void Bu::ArchiveBinary::read( double &rData ) | ||
197 | { | ||
198 | rStream.read( &rData, sizeof(rData) ); | ||
199 | } | ||
200 | |||
201 | void Bu::ArchiveBinary::read( long double &rData ) | ||
202 | { | ||
203 | rStream.read( &rData, sizeof(rData) ); | ||
204 | } | ||
205 | |||
206 | void 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 | |||
216 | void 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 | ||
41 | void Bu::ArchiveBinary::close() | 229 | void Bu::ArchiveBinary::close() |
diff --git a/src/stable/archivebinary.h b/src/stable/archivebinary.h index 4c12e02..d28e5e7 100644 --- a/src/stable/archivebinary.h +++ b/src/stable/archivebinary.h | |||
@@ -77,8 +77,44 @@ namespace Bu | |||
77 | virtual ~ArchiveBinary(); | 77 | virtual ~ArchiveBinary(); |
78 | virtual void close(); | 78 | virtual void close(); |
79 | 79 | ||
80 | virtual void write( const void *pData, size_t iSize ); | 80 | //virtual void write( const void *pData, size_t iSize ); |
81 | virtual void read( void *pData, size_t iSize ); | 81 | //virtual void read( void *pData, size_t iSize ); |
82 | |||
83 | virtual void write( bool rData ); | ||
84 | virtual void write( unsigned char rData ); | ||
85 | virtual void write( char rData ); | ||
86 | virtual void write( signed char rData ); | ||
87 | virtual void write( unsigned short rData ); | ||
88 | virtual void write( signed short rData ); | ||
89 | virtual void write( unsigned int rData ); | ||
90 | virtual void write( signed int rData ); | ||
91 | virtual void write( unsigned long rData ); | ||
92 | virtual void write( signed long rData ); | ||
93 | virtual void write( unsigned long long rData ); | ||
94 | virtual void write( signed long long rData ); | ||
95 | virtual void write( float rData ); | ||
96 | virtual void write( double rData ); | ||
97 | virtual void write( long double rData ); | ||
98 | virtual void write( const Bu::Blob &rData ); | ||
99 | virtual void write( const Bu::Text &rData ); | ||
100 | |||
101 | virtual void read( bool &rData ); | ||
102 | virtual void read( unsigned char &rData ); | ||
103 | virtual void read( char &rData ); | ||
104 | virtual void read( signed char &rData ); | ||
105 | virtual void read( unsigned short &rData ); | ||
106 | virtual void read( signed short &rData ); | ||
107 | virtual void read( unsigned int &rData ); | ||
108 | virtual void read( signed int &rData ); | ||
109 | virtual void read( unsigned long &rData ); | ||
110 | virtual void read( signed long &rData ); | ||
111 | virtual void read( unsigned long long &rData ); | ||
112 | virtual void read( signed long long &rData ); | ||
113 | virtual void read( float &rData ); | ||
114 | virtual void read( double &rData ); | ||
115 | virtual void read( long double &rData ); | ||
116 | virtual void read( Bu::Blob &rData ); | ||
117 | virtual void read( Bu::Text &rData ); | ||
82 | 118 | ||
83 | /** | 119 | /** |
84 | * For storage, get an ID for the pointer to the object you're going to | 120 | * For storage, get an ID for the pointer to the object you're going to |
diff --git a/src/stable/crypt.cpp b/src/stable/crypt.cpp index 085d460..0dbe2d5 100644 --- a/src/stable/crypt.cpp +++ b/src/stable/crypt.cpp | |||
@@ -26,7 +26,7 @@ Bu::String Bu::cryptPass( const Bu::String &sPass, const Bu::String &sSalt ) | |||
26 | 26 | ||
27 | b64Out.stop(); | 27 | b64Out.stop(); |
28 | 28 | ||
29 | return sSaltSml + "$" + mbOut.getString(); | 29 | return sSaltSml + "$" + mbOut.getBlob(); |
30 | } | 30 | } |
31 | 31 | ||
32 | Bu::String Bu::cryptPass( const Bu::String &sPass ) | 32 | Bu::String Bu::cryptPass( const Bu::String &sPass ) |
@@ -42,6 +42,6 @@ Bu::String Bu::cryptPass( const Bu::String &sPass ) | |||
42 | 42 | ||
43 | b64Salt.stop(); | 43 | b64Salt.stop(); |
44 | 44 | ||
45 | return cryptPass( sPass, mbSalt.getString() ); | 45 | return cryptPass( sPass, mbSalt.getBlob() ); |
46 | } | 46 | } |
47 | 47 | ||
diff --git a/src/stable/membuf.cpp b/src/stable/membuf.cpp index 040c0c6..fff3027 100644 --- a/src/stable/membuf.cpp +++ b/src/stable/membuf.cpp | |||
@@ -169,6 +169,11 @@ Bu::String &Bu::MemBuf::getString() | |||
169 | return sBuf; | 169 | return sBuf; |
170 | } | 170 | } |
171 | 171 | ||
172 | Bu::Blob Bu::MemBuf::getBlob() | ||
173 | { | ||
174 | return Bu::Blob( sBuf.getStr(), sBuf.getSize() ); | ||
175 | } | ||
176 | |||
172 | void Bu::MemBuf::setString( const Bu::String &sNewData ) | 177 | void Bu::MemBuf::setString( const Bu::String &sNewData ) |
173 | { | 178 | { |
174 | sBuf = sNewData; | 179 | sBuf = sNewData; |
diff --git a/src/stable/membuf.h b/src/stable/membuf.h index fc9be1f..f42cc2d 100644 --- a/src/stable/membuf.h +++ b/src/stable/membuf.h | |||
@@ -13,6 +13,7 @@ | |||
13 | #include "bu/config.h" | 13 | #include "bu/config.h" |
14 | #include "bu/stream.h" | 14 | #include "bu/stream.h" |
15 | #include "bu/string.h" | 15 | #include "bu/string.h" |
16 | #include "bu/blob.h" | ||
16 | 17 | ||
17 | namespace Bu | 18 | namespace Bu |
18 | { | 19 | { |
@@ -57,6 +58,7 @@ namespace Bu | |||
57 | virtual Bu::String getLocation() const; | 58 | virtual Bu::String getLocation() const; |
58 | 59 | ||
59 | Bu::String &getString(); | 60 | Bu::String &getString(); |
61 | Bu::Blob getBlob(); | ||
60 | void setString( const Bu::String &sNewData ); | 62 | void setString( const Bu::String &sNewData ); |
61 | 63 | ||
62 | private: | 64 | private: |
diff --git a/src/stable/string.cpp b/src/stable/string.cpp index c36b768..81f2c7f 100644 --- a/src/stable/string.cpp +++ b/src/stable/string.cpp | |||
@@ -1520,20 +1520,18 @@ Bu::String &Bu::operator<<( Bu::String &dst, const Bu::String &sIn ) | |||
1520 | return dst; | 1520 | return dst; |
1521 | } | 1521 | } |
1522 | 1522 | ||
1523 | #include "bu/blob.h" | ||
1524 | |||
1523 | Bu::Archive &Bu::operator<<( Bu::Archive &ar, const Bu::String &s ) | 1525 | Bu::Archive &Bu::operator<<( Bu::Archive &ar, const Bu::String &s ) |
1524 | { | 1526 | { |
1525 | long n = s.getSize(); | 1527 | ar << Bu::Blob( s.getStr(), s.getSize() ); |
1526 | ar << n; | ||
1527 | ar.write( s.getConstStr(), n ); | ||
1528 | return ar; | 1528 | return ar; |
1529 | } | 1529 | } |
1530 | 1530 | ||
1531 | Bu::Archive &Bu::operator>>( Bu::Archive &ar, Bu::String &s ) | 1531 | Bu::Archive &Bu::operator>>( Bu::Archive &ar, Bu::String &s ) |
1532 | { | 1532 | { |
1533 | long n; | 1533 | Bu::Blob b; |
1534 | ar >> n; | 1534 | ar >> b; |
1535 | s.setSize( n ); | ||
1536 | ar.read( s.getStr(), n ); | ||
1537 | return ar; | 1535 | return ar; |
1538 | } | 1536 | } |
1539 | 1537 | ||