|
Honeycomb
0.1
Component-Model Framework
|
automatically resizable buffer class based on ByteStreamBuf More...
#include <Stream.h>


Public Member Functions | |
| StreamBuf_ (szt maxSize=numeral< szt >().max(), const Alloc &alloc=Alloc()) | |
| szt | size () const |
| Get the size of the input sequence. More... | |
| szt | maxSize () const |
| Get the max sum of sizes of the input and output sequences. More... | |
| ByteBufConst | data () const |
| Get the data that represents the input sequence. More... | |
| ByteBuf | prepare (szt n) |
| Get a buffer that represents the output sequence with the given size. More... | |
| void | commit (szt n) |
| Move characters from the output sequence to the input sequence. More... | |
| void | consume (szt n) |
| Remove characters from the input sequence. More... | |
Public Member Functions inherited from honey::ByteStreamBuf | |
| ByteStreamBuf (ios_base::openmode mode=0) | |
| ByteStreamBuf (const Bytes &bs, ios_base::openmode mode=0) | |
| ByteStreamBuf (ByteStreamBuf &&rhs) | |
| ByteStreamBuf & | operator= (ByteStreamBuf &&rhs) |
| Bytes | bytes () const |
| void | bytes (const Bytes &bs) |
| std::streamsize | sgetn (byte *s, std::streamsize n) |
| int | sputbackc (byte c) |
| int | sputc (byte c) |
| std::streamsize | sputn (const byte *s, std::streamsize n) |
| byte * | eback () const |
| byte * | gptr () const |
| byte * | egptr () const |
| void | setg (byte *gbeg, byte *gnext, byte *gend) |
| byte * | pbase () const |
| byte * | pptr () const |
| byte * | epptr () const |
| void | setp (byte *new_pbase, byte *new_epptr) |
Protected Member Functions | |
| int_type | underflow () |
| Override std::streambuf behaviour. More... | |
| int_type | overflow (int_type c) |
| Override std::streambuf behaviour. More... | |
| void | reserve (szt n) |
Static Protected Attributes | |
| static const int | buf_delta = 128 |
Additional Inherited Members | |
Public Types inherited from honey::ByteStreamBuf | |
| typedef std::stringbuf | Super |
automatically resizable buffer class based on ByteStreamBuf
Examples:
Writing directly from a StreamBuf to a socket:
net::StreamBuf b; ostream os(&b); os << "Hello, World!"; szt n = sock.send(b.data()); //try sending some data from input sequence b.consume(n); //sent data is removed from input sequence
Reading from a socket directly into a StreamBuf:
net::StreamBuf b; ByteBuf buf = b.prepare(512); //reserve 512 bytes in output sequence szt n = sock.receive(buf); //receive some data into buffer b.commit(n); //received data is "committed" from output sequence to input sequence istream is(&b); String s; is >> s;
|
inline |
|
inline |
Move characters from the output sequence to the input sequence.
Appends n characters from the start of the output sequence to the input sequence. The beginning of the output sequence is advanced by n characters.
Requires a preceding call prepare(x) where x >= n, and no intervening operations that modify the input or output sequences.
n is greater than the size of the output sequence, the entire output sequence is moved to the input sequence and no error is issued.
|
inline |
Remove characters from the input sequence.
Removes n characters from the beginning of the input sequence.
n is greater than the size of the input sequence, the entire input sequence is consumed and no error is issued.
|
inline |
Get the data that represents the input sequence.
|
inline |
Get the max sum of sizes of the input and output sequences.
|
inlineprotected |
|
inline |
Get a buffer that represents the output sequence with the given size.
Ensures that the output sequence can accommodate n characters, reallocating as necessary.
|
inlineprotected |
|
inline |
Get the size of the input sequence.
|
inlineprotected |
Override std::streambuf behaviour.
Behaves according to the specification of std::streambuf::underflow().
|
staticprotected |
1.8.10