byteme
C++ wrappers for buffered inputs
Loading...
Searching...
No Matches
byteme::IstreamReader< Pointer_ > Class Template Reference

Read bytes from a std::istream. More...

#include <IstreamReader.hpp>

Inheritance diagram for byteme::IstreamReader< Pointer_ >:
Collaboration diagram for byteme::IstreamReader< Pointer_ >:

Public Member Functions

 IstreamReader (Pointer_ input, size_t buffer_size=65536)
 
bool load ()
 
const unsigned char * buffer () const
 
size_t available () const
 
- Public Member Functions inherited from byteme::Reader

Detailed Description

template<class Pointer_ = std::istream*>
class byteme::IstreamReader< Pointer_ >

Read bytes from a std::istream.

Template Parameters
Pointer_A (possibly smart) pointer to an std::istream object.

This is just a wrapper around std::istream::read, mostly to avoid having to remember the correct way to check for end of file.

Constructor & Destructor Documentation

◆ IstreamReader()

template<class Pointer_ = std::istream*>
byteme::IstreamReader< Pointer_ >::IstreamReader ( Pointer_ input,
size_t buffer_size = 65536 )
inline
Parameters
inputPointer to an input stream.
buffer_sizeSize of the buffer to use for reading.

Member Function Documentation

◆ available()

template<class Pointer_ = std::istream*>
size_t byteme::IstreamReader< Pointer_ >::available ( ) const
inlinevirtual

This method should only be called after load() has been called and returns true. The return value is generally expected to be positive; however, it is possible to return a zero. Note that zero values should not be interpreted as the end of the source, which is strictly only defined by load() returning false.

Returns
Number of available bytes in buffer().

Implements byteme::Reader.

◆ buffer()

template<class Pointer_ = std::istream*>
const unsigned char * byteme::IstreamReader< Pointer_ >::buffer ( ) const
inlinevirtual

This method should only be called after load() has been called and returns true.

Returns
Pointer to the start of an array containing the available bytes. The number of available bytes is provided in available().

Implements byteme::Reader.

◆ load()

template<class Pointer_ = std::istream*>
bool byteme::IstreamReader< Pointer_ >::load ( )
inlinevirtual

Read the next chunk of bytes from the input source. To read the entire source, this function should be called repeatedly until false is returned.

Returns
Boolean indicating whether the read was successful. If false, it can be assumed that the end of the source was reached.

Implements byteme::Reader.


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