#include <buffered_source.hpp>
template<size_t block_size = default_block_size, size_t maximum_size = default_max_write_buffer_size>
class hamcast::util::buffered_source< block_size, maximum_size >
A decorator class that adds a read buffer to an otherwise unbuffered source.
- Parameters
-
block_size | buffered_source allocates storage always in chunks to minimize resizing of the internal buffer. |
maximum_size | The maximum number of bytes buffered_source should allocate. |
template<size_t block_size = default_block_size, size_t maximum_size = default_max_write_buffer_size>
Create a buffered source that decorates underlying_source
.
- Parameters
-
underlying_source | The original source. |
- Precondition
underlying_source
is valid
template<size_t block_size = default_block_size, size_t maximum_size = default_max_write_buffer_size>
template<size_t block_size = default_block_size, size_t maximum_size = default_max_write_buffer_size>
Check if the data channel is closed.
- Returns
true
if this
is closed for read/write operations; otherwise false
.
Implements hamcast::util::closeable.
template<size_t block_size = default_block_size, size_t maximum_size = default_max_write_buffer_size>
Read buf_size
bytes from the data source. This function blocks until enough bytes are available and throws and exception if the source becomes unreadable before buf_size
bytes are read.
- Parameters
-
buf_size | The size of buf . |
buf | The target buffer. |
- Precondition
- lock_read() was called
- Exceptions
-
std::ios_base::failure | on errors during read (e.g. if the source is closed) |
Implements hamcast::util::source.
template<size_t block_size = default_block_size, size_t maximum_size = default_max_write_buffer_size>
Read up to buf_size
bytes from the data source and store the bytes in buf
. A closed source always returns 0.
- Parameters
-
buf_size | The size of buf . |
buf | The target buffer. |
- Returns
- The number of readed bytes (might be <
buf_size
).
- Precondition
- lock_read() was called
- Exceptions
-
std::ios_base::failure | on errors during read. |
Implements hamcast::util::source.
template<size_t block_size = default_block_size, size_t maximum_size = default_max_write_buffer_size>
Wait until this source becomes "ready" or until a timeout occurs.
- Parameters
-
seconds | The seconds part of the maximum block time. |
microseconds | The microseconds part of the maximum block time. |
- Returns
true
if there is data to read; otherwise false
- Precondition
- lock_read() was called
- Exceptions
-
std::ios_base::failure | if the source becomes closed |
Implements hamcast::util::source.
The documentation for this class was generated from the following file:
- hamcast/util/buffered_source.hpp