7 namespace honey {
namespace net
35 template<
class Alloc = std::allocator<byte>>
45 setg(&_buf[0], &_buf[0], &_buf[0]);
46 setp(&_buf[0], &_buf[0] + pend);
110 return traits_type::to_int_type(*
gptr());
113 return traits_type::eof();
125 if (!traits_type::eq_int_type(c, traits_type::eof()))
130 if (_bufsize < _maxSize && _maxSize - _bufsize < buf_delta)
136 *
pptr() = traits_type::to_char_type(c);
141 return traits_type::not_eof(c);
152 if (n <= pend - pnext)
return;
158 std::memmove(&_buf[0], &_buf[0] + gnext, pnext);
162 if (n > pend - pnext)
164 if (n <= _maxSize && pnext <= _maxSize - n)
170 throw std::length_error(
"buffer too large");
174 setg(&_buf[0], &_buf[0], &_buf[0] + pnext);
175 setp(&_buf[0] + pnext, &_buf[0] + pend);
180 vector<byte, Alloc> _buf;
automatically resizable buffer class based on ByteStreamBuf
Definition: Stream.h:36
int_type overflow(int_type c)
Override std::streambuf behaviour.
Definition: Stream.h:123
byte * egptr() const
Definition: ByteStream.h:46
A contiguous region of referenced (not owned by object) memory.
Definition: Buffer.h:17
static const int buf_delta
Definition: Stream.h:99
byte * epptr() const
Definition: ByteStream.h:51
StreamBuf_(szt maxSize=numeral< szt >().max(), const Alloc &alloc=Alloc())
Definition: Stream.h:39
Buffer< const byte > ByteBufConst
Definition: Bytes.h:21
StreamBuf_ StreamBuf
Definition: Stream.h:183
Inherit to declare that class is not copyable.
Definition: Meta.h:286
void reserve(szt n)
Definition: Stream.h:144
byte * gptr() const
Definition: ByteStream.h:45
static std::common_type< Num, Num2 >::type max(Num a, Num2 b)
Get the maximum of two numbers.
Definition: Alge.h:94
static std::common_type< Num, Num2 >::type min(Num a, Num2 b)
Get the minimum of two numbers.
Definition: Alge.h:89
void setg(byte *gbeg, byte *gnext, byte *gend)
Definition: ByteStream.h:47
size_t szt
Size type, shorthand for size_t.
Definition: Core.h:90
T * alloc(szt count=1)
Allocate memory for count number of T objects. Objects are not constructed.
Definition: Allocator.h:31
Buffer< byte > ByteBuf
A buffer of bytes.
Definition: Bytes.h:20
void setp(byte *new_pbase, byte *new_epptr)
Definition: ByteStream.h:52
ByteBuf prepare(szt n)
Get a buffer that represents the output sequence with the given size.
Definition: Stream.h:64
int_type underflow()
Override std::streambuf behaviour.
Definition: Stream.h:105
ByteBufConst data() const
Get the data that represents the input sequence.
Definition: Stream.h:54
void commit(szt n)
Move characters from the output sequence to the input sequence.
Definition: Stream.h:77
szt size() const
Get the size of the input sequence.
Definition: Stream.h:50
byte * pptr() const
Definition: ByteStream.h:50
Global Honeycomb namespace.
void consume(szt n)
Remove characters from the input sequence.
Definition: Stream.h:91
byte * eback() const
Definition: ByteStream.h:44
A stream I/O buffer of bytes, to be passed into ByteStream.
Definition: ByteStream.h:17
szt maxSize() const
Get the max sum of sizes of the input and output sequences.
Definition: Stream.h:52