8 #define SOCI_FIREBIRD_SOURCE 16 : session_(session), from_db_(false), bhp_(0), loaded_(false),
36 std::size_t offset,
char * buf, std::size_t toRead)
44 std::size_t size =
data_.size();
48 throw soci_error(
"Can't read past-the-end of BLOB data");
52 std::size_t limit = size - offset < toRead ? size - offset : toRead;
53 std::size_t index = 0;
57 *itr =
data_[offset+index];
74 std::size_t size =
data_.size();
78 throw soci_error(
"Can't write past-the-end of BLOB data");
82 if (toWrite > (size - offset))
84 data_.resize(size + (toWrite - (size - offset)));
93 char const * buf, std::size_t toWrite)
101 std::size_t size =
data_.size();
102 data_.resize(size + toWrite);
117 data_.resize(newLen);
121 char const * buf, std::size_t toWrite)
123 char const * itr = buf;
124 char const * end_itr = buf + toWrite;
128 data_[offset++] = *itr++;
152 data_.resize(blob_size);
166 if (isc_close_blob(stat, &
bhp_))
183 unsigned short bytes;
184 std::vector<char>::size_type total_bytes = 0;
185 bool keep_reading =
false;
193 &
data_[total_bytes]);
195 total_bytes += bytes;
197 if (total_bytes ==
data_.size())
200 keep_reading =
false;
202 else if (stat[1] == 0 || stat[1] == isc_segment)
208 else if (stat[1] == isc_segstr_eof)
211 keep_reading =
false;
219 while (keep_reading);
233 if (isc_close_blob(stat, &
bhp_))
247 if (
data_.size() > 0)
250 if (isc_put_segment(stat, &
bhp_,
251 static_cast<unsigned short>(
data_.size()), &
data_[0]))
265 char blob_items[] = {isc_info_blob_max_segment, isc_info_blob_total_length};
266 char res_buffer[20], *p, item;
268 long total_length = 0;
272 if (isc_blob_info(stat, &
bhp_,
sizeof(blob_items), blob_items,
273 sizeof(res_buffer), res_buffer))
278 for (p = res_buffer; *p != isc_info_end ;)
281 length =
static_cast<short>(isc_vax_integer(p, 2));
285 case isc_info_blob_max_segment:
288 case isc_info_blob_total_length:
289 total_length = isc_vax_integer(p, length);
291 case isc_info_truncated:
292 throw soci_error(
"Fatal Error: BLOB info truncated!");
std::vector< char > data_
virtual std::size_t append(char const *buf, std::size_t toWrite)
firebird_blob_backend(firebird_session_backend &session)
virtual void writeBuffer(std::size_t offset, char const *buf, std::size_t toWrite)
virtual std::size_t write(std::size_t offset, char const *buf, std::size_t toWrite)
firebird_session_backend & session_
void throw_iscerror(ISC_STATUS *status_vector)
virtual long getBLOBInfo()
virtual std::size_t read(std::size_t offset, char *buf, std::size_t toRead)
virtual std::size_t get_len()
virtual void trim(std::size_t newLen)