Rosetta  2020.37
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
zlib_stream::basic_zip_streambuf< Elem, Tr, ElemA, ByteT, ByteAT > Class Template Reference

A stream decorator that takes raw input and zips it to a ostream. More...

#include <zipstream.hpp>

Inheritance diagram for zlib_stream::basic_zip_streambuf< Elem, Tr, ElemA, ByteT, ByteAT >:
Inheritance graph
[legend]

Public Types

typedef std::basic_streambuf
< Elem, Tr > 
basic_streambuf_type
 
typedef std::basic_ostream
< Elem, Tr > & 
ostream_reference
 
typedef Elem char_type
 
typedef ElemA char_allocator_type
 
typedef ByteT byte_type
 
typedef ByteAT byte_allocator_type
 
typedef byte_typebyte_buffer_type
 
typedef std::vector< byte_type,
byte_allocator_type
byte_vector_type
 
typedef std::vector< char_type,
char_allocator_type
char_vector_type
 
typedef Tr traits_type
 
typedef Tr::int_type int_type
 

Public Member Functions

 basic_zip_streambuf (ostream_reference ostream_, size_t level_, EStrategy strategy_, size_t window_size_, size_t memory_level_, size_t buffer_size_)
 Construct a zip stream. More...
 
 ~basic_zip_streambuf () override
 
int sync () override
 
int_type overflow (int_type c) override
 
std::streamsize flush ()
 flushes the zip buffer and output buffer More...
 
std::streamsize flush_finalize ()
 flushes the zip buffer and output buffer and finalize the zip stream More...
 
void reset_state ()
 resets the zip stream and zeros the crc More...
 
ostream_reference get_ostream () const
 returns a reference to the output stream More...
 
int get_zerr () const
 returns the latest zlib error status More...
 
uLong get_crc () const
 returns the crc of the input data compressed so far More...
 
uLong get_in_size () const
 returns the size (bytes) of the input data compressed so far More...
 
uLong get_out_size () const
 returns the size (bytes) of the compressed data so far More...
 

Private Member Functions

bool zip_to_stream (char_type *, std::streamsize)
 
size_t fill_input_buffer ()
 
std::streamsize flush (int flush_mode)
 flush the zip buffer using a particular mode and flush output buffer More...
 

Private Attributes

ostream_reference m_ostream
 
z_stream m_zip_stream
 
int m_err
 
byte_vector_type m_output_buffer
 
char_vector_type m_buffer
 
uLong m_crc
 

Detailed Description

template<typename Elem, typename Tr = std::char_traits< Elem >, typename ElemA = std::allocator< Elem >, typename ByteT = unsigned char, typename ByteAT = std::allocator< ByteT >>
class zlib_stream::basic_zip_streambuf< Elem, Tr, ElemA, ByteT, ByteAT >

A stream decorator that takes raw input and zips it to a ostream.

Note
The class wraps up the inflate method of the zlib library 1.1.4 http://www.gzip.org/zlib/

Member Typedef Documentation

template<typename Elem, typename Tr = std::char_traits< Elem >, typename ElemA = std::allocator< Elem >, typename ByteT = unsigned char, typename ByteAT = std::allocator< ByteT >>
typedef std::basic_streambuf< Elem, Tr > zlib_stream::basic_zip_streambuf< Elem, Tr, ElemA, ByteT, ByteAT >::basic_streambuf_type
template<typename Elem, typename Tr = std::char_traits< Elem >, typename ElemA = std::allocator< Elem >, typename ByteT = unsigned char, typename ByteAT = std::allocator< ByteT >>
typedef ByteAT zlib_stream::basic_zip_streambuf< Elem, Tr, ElemA, ByteT, ByteAT >::byte_allocator_type
template<typename Elem, typename Tr = std::char_traits< Elem >, typename ElemA = std::allocator< Elem >, typename ByteT = unsigned char, typename ByteAT = std::allocator< ByteT >>
typedef byte_type* zlib_stream::basic_zip_streambuf< Elem, Tr, ElemA, ByteT, ByteAT >::byte_buffer_type
template<typename Elem, typename Tr = std::char_traits< Elem >, typename ElemA = std::allocator< Elem >, typename ByteT = unsigned char, typename ByteAT = std::allocator< ByteT >>
typedef ByteT zlib_stream::basic_zip_streambuf< Elem, Tr, ElemA, ByteT, ByteAT >::byte_type
template<typename Elem, typename Tr = std::char_traits< Elem >, typename ElemA = std::allocator< Elem >, typename ByteT = unsigned char, typename ByteAT = std::allocator< ByteT >>
typedef std::vector< byte_type, byte_allocator_type > zlib_stream::basic_zip_streambuf< Elem, Tr, ElemA, ByteT, ByteAT >::byte_vector_type
template<typename Elem, typename Tr = std::char_traits< Elem >, typename ElemA = std::allocator< Elem >, typename ByteT = unsigned char, typename ByteAT = std::allocator< ByteT >>
typedef ElemA zlib_stream::basic_zip_streambuf< Elem, Tr, ElemA, ByteT, ByteAT >::char_allocator_type
template<typename Elem, typename Tr = std::char_traits< Elem >, typename ElemA = std::allocator< Elem >, typename ByteT = unsigned char, typename ByteAT = std::allocator< ByteT >>
typedef Elem zlib_stream::basic_zip_streambuf< Elem, Tr, ElemA, ByteT, ByteAT >::char_type
template<typename Elem, typename Tr = std::char_traits< Elem >, typename ElemA = std::allocator< Elem >, typename ByteT = unsigned char, typename ByteAT = std::allocator< ByteT >>
typedef std::vector< char_type, char_allocator_type > zlib_stream::basic_zip_streambuf< Elem, Tr, ElemA, ByteT, ByteAT >::char_vector_type
template<typename Elem, typename Tr = std::char_traits< Elem >, typename ElemA = std::allocator< Elem >, typename ByteT = unsigned char, typename ByteAT = std::allocator< ByteT >>
typedef Tr::int_type zlib_stream::basic_zip_streambuf< Elem, Tr, ElemA, ByteT, ByteAT >::int_type
template<typename Elem, typename Tr = std::char_traits< Elem >, typename ElemA = std::allocator< Elem >, typename ByteT = unsigned char, typename ByteAT = std::allocator< ByteT >>
typedef std::basic_ostream< Elem, Tr >& zlib_stream::basic_zip_streambuf< Elem, Tr, ElemA, ByteT, ByteAT >::ostream_reference
template<typename Elem, typename Tr = std::char_traits< Elem >, typename ElemA = std::allocator< Elem >, typename ByteT = unsigned char, typename ByteAT = std::allocator< ByteT >>
typedef Tr zlib_stream::basic_zip_streambuf< Elem, Tr, ElemA, ByteT, ByteAT >::traits_type

