byteme
C++ wrappers for buffered inputs
|
Perform byte-by-byte extraction from a Reader
source.
More...
#include <PerByte.hpp>
Public Member Functions | |
PerByte (Pointer_ reader) | |
bool | valid () const |
bool | advance () |
Type_ | get () const |
size_t | position () const |
std::pair< size_t, bool > | extract (size_t number, Type_ *output) |
Perform byte-by-byte extraction from a Reader
source.
Type_ | Character type to return, usually char for text or unsigned char for binary. |
Pointer_ | A (possibly smart) non-const pointer to a Reader . |
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 |
reader | A (possibly smart) pointer to a Reader object. |
|
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 |
|
inline |