zipios 2.3.4
Zipios -- a small C++ library providing easy access to .zip files.
Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes | List of all members
zipios::ZipInputStreambuf Class Reference

An input stream buffer for Zip data. More...

#include <zipinputstreambuf.hpp>

Inheritance diagram for zipios::ZipInputStreambuf:
Inheritance graph
[legend]
Collaboration diagram for zipios::ZipInputStreambuf:
Collaboration graph
[legend]

Public Member Functions

 ZipInputStreambuf (std::streambuf *inbuf, offset_t start_pos=-1)
 Initialize a ZipInputStreambuf.
 
 ZipInputStreambuf (ZipInputStreambuf const &src)=delete
 The copy constructor is deleted.
 
virtual ~ZipInputStreambuf () override
 Clean up a ZipInputStreambuf object.
 
ZipInputStreambufoperator= (ZipInputStreambuf const &rhs)=delete
 
bool reset (offset_t stream_position=-1)
 Initializes the stream buffer.
 

Protected Member Functions

virtual std::streambuf::int_type underflow () override
 Called when more data is required.
 

Protected Attributes

std::streambuf * m_inbuf = nullptr
 
std::vector< char > m_outvec = std::vector<char>()
 

Private Attributes

ZipLocalEntry m_current_entry = ZipLocalEntry()
 
std::vector< char > m_invec = std::vector<char>()
 
offset_t m_remain = 0
 
z_stream m_zs = z_stream()
 
bool m_zs_initialized = false
 

Detailed Description

The ZipInputStreambuf class is a Zip input streambuf filter that automatically decompresses input data that was compressed using the zlib library.

Definition at line 42 of file zipinputstreambuf.hpp.

Constructor & Destructor Documentation

◆ ZipInputStreambuf() [1/2]

zipios::ZipInputStreambuf::ZipInputStreambuf ( std::streambuf *  inbuf,
offset_t  start_pos = -1 
)

This ZipInputStreambuf constructor initializes the buffer from the user specified buffer.

Parameters
[in,out]inbufThe streambuf to use for input.
[in]start_posA position to reset the inbuf to before reading. Specify -1 to read from the current position.

Definition at line 57 of file zipinputstreambuf.cpp.

References zipios::DEFLATED, zipios::getBufferSize(), zipios::FileEntry::getMethod(), zipios::FileEntry::getSize(), zipios::ZipLocalEntry::hasTrailingDataDescriptor(), zipios::FileEntry::isValid(), m_current_entry, zipios::FilterInputStreambuf::m_inbuf, zipios::InflateInputStreambuf::m_outvec, m_remain, zipios::ZipLocalEntry::read(), zipios::InflateInputStreambuf::reset(), and zipios::STORED.

◆ ZipInputStreambuf() [2/2]

zipios::ZipInputStreambuf::ZipInputStreambuf ( ZipInputStreambuf const &  src)
delete

ZipInputStreambuf objects cannot be copied so the copy constructor is deleted.

Parameters
[in]srcThe source to copy.

◆ ~ZipInputStreambuf()

zipios::ZipInputStreambuf::~ZipInputStreambuf ( )
overridevirtual

The destructor ensures that all resources get released.

Definition at line 108 of file zipinputstreambuf.cpp.

Member Function Documentation

◆ operator=()

ZipInputStreambuf & zipios::ZipInputStreambuf::operator= ( ZipInputStreambuf const &  rhs)
delete

◆ reset()

bool zipios::InflateInputStreambuf::reset ( offset_t  stream_position = -1)
inherited

This function resets the zlib stream and purges input and output buffers. It also repositions the input streambuf at stream_position.

Warning
This method is called in the constructor, so it must not read anything from the input streambuf m_inbuf (see notice in constructor.)
Parameters
[in]stream_positionA position to reset the inbuf to before reading. Specify -1 to read from the current position.
See also
InflateInputStreambuf()

Definition at line 207 of file inflateinputstreambuf.cpp.

References zipios::getBufferSize(), zipios::FilterInputStreambuf::m_inbuf, zipios::InflateInputStreambuf::m_invec, zipios::InflateInputStreambuf::m_outvec, zipios::InflateInputStreambuf::m_zs, and zipios::InflateInputStreambuf::m_zs_initialized.

Referenced by zipios::InflateInputStreambuf::InflateInputStreambuf(), and ZipInputStreambuf().

◆ underflow()

std::streambuf::int_type zipios::ZipInputStreambuf::underflow ( )
overrideprotectedvirtual

The function ensures that at least one byte is available in the input area by updating the pointers to the input area and reading more data in from the input sequence if required.

Returns
The value of that character on success or std::streambuf::traits_type::eof() on failure.

Reimplemented from zipios::InflateInputStreambuf.

Definition at line 122 of file zipinputstreambuf.cpp.

References zipios::DEFLATED, zipios::getBufferSize(), zipios::FileEntry::getMethod(), m_current_entry, zipios::FilterInputStreambuf::m_inbuf, zipios::InflateInputStreambuf::m_outvec, m_remain, zipios::STORED, and zipios::InflateInputStreambuf::underflow().

Member Data Documentation

◆ m_current_entry

ZipLocalEntry zipios::ZipInputStreambuf::m_current_entry = ZipLocalEntry()
private

Definition at line 54 of file zipinputstreambuf.hpp.

Referenced by ZipInputStreambuf(), and underflow().

◆ m_inbuf

std::streambuf* zipios::FilterInputStreambuf::m_inbuf = nullptr
protectedinherited

◆ m_invec

std::vector<char> zipios::InflateInputStreambuf::m_invec = std::vector<char>()
privateinherited

◆ m_outvec

std::vector<char> zipios::InflateInputStreambuf::m_outvec = std::vector<char>()
protectedinherited

◆ m_remain

offset_t zipios::ZipInputStreambuf::m_remain = 0
private

Definition at line 55 of file zipinputstreambuf.hpp.

Referenced by ZipInputStreambuf(), and underflow().

◆ m_zs

z_stream zipios::InflateInputStreambuf::m_zs = z_stream()
privateinherited

◆ m_zs_initialized

bool zipios::InflateInputStreambuf::m_zs_initialized = false
privateinherited

Definition at line 69 of file inflateinputstreambuf.hpp.

Referenced by zipios::InflateInputStreambuf::reset().


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