Constructor & Destructor Documentation

template<typename Elem , typename Tr , typename ElemA , typename ByteT , typename ByteAT >
zlib_stream::basic_zip_streambuf< Elem, Tr, ElemA, ByteT, ByteAT >::basic_zip_streambuf ( ostream_reference  ostream_,
size_t  level_,
EStrategy  strategy_,
size_t  window_size_,
size_t  memory_level_,
size_t  buffer_size_ 
)
template<typename Elem , typename Tr , typename ElemA , typename ByteT , typename ByteAT >
zlib_stream::basic_zip_streambuf< Elem, Tr, ElemA, ByteT, ByteAT >::~basic_zip_streambuf ( )
override

Member Function Documentation

template<typename Elem, typename Tr = std::char_traits< Elem >, typename ElemA = std::allocator< Elem >, typename ByteT = unsigned char, typename ByteAT = std::allocator< ByteT >>
size_t zlib_stream::basic_zip_streambuf< Elem, Tr, ElemA, ByteT, ByteAT >::fill_input_buffer ( )
private
template<typename Elem , typename Tr , typename ElemA , typename ByteT , typename ByteAT >
std::streamsize zlib_stream::basic_zip_streambuf< Elem, Tr, ElemA, ByteT, ByteAT >::flush ( )

flushes the zip buffer and output buffer

template<typename Elem , typename Tr , typename ElemA , typename ByteT , typename ByteAT >
std::streamsize zlib_stream::basic_zip_streambuf< Elem, Tr, ElemA, ByteT, ByteAT >::flush ( int  flush_mode)
private

flush the zip buffer using a particular mode and flush output buffer

References numeric::remainder().

template<typename Elem , typename Tr , typename ElemA , typename ByteT , typename ByteAT >
std::streamsize zlib_stream::basic_zip_streambuf< Elem, Tr, ElemA, ByteT, ByteAT >::flush_finalize ( )

flushes the zip buffer and output buffer and finalize the zip stream

This method should be called at the end of the compression.

template<typename Elem, typename Tr = std::char_traits< Elem >, typename ElemA = std::allocator< Elem >, typename ByteT = unsigned char, typename ByteAT = std::allocator< ByteT >>
uLong zlib_stream::basic_zip_streambuf< Elem, Tr, ElemA, ByteT, ByteAT >::get_crc ( ) const
inline

returns the crc of the input data compressed so far

References zlib_stream::basic_zip_streambuf< Elem, Tr, ElemA, ByteT, ByteAT >::m_crc.

template<typename Elem, typename Tr = std::char_traits< Elem >, typename ElemA = std::allocator< Elem >, typename ByteT = unsigned char, typename ByteAT = std::allocator< ByteT >>
uLong zlib_stream::basic_zip_streambuf< Elem, Tr, ElemA, ByteT, ByteAT >::get_in_size ( ) const
inline

returns the size (bytes) of the input data compressed so far

References zlib_stream::basic_zip_streambuf< Elem, Tr, ElemA, ByteT, ByteAT >::m_zip_stream.

