27 : _in_buf(min_buffer), _out_buf(min_buffer),
_client(client), _chunk(chunk),
28 _min_buf_size(min_buffer), _max_buf_size(max_buffer), _chunk_offset(0), _in_seq(0),
29 _streaming(wait_seq_zero), _request_ack(false), _flush_request(false), _receive_timeout(0)
48 if (_chunk.
size() == 0) {
49 _flush_request =
true;
58 _receive_timeout = timeout;
70 _client << _chunk; _client.flush();
73 _flush_request =
false;
78 if ((_chunk.
size() + _min_buf_size) <= _max_buf_size)
84 return _max_buf_size - _chunk.
size();
90 int ret = std::char_traits<char>::eq_int_type(this->
overflow(
91 std::char_traits<char>::eof()), std::char_traits<char>::eof()) ? -1
102 _flush_request = val;
107 char *ibegin = &_in_buf[0];
110 if (!std::char_traits<char>::eq_int_type(c, std::char_traits<char>::eof()))
112 *iend++ = std::char_traits<char>::to_char_type(c);
116 if ((iend - ibegin) == 0)
118 return std::char_traits<char>::not_eof(c);
125 _chunk.
append(&_in_buf[0], iend - ibegin);
131 if ((_chunk.
size() >= _max_buf_size) || _flush_request)
136 return std::char_traits<char>::not_eof(c);
152 _chunks.insert(Chunk(b));
155 _chunks_cond.
signal(
true);
169 while (_chunks.empty())
179 while ((_in_seq != (*_chunks.begin())._seq))
183 _chunks_cond.
wait(1000);
187 if (((_receive_timeout > 0) && (tm.
getSeconds() > _receive_timeout)) || !_streaming)
190 _in_seq = (*_chunks.begin())._seq;
198 const Chunk &c = (*_chunks.begin());
207 (*stream).seekg(_chunk_offset, ios::beg);
210 (*stream).read(&_out_buf[0], _out_buf.size());
213 size_t bytes = (*stream).gcount();
235 _chunk_offset += bytes;
240 setg(&_out_buf[0], &_out_buf[0], &_out_buf[0] + bytes);
242 return std::char_traits<char>::not_eof(_out_buf[0]);
246 : _bundle(b), _seq(0)
253 BundleStreamBuf::Chunk::~Chunk()
257 bool BundleStreamBuf::Chunk::operator==(
const Chunk& other)
const
259 return (_seq == other._seq);
262 bool BundleStreamBuf::Chunk::operator<(
const Chunk& other)
const
264 return (_seq < other._seq);