byteme
C++ wrappers for buffered inputs
Loading...
Searching...
No Matches
byteme::ChunkedBufferReader Class Reference

Read chunks of bytes from a raw buffer. More...

#include <ChunkedBufferReader.hpp>

Inheritance diagram for byteme::ChunkedBufferReader:
Collaboration diagram for byteme::ChunkedBufferReader:

Public Member Functions

 ChunkedBufferReader (const unsigned char *buffer, size_t length, size_t chunk_size)
 
 ChunkedBufferReader (const char *buffer, size_t length, size_t chunk_size)
 
bool load ()
 
const unsigned char * buffer () const
 
size_t available () const
 
- Public Member Functions inherited from byteme::Reader

Detailed Description

Read chunks of bytes from a raw buffer.

This is basically the same as RawBufferReader except that chunks of bytes are returned on every load() call. It is primarily intended for use in tests of byteme callers, to ensure that downstream algorithms behave correctly with respect to chunked reads.

Constructor & Destructor Documentation

◆ ChunkedBufferReader() [1/2]

byteme::ChunkedBufferReader::ChunkedBufferReader ( const unsigned char * buffer,
size_t length,
size_t chunk_size )
inline
Parameters
[in]bufferPointer to an array of bytes, usually containing text.
lengthLength of the buffer.
chunk_sizeSize of each chunk in bytes.

◆ ChunkedBufferReader() [2/2]

byteme::ChunkedBufferReader::ChunkedBufferReader ( const char * buffer,
size_t length,
size_t chunk_size )
inline
Parameters
[in]bufferPointer to an array of bytes, usually containing text.
lengthLength of the buffer.
chunk_sizeSize of each chunk in bytes.

Member Function Documentation

◆ available()

size_t byteme::ChunkedBufferReader::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()

const unsigned char * byteme::ChunkedBufferReader::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()

bool byteme::ChunkedBufferReader::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: