MPD
0.20.18
|
This objects handles buffered reads in decoder plugins easily. More...
#include <DecoderBuffer.hxx>
Public Member Functions | |
DecoderBuffer (DecoderClient *_client, InputStream &_is, size_t _size) | |
Creates a new buffer. More... | |
const InputStream & | GetStream () const noexcept |
void | Clear () noexcept |
bool | Fill () |
Read data from the InputStream and append it to the buffer. More... | |
gcc_pure size_t | GetAvailable () const noexcept |
How many bytes are stored in the buffer? More... | |
ConstBuffer< void > | Read () const noexcept |
Reads data from the buffer. More... | |
ConstBuffer< void > | Need (size_t min_size) |
Wait until this number of bytes are available. More... | |
void | Consume (size_t nbytes) noexcept |
Consume (delete, invalidate) a part of the buffer. More... | |
bool | Skip (size_t nbytes) |
Skips the specified number of bytes, discarding its data. More... | |
This objects handles buffered reads in decoder plugins easily.
You create a buffer object, and use its high-level methods to fill and read it. It will automatically handle shifting the buffer.
Definition at line 38 of file DecoderBuffer.hxx.
|
inline |
Creates a new buffer.
_client | the decoder client, used for decoder_read(), may be nullptr |
_is | the input stream object where we should read from |
_size | the maximum size of the buffer |
Definition at line 53 of file DecoderBuffer.hxx.
|
inlinenoexcept |
Definition at line 61 of file DecoderBuffer.hxx.
|
inlinenoexcept |
Consume (delete, invalidate) a part of the buffer.
The "nbytes" parameter must not be larger than the length returned by Read().
nbytes | the number of bytes to consume |
Definition at line 105 of file DecoderBuffer.hxx.
bool DecoderBuffer::Fill | ( | ) |
Read data from the InputStream and append it to the buffer.
|
inlinenoexcept |
How many bytes are stored in the buffer?
Definition at line 78 of file DecoderBuffer.hxx.
|
inlinenoexcept |
Definition at line 57 of file DecoderBuffer.hxx.
ConstBuffer<void> DecoderBuffer::Need | ( | size_t | min_size | ) |
Wait until this number of bytes are available.
Returns nullptr on error.
|
inlinenoexcept |
Reads data from the buffer.
This data is not yet consumed, you have to call Consume() to do that. The returned buffer becomes invalid after a Fill() or a Consume() call.
Definition at line 87 of file DecoderBuffer.hxx.
bool DecoderBuffer::Skip | ( | size_t | nbytes | ) |
Skips the specified number of bytes, discarding its data.
nbytes | the number of bytes to skip |