33 #ifdef __DEVELOPMENT_ASSERTIONS__
52 std::ostream&
BLOB::copy(std::ostream &output, std::istream &input,
const std::streamsize size,
const size_t buffer_size)
55 std::vector<char> buffer(buffer_size);
64 std::stringstream errmsg; errmsg <<
"input stream went bad [" << std::strerror(errno) <<
"]; " << (size-remain) <<
" of " << size <<
" bytes copied";
71 std::stringstream errmsg; errmsg <<
"input stream reached EOF [" << std::strerror(errno) <<
"]; " << (size-remain) <<
" of " << size <<
" bytes copied";
78 std::stringstream errmsg; errmsg <<
"output stream went bad [" << std::strerror(errno) <<
"]; " << (size-remain) <<
" of " << size <<
" bytes copied";
98 if (remain > buffer_size)
100 input.read(&buffer[0], buffer_size);
104 input.read(&buffer[0], remain);
108 if (!input.eof() && input.fail())
continue;
112 output.write(&buffer[0], input.gcount());
115 remain -= input.gcount();
140 : _provider(provider), _auto_delete(auto_delete)
160 _auto_delete = auto_delete;
165 return _provider->create();
178 return StringBLOB::create();
225 void MemoryBLOBProvider::StringBLOB::clear()
227 _stringstream.str(
"");
230 MemoryBLOBProvider::StringBLOB::StringBLOB()
231 :
BLOB(), _stringstream()
236 MemoryBLOBProvider::StringBLOB::~StringBLOB()
240 void MemoryBLOBProvider::StringBLOB::open()
243 _stringstream.clear();
244 _stringstream.seekp(0);
245 _stringstream.seekg(0);
248 void MemoryBLOBProvider::StringBLOB::close()
252 std::streamsize MemoryBLOBProvider::StringBLOB::__get_size()
255 std::streamoff pos = _stringstream.tellg();
257 _stringstream.seekg(0, std::ios_base::end);
258 std::streamoff size = _stringstream.tellg();
259 _stringstream.seekg(pos);
261 return static_cast<std::streamsize
>(size);
270 : ibrcommon::
BLOB(), _filestream(), _file(f)
287 _filestream.open(_file.
getPath().c_str(), ios::in|ios::binary);
289 if (!_filestream.is_open())
308 void FileBLOBProvider::TmpFileBLOB::clear()
314 _filestream.open(_tmpfile.getPath().c_str(), ios::in | ios::out | ios::trunc | ios::binary );
316 if (!_filestream.is_open())
323 FileBLOBProvider::TmpFileBLOB::TmpFileBLOB(
const File &tmppath)
324 : BLOB(), _filestream(), _fd(0), _tmpfile(tmppath,
"blob")
328 FileBLOBProvider::TmpFileBLOB::~TmpFileBLOB()
334 void FileBLOBProvider::TmpFileBLOB::open()
339 _filestream.open(_tmpfile.getPath().c_str(), ios::in | ios::out | ios::binary );
341 if (!_filestream.is_open())
348 void FileBLOBProvider::TmpFileBLOB::close()
359 std::streamsize FileBLOBProvider::TmpFileBLOB::__get_size()
361 return _tmpfile.size();