hamcast
Version 0.7
|
#include <write_buffer.hpp>
Public Member Functions | |
write_buffer () | |
~write_buffer () | |
void | reserve (size_t arg) |
size_t | capacity () const |
size_t | remaining () const |
size_t | size () const |
const char * | data () const |
void | write (size_t buf_size, const void *buf) |
std::pair< size_t, void * > | take () |
void | clear () |
virtual void | flush () |
virtual void | close () |
virtual bool | closed () const |
![]() | |
virtual int | flush_hint () const |
![]() | |
long | ref_count () |
Additional Inherited Members | |
![]() | |
static void | add_ref (ref_counted *rc) |
static void | release (ref_counted *rc) |
![]() | |
ref_counted () | |
void | ref () |
bool | deref () |
A mutable (growing) buffer that could be used as a sink.
The write_buffer class provides a representation of a mutable output buffer that automatically grows up to maximum_size
bytes.
block_size
buffered_sink allocates storage always in chunks to minimize resizing of the internal buffer. maximum_size
The maximum number of bytes buffered_sink is allowed to allocate.
hamcast::util::write_buffer< block_size, maximum_size >::write_buffer | ( | ) |
Create a buffered sink that decorates underlying_sink
.
underlying_sink
is valid hamcast::util::write_buffer< block_size, maximum_size >::~write_buffer | ( | ) |
Deletes the decorated sink.
size_t hamcast::util::write_buffer< block_size, maximum_size >::capacity | ( | ) | const |
Get the size of the allocated storage.
void hamcast::util::write_buffer< block_size, maximum_size >::clear | ( | ) |
Clear the internal buffer.
|
virtual |
Close the data channel.
Implements hamcast::util::closeable.
|
virtual |
Check if the data channel is closed.
true
if this
is closed for read/write operations; otherwise false
. Implements hamcast::util::closeable.
const char* hamcast::util::write_buffer< block_size, maximum_size >::data | ( | ) | const |
Get the written data.
|
virtual |
Force the data sink to flush any buffers.
Any | exception that might be thrown by write(). |
Implements hamcast::util::sink.
size_t hamcast::util::write_buffer< block_size, maximum_size >::remaining | ( | ) | const |
Get the number of remaining (unwritten) bytes in the allocated storage.
capacity() - size()
. void hamcast::util::write_buffer< block_size, maximum_size >::reserve | ( | size_t | arg | ) |
Increase capacity() to at least arg
bytes.
arg | The new minimum size of this . |
size_t hamcast::util::write_buffer< block_size, maximum_size >::size | ( | ) | const |
Get the number of currently used bytes.
std::pair<size_t, void*> hamcast::util::write_buffer< block_size, maximum_size >::take | ( | ) |
|
virtual |
Writes buf_size
bytes from buf
to the internal buffer.
buf_size | The size of buf in bytes. |
buf | A pointer to a C-buffer that contains the data to write. |
buf_size > 0 && buf != NULL
. Implements hamcast::util::sink.