RPNX::Compress
Self-contained C++20 compression and ZIP library
 
Loading...
Searching...
No Matches
rpnx::compression::implementation::byte_reader< input_iterator, sentinel > Class Template Reference

Single-pass byte reader over an input iterator and sentinel. More...

#include <io.hpp>

Public Member Functions

 byte_reader (input_iterator first, sentinel last)
 Constructs a reader over an iterator range.
 
bool empty () const
 Tests whether no unread byte remains.
 
bool peek (std::byte &value)
 Inspects the next byte without consuming it.
 
bool read (std::byte &value)
 Reads one byte.
 
bool read (std::uint8_t &value)
 Reads one byte as an unsigned integer.
 
std::size_t consumed () const noexcept
 Returns the number of bytes consumed from the source.
 

Detailed Description

template<std::input_iterator input_iterator, std::sentinel_for< input_iterator > sentinel>
class rpnx::compression::implementation::byte_reader< input_iterator, sentinel >

Single-pass byte reader over an input iterator and sentinel.

Template Parameters
input_iteratorInput iterator yielding std::byte or one-byte integral values.
sentinelSentinel type for the input iterator.

One byte of lookahead supports format-boundary checks without requiring a forward iterator. The consumed count excludes a byte held by peek().

Definition at line 70 of file io.hpp.

Constructor & Destructor Documentation

◆ byte_reader()

template<std::input_iterator input_iterator, std::sentinel_for< input_iterator > sentinel>
rpnx::compression::implementation::byte_reader< input_iterator, sentinel >::byte_reader ( input_iterator first,
sentinel last )
inline

Constructs a reader over an iterator range.

Parameters
firstIterator to the first byte.
lastSentinel past the final byte.

Definition at line 78 of file io.hpp.

Member Function Documentation

◆ consumed()

template<std::input_iterator input_iterator, std::sentinel_for< input_iterator > sentinel>
std::size_t rpnx::compression::implementation::byte_reader< input_iterator, sentinel >::consumed ( ) const
inlinenodiscardnoexcept

Returns the number of bytes consumed from the source.

Returns
Successful read count; a byte retained by peek() is not included.

Definition at line 155 of file io.hpp.

◆ empty()

template<std::input_iterator input_iterator, std::sentinel_for< input_iterator > sentinel>
bool rpnx::compression::implementation::byte_reader< input_iterator, sentinel >::empty ( ) const
inlinenodiscard

Tests whether no unread byte remains.

Returns
true if neither lookahead nor the source contains another byte.

Definition at line 86 of file io.hpp.

Referenced by rpnx::compression::bzip2_codec::decompress(), rpnx::compression::deflate_codec::decompress(), rpnx::compression::lz4_codec::decompress(), rpnx::compression::xz_codec::decompress(), and rpnx::compression::zstandard_codec::decompress().

◆ peek()

template<std::input_iterator input_iterator, std::sentinel_for< input_iterator > sentinel>
bool rpnx::compression::implementation::byte_reader< input_iterator, sentinel >::peek ( std::byte & value)
inlinenodiscard

Inspects the next byte without consuming it.

Parameters
valueReceives the next byte on success and is unchanged at end of input.
Returns
true if a byte was available; false at end of input.

Definition at line 96 of file io.hpp.

References rpnx::compression::implementation::to_byte().

Referenced by rpnx::compression::xz_codec::decompress().

◆ read() [1/2]

template<std::input_iterator input_iterator, std::sentinel_for< input_iterator > sentinel>
bool rpnx::compression::implementation::byte_reader< input_iterator, sentinel >::read ( std::byte & value)
inlinenodiscard

Reads one byte.

Parameters
valueReceives the byte on success and is unchanged at end of input.
Returns
true if a byte was consumed; false at end of input.

Definition at line 116 of file io.hpp.

References rpnx::compression::implementation::to_byte().

Referenced by rpnx::compression::deflate_codec::decompress(), rpnx::compression::lz4_codec::decompress(), rpnx::compression::xz_codec::decompress(), rpnx::compression::zstandard_codec::decompress(), and read().

◆ read() [2/2]

template<std::input_iterator input_iterator, std::sentinel_for< input_iterator > sentinel>
bool rpnx::compression::implementation::byte_reader< input_iterator, sentinel >::read ( std::uint8_t & value)
inlinenodiscard

Reads one byte as an unsigned integer.

Parameters
valueReceives the byte on success and is unchanged at end of input.
Returns
true if a byte was consumed; false at end of input.

Definition at line 140 of file io.hpp.

References read().


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