byteme
C++ wrappers for buffered inputs
|
Interface for byte-by-byte extraction from a Reader
source.
More...
#include <PerByte.hpp>
Public Member Functions | |
bool | advance () |
Type_ | get () const |
unsigned long long | position () const |
bool | valid () const |
std::pair< std::size_t, bool > | extract (std::size_t number, Type_ *output) |
Protected Member Functions | |
virtual void | refill ()=0 |
Protected Attributes | |
const Type_ * | ptr = nullptr |
std::size_t | available = 0 |
Interface for byte-by-byte extraction from a Reader
source.
Type_ | Type of the output bytes, usually char for text or unsigned char for binary. |
This wraps a Reader
so that developers can avoid the boilerplate of managing blocks of bytes, when all they want is to iterate over the bytes of the input.
|
inline |
|
inline |
Extract up to number
bytes from the Reader
source and store them in the output
. This is equivalent to (but more efficient than) calling get()
and then advance()
up to number
times, only iterating while the return value of advance()
is still true. The number of successful iterations is returned in the output as the first pair element, while the return value of the final advance()
is returned as the second pair element.
number | Number of bytes to extract. | |
[out] | output | Pointer to an output buffer of length number . This is filled with up to number bytes from the source. |
|
inline |
This should only be called if valid()
is true
.
|
inline |
|
protectedpure virtual |
Set ptr
and available
to refer to an array of new bytes from a Reader
.
Implemented in byteme::PerByteParallel< Type_, Pointer_ >, and byteme::PerByteSerial< Type_, Pointer_ >.
|
inline |
|
protected |
Length of the array at ptr
.
|
protected |
Pointer to an array of bytes, to be set by refill()
whenever available > 0
.