Definition
An object mb of the class memory_streambuf can be used as source or target stream for a coder and allows encoding and decoding in memory (i.e. without file accesses). Every read or write operation is forwarded to a buffer in memory. This buffer is directly accessible by the user. The length of this buffer is called the capacity of mb. The size of mb is the number of characters that can be read from or written to the stream before an underflow/overflow occurs. (In that case the corresponding stream operation returns EOF (end-of-file).) Thus the capacity is the maximum size that mb can have without reallocating its buffer.
#include < LEDA/coding/memory_streambuf.h >
Creation
memory_streambuf | mb(streamsize buf_sz = 0, bool wipe_buf = false) | |
creates an object mb with capacity and size buf_sz. The parameter wipe_buf determines whether wipe_buffer is called when the buffer is not needed any more. | ||
memory_streambuf | mb(char* buf, streamsize buf_sz, bool own_buf = false, bool wipe_buf = false) | |
creates an object mb with the memory buffer buf and sets the capacity and the size to buf_sz. If own_buf/wipe_buf is true, then buf is deleted/wiped by mb when it is not used anymore. Note that buf is not copied but it is used as the internal buffer of mb. |
Operations