byteme
Read/write bytes from various sources
Loading...
Searching...
No Matches
byteme::IstreamReader< Pointer_ > Class Template Referencefinal

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)
 
std::size_t read (unsigned char *buffer, std::size_t n)
 
- Public Member Functions inherited from byteme::Reader

Detailed Description

template<class Pointer_>
class byteme::IstreamReader< Pointer_ >

Read bytes from a std::istream.

Template Parameters
Pointer_Pointer to a class providing an input stream of bytes, satisfying the std::istream interface. This is most typically a std::unique_ptr<std::istream> but a pointer to a concrete subclass may also be used to encourage devirtualization. Either a raw or smart pointer may be used depending on how the lifetime of the pointed-to object is managed.

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_ >
byteme::IstreamReader< Pointer_ >::IstreamReader ( Pointer_ input)
inline
Parameters
inputPointer to an input stream.

Member Function Documentation

◆ read()

template<class Pointer_ >
std::size_t byteme::IstreamReader< Pointer_ >::read ( unsigned char * buffer,
std::size_t n )
inlinevirtual

Read the specified number of bytes from the source into a user-supplied buffer.

Parameters
[out]bufferPointer to an array of at least length n.
nMaximum number of bytes to extract from the source. This may be zero.
Returns
Number of bytes that were actually extracted from the source. This will be less than or equal to n. If less than n, the stream of bytes from the source is finished and no more calls to read() should be performed.

Implements byteme::Reader.


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