MPD 0.20.6

- Main Page
- Namespaces
- Data Structures
- Files

- Data Structures
- Class Hierarchy
- Data Fields

Public Member Functions
DecoderBuffer Class Reference

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
void | Clear ()
bool | Fill ()
| Read data from the InputStream and append it to the buffer. More...
gcc_pure size_t | GetAvailable () const
| How many bytes are stored in the buffer? More...
ConstBuffer< void > | Read () const
| 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)
| Consume (delete, invalidate) a part of the buffer. More...
bool | Skip (size_t nbytes)
| Skips the specified number of bytes, discarding its data. More...

## Detailed Description

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.

## Constructor & Destructor Documentation

DecoderBuffer::DecoderBuffer | ( | DecoderClient * | _client,
|  | InputStream & | _is,
|  | size_t | _size
| ) |  |
| inline

Creates a new buffer.

Parameters

  _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.

## Member Function Documentation

void DecoderBuffer::Clear | ( |  | ) |
| inline

Definition at line 61 of file DecoderBuffer.hxx.

void DecoderBuffer::Consume | ( | size_t | nbytes | ) |
| inline

Consume (delete, invalidate) a part of the buffer.

The "nbytes" parameter must not be larger than the length returned by Read().

Parameters

  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.

Returns
  true if data was appended; false if there is no data available (yet), end of file, I/O error or a decoder command was received

gcc_pure size_t DecoderBuffer::GetAvailable | ( |  | ) | const
| inline

How many bytes are stored in the buffer?

Definition at line 78 of file DecoderBuffer.hxx.

const InputStream& DecoderBuffer::GetStream | ( |  | ) | const
| inline

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.

ConstBuffer<void> DecoderBuffer::Read | ( |  | ) | const
| inline

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.

Parameters

  nbytes | the number of bytes to skip

Returns
  true on success, false on error

The documentation for this class was generated from the following file:

- decoder/DecoderBuffer.hxx