template<typename Elem, typename Tr = std::char_traits< Elem >, typename ElemA = std::allocator< Elem >, typename ByteT = unsigned char, typename ByteAT = std::allocator< ByteT >>
ostream_reference zlib_stream::basic_zip_streambuf< Elem, Tr, ElemA, ByteT, ByteAT >::get_ostream ( ) const
inline

returns a reference to the output stream

References zlib_stream::basic_zip_streambuf< Elem, Tr, ElemA, ByteT, ByteAT >::m_ostream.

template<typename Elem, typename Tr = std::char_traits< Elem >, typename ElemA = std::allocator< Elem >, typename ByteT = unsigned char, typename ByteAT = std::allocator< ByteT >>
uLong zlib_stream::basic_zip_streambuf< Elem, Tr, ElemA, ByteT, ByteAT >::get_out_size ( ) const
inline

returns the size (bytes) of the compressed data so far

References zlib_stream::basic_zip_streambuf< Elem, Tr, ElemA, ByteT, ByteAT >::m_zip_stream.

template<typename Elem, typename Tr = std::char_traits< Elem >, typename ElemA = std::allocator< Elem >, typename ByteT = unsigned char, typename ByteAT = std::allocator< ByteT >>
int zlib_stream::basic_zip_streambuf< Elem, Tr, ElemA, ByteT, ByteAT >::get_zerr ( ) const
inline

returns the latest zlib error status

References zlib_stream::basic_zip_streambuf< Elem, Tr, ElemA, ByteT, ByteAT >::m_err.

template<typename Elem, typename Tr = std::char_traits< Elem >, typename ElemA = std::allocator< Elem >, typename ByteT = unsigned char, typename ByteAT = std::allocator< ByteT >>
basic_zip_streambuf< Elem, Tr, ElemA, ByteT, ByteAT >::int_type zlib_stream::basic_zip_streambuf< Elem, Tr, ElemA, ByteT, ByteAT >::overflow ( int_type  c)
override
template<typename Elem , typename Tr , typename ElemA , typename ByteT , typename ByteAT >
void zlib_stream::basic_zip_streambuf< Elem, Tr, ElemA, ByteT, ByteAT >::reset_state ( )

resets the zip stream and zeros the crc

This method should be called after flush_finalize() to allow future writes

template<typename Elem , typename Tr , typename ElemA , typename ByteT , typename ByteAT >
int zlib_stream::basic_zip_streambuf< Elem, Tr, ElemA, ByteT, ByteAT >::sync ( )
override
template<typename Elem, typename Tr = std::char_traits< Elem >, typename ElemA = std::allocator< Elem >, typename ByteT = unsigned char, typename ByteAT = std::allocator< ByteT >>
bool zlib_stream::basic_zip_streambuf< Elem, Tr, ElemA, ByteT, ByteAT >::zip_to_stream ( char_type ,
std::streamsize   
)
private

References numeric::remainder().

Member Data Documentation

template<typename Elem, typename Tr = std::char_traits< Elem >, typename ElemA = std::allocator< Elem >, typename ByteT = unsigned char, typename ByteAT = std::allocator< ByteT >>
char_vector_type zlib_stream::basic_zip_streambuf< Elem, Tr, ElemA, ByteT, ByteAT >::m_buffer
private
template<typename Elem, typename Tr = std::char_traits< Elem >, typename ElemA = std::allocator< Elem >, typename ByteT = unsigned char, typename ByteAT = std::allocator< ByteT >>
uLong zlib_stream::basic_zip_streambuf< Elem, Tr, ElemA, ByteT, ByteAT >::m_crc
private
template<typename Elem, typename Tr = std::char_traits< Elem >, typename ElemA = std::allocator< Elem >, typename ByteT = unsigned char, typename ByteAT = std::allocator< ByteT >>
int zlib_stream::basic_zip_streambuf< Elem, Tr, ElemA, ByteT, ByteAT >::m_err
private
template<typename Elem, typename Tr = std::char_traits< Elem >, typename ElemA = std::allocator< Elem >, typename ByteT = unsigned char, typename ByteAT = std::allocator< ByteT >>
ostream_reference zlib_stream::basic_zip_streambuf< Elem, Tr, ElemA, ByteT, ByteAT >::m_ostream
private
template<typename Elem, typename Tr = std::char_traits< Elem >, typename ElemA = std::allocator< Elem >, typename ByteT = unsigned char, typename ByteAT = std::allocator< ByteT >>
byte_vector_type zlib_stream::basic_zip_streambuf< Elem, Tr, ElemA, ByteT, ByteAT >::m_output_buffer
private
template<typename Elem, typename Tr = std::char_traits< Elem >, typename ElemA = std::allocator< Elem >, typename ByteT = unsigned char, typename ByteAT = std::allocator< ByteT >>
z_stream zlib_stream::basic_zip_streambuf< Elem, Tr, ElemA, ByteT, ByteAT >::m_zip_stream
private

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