Buffered input stream.
More...
#include <base/io/BufferedInputStream.h>
Inherits FilterInputStream.
Buffered input stream.
A FilterInputStream that adds buffer functionality to an InputStream for added performance. MT-unsafe implementation.
- Version
- 1.0
◆ BufferedInputStream() [1/2]
BufferedInputStream::BufferedInputStream |
( |
| ) |
|
Initializes the buffered input stream.
◆ BufferedInputStream() [2/2]
Initializes the buffered input stream.
- Parameters
-
in | The input stream. |
size | The size of the buffer. Default is given by DEFAULT_BUFFER_SIZE. |
◆ ~BufferedInputStream()
BufferedInputStream::~BufferedInputStream |
( |
| ) |
|
Destroy buffered input stream.
◆ available()
unsigned int BufferedInputStream::available |
( |
| ) |
const |
|
virtual |
Returns the number of bytes that can be read or skipped over without blocking.
- Returns
- Available number of bytes in stream.
Implements InputStream.
◆ fill()
void BufferedInputStream::fill |
( |
| ) |
|
Requests buffer to be filled.
◆ getElements()
const uint8* BufferedInputStream::getElements |
( |
| ) |
const |
|
inlinenoexcept |
Returns the unread bytes of the internal buffer as sequence. The size of the sequence is returned by getNumberOfBytes() or peek().
◆ getNumberOfBytes()
unsigned int BufferedInputStream::getNumberOfBytes |
( |
| ) |
const |
|
inlinenoexcept |
Returns the number of bytes currently available in the internal buffer. This is not the same as available() which also includes buffered bytes of the linked input stream.
◆ isEmpty()
bool BufferedInputStream::isEmpty |
( |
| ) |
const |
|
inlinenoexcept |
Returns true if the internal buffer is empty.
◆ peek()
unsigned int BufferedInputStream::peek |
( |
unsigned int |
count | ) |
|
This function ensures that the requested number of bytes is available in the internal buffer. Use getElements() afterwards to examine the content of the buffer.
- Parameters
-
count | The number of bytes to peek ahead. |
- Returns
- The number of bytes in the internal buffer (only less than the requested number of bytes if EOF is hit).
◆ read()
unsigned int BufferedInputStream::read |
( |
uint8 * |
buffer, |
|
|
unsigned int |
size, |
|
|
bool |
nonblocking = false |
|
) |
| |
|
virtual |
Fills the specified buffer with bytes from the stream. Blocks if asked to read more bytes than available.
- Parameters
-
buffer | The buffer to receive the bytes. |
size | The size of the buffer. |
nonblocking | Specifies that the method may not block. Default is false. |
- Returns
- The actual number of bytes read from the stream.
Implements InputStream.
◆ skip()
unsigned int BufferedInputStream::skip |
( |
unsigned int |
count | ) |
|
|
virtual |
Skips a specified number of bytes. Blocks if asked to skip more bytes than available.
- Parameters
-
count | The number of bytes to skip. |
- Returns
- The actual number of bytes skipped.
Implements InputStream.
◆ wait() [1/2]
void BufferedInputStream::wait |
( |
| ) |
const |
|
virtual |
Blocking wait for input to become available.
Implements InputStream.
◆ wait() [2/2]
bool BufferedInputStream::wait |
( |
unsigned int |
timeout | ) |
const |
|
virtual |
Blocking wait for input to become available.
- Parameters
-
timeout | The timeout periode in microseconds. |
- Returns
- True, if data is available. False, if the timeout periode expired.
Implements InputStream.
◆ buffer
The internal buffer used to store data temporarily.
◆ count
unsigned int BufferedInputStream::count = 0 |
|
protected |
The current number of bytes in the buffer.
◆ DEFAULT_BUFFER_SIZE
const unsigned int BufferedInputStream::DEFAULT_BUFFER_SIZE = 4096 |
|
static |
The default size of the buffer.
◆ MINIMUM_BUFFER_SIZE
const unsigned int BufferedInputStream::MINIMUM_BUFFER_SIZE = 1024 |
|
static |
◆ position
unsigned int BufferedInputStream::position = 0 |
|
protected |
The current position in the buffer.