33 #ifdef __DEVELOPMENT_ASSERTIONS__
46 : _const_size(intitial_size)
63 std::ostream&
BLOB::copy(std::ostream &output, std::istream &input,
const std::streamsize size,
const size_t buffer_size)
66 std::vector<char> buffer(buffer_size);
75 std::stringstream errmsg; errmsg <<
"input stream went bad [" << std::strerror(errno) <<
"]; " << (size-remain) <<
" of " << size <<
" bytes copied";
82 std::stringstream errmsg; errmsg <<
"input stream reached EOF [" << std::strerror(errno) <<
"]; " << (size-remain) <<
" of " << size <<
" bytes copied";
89 std::stringstream errmsg; errmsg <<
"output stream went bad [" << std::strerror(errno) <<
"]; " << (size-remain) <<
" of " << size <<
" bytes copied";
109 if (remain > buffer_size)
111 input.read(&buffer[0], buffer_size);
115 input.read(&buffer[0], remain);
119 if (!input.eof() && input.fail())
continue;
123 output.write(&buffer[0], input.gcount());
126 remain -= input.gcount();
151 : _provider(provider), _auto_delete(auto_delete)
171 _auto_delete = auto_delete;
176 return _provider->create();
189 return StringBLOB::create();
217 return _blob->size();
241 void MemoryBLOBProvider::StringBLOB::clear()
243 _stringstream.str(
"");
246 MemoryBLOBProvider::StringBLOB::StringBLOB()
247 :
BLOB(), _stringstream()
252 MemoryBLOBProvider::StringBLOB::~StringBLOB()
256 void MemoryBLOBProvider::StringBLOB::open()
259 _stringstream.clear();
260 _stringstream.seekp(0);
261 _stringstream.seekg(0);
264 void MemoryBLOBProvider::StringBLOB::close()
268 std::streamsize MemoryBLOBProvider::StringBLOB::__get_size()
271 std::streamoff pos = _stringstream.tellg();
274 _stringstream.clear();
276 _stringstream.seekg(0, std::ios_base::end);
277 std::streamoff
size = _stringstream.tellg();
278 _stringstream.seekg(pos);
280 return static_cast<std::streamsize
>(
size);
289 : ibrcommon::
BLOB(f.size()), _filestream(), _file(f)
306 _filestream.open(_file.
getPath().c_str(), ios::in|ios::binary);
308 if (!_filestream.is_open())
327 void FileBLOBProvider::TmpFileBLOB::clear()
333 _filestream.open(_tmpfile.getPath().c_str(), ios::in | ios::out | ios::trunc | ios::binary );
335 if (!_filestream.is_open())
342 FileBLOBProvider::TmpFileBLOB::TmpFileBLOB(
const File &tmppath)
343 : BLOB(), _filestream(), _fd(0), _tmpfile(tmppath,
"blob")
347 FileBLOBProvider::TmpFileBLOB::~TmpFileBLOB()
353 void FileBLOBProvider::TmpFileBLOB::open()
358 _filestream.open(_tmpfile.getPath().c_str(), ios::in | ios::out | ios::binary );
360 if (!_filestream.is_open())
367 void FileBLOBProvider::TmpFileBLOB::close()
378 std::streamsize FileBLOBProvider::TmpFileBLOB::__get_size()
380 return _tmpfile.size();