Rosetta
|
#include <zipstream.hpp>
Public Types | |
typedef basic_zip_ostreambase< Elem, Tr, ElemA, ByteT, ByteAT > | zip_ostreambase_type |
typedef std::basic_ostream< Elem, Tr > | ostream_type |
typedef std::basic_ostream< Elem, Tr > & | ostream_reference |
typedef Elem | char_type |
![]() | |
typedef std::basic_ostream< Elem, std::char_traits< Elem > > & | ostream_reference |
typedef basic_zip_streambuf< Elem, std::char_traits< Elem >, std::allocator< Elem >, unsigned char, std::allocator< unsigned char > > | zip_streambuf_type |
Public Member Functions | |
basic_zip_ostream (ostream_reference ostream_, bool is_gzip_=false, size_t level_=Z_DEFAULT_COMPRESSION, EStrategy strategy_=DefaultStrategy, size_t window_size_=15, size_t memory_level_=8, size_t buffer_size_=default_buffer_size) | |
Constructs a zipper ostream decorator. More... | |
~basic_zip_ostream () override | |
bool | is_gzip () const |
returns true if it is a gzip More... | |
basic_zip_ostream< Elem, Tr > & | zflush () |
flush inner buffer and zipper buffer More... | |
basic_zip_ostream< Elem, Tr > & | zflush_finalize () |
flush inner and zipper buffers and finalize zip stream More... | |
template<typename T > | |
basic_zip_ostream & | operator<< (T const &t) |
stream output More... | |
basic_zip_ostream & | put (char const c) |
write char More... | |
basic_zip_ostream & | write (char const *str, std::streamsize const count) |
write a string More... | |
zip_streambuf_type * | rdbuf () |
returns the underlying zip ostream object More... | |
![]() | |
basic_zip_ostreambase (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... | |
zip_streambuf_type * | rdbuf () |
returns the underlying zip ostream object More... | |
int | get_zerr () const |
returns the zlib error state More... | |
uLong | get_crc () const |
returns the uncompressed data crc More... | |
uLong | get_out_size () const |
returns the compressed data size More... | |
uLong | get_in_size () const |
returns the uncompressed data size More... | |
Private Member Functions | |
bool | reset_zip_stream () |
if end of stream, reset the zip stream and add header More... | |
void | add_header () |
void | add_footer () |
Static Private Member Functions | |
static void | put_long_as_uint32 (ostream_reference out_, unsigned long x_) |
Private Attributes | |
bool | m_is_gzip |
bool | m_zip_stream_finalized |
tracks to see if zip stream was finalized More... | |
A zipper ostream.
This class is a ostream decorator that behaves 'almost' like any other ostream.
At construction, it takes any ostream that shall be used to output of the compressed data.
When finished, you need to call the special method zflush or call the destructor to flush all the intermidiate streams.
Example:
typedef Elem zlib_stream::basic_zip_ostream< Elem, Tr, ElemA, ByteT, ByteAT >::char_type |
typedef std::basic_ostream< Elem, Tr >& zlib_stream::basic_zip_ostream< Elem, Tr, ElemA, ByteT, ByteAT >::ostream_reference |
typedef std::basic_ostream< Elem, Tr > zlib_stream::basic_zip_ostream< Elem, Tr, ElemA, ByteT, ByteAT >::ostream_type |
typedef basic_zip_ostreambase< Elem, Tr, ElemA, ByteT, ByteAT > zlib_stream::basic_zip_ostream< Elem, Tr, ElemA, ByteT, ByteAT >::zip_ostreambase_type |
|
inline |
Constructs a zipper ostream decorator.
ostream_ | ostream where the compressed output is written |
is_gzip_ | true if gzip header and footer have to be added |
level_ | level of compression 0, bad and fast, 9, good and slower, |
strategy_ | compression strategy |
window_size_ | see zlib doc |
memory_level_ | see zlib doc |
buffer_size_ | the buffer size used to zip data |
References zlib_stream::basic_zip_ostream< Elem, Tr, ElemA, ByteT, ByteAT >::add_header(), and zlib_stream::basic_zip_ostream< Elem, Tr, ElemA, ByteT, ByteAT >::m_is_gzip.
|
inlineoverride |
|
private |
|
private |
|
inline |
returns true if it is a gzip
References zlib_stream::basic_zip_ostream< Elem, Tr, ElemA, ByteT, ByteAT >::m_is_gzip.
Referenced by utility::io::ozstream::is_gzip(), utility::io::ozstream::open(), and utility::io::ozstream::open_append().
|
inline |
stream output
if zip stream has been finalized, will reset
the stream and add header if necessary
References zlib_stream::basic_zip_ostream< Elem, Tr, ElemA, ByteT, ByteAT >::reset_zip_stream(), and predPRE::t.
|
inline |
write char
if zip stream has been finalized, will reset
the stream and add header if necessary
References kmeans_adaptive_kernel_density_bb_dependent_rotlib::c, and zlib_stream::basic_zip_ostream< Elem, Tr, ElemA, ByteT, ByteAT >::reset_zip_stream().
Referenced by utility::io::ozstream::put().
|
staticprivate |
|
inline |
returns the underlying zip ostream object
Referenced by zlib_stream::basic_zip_ostream< Elem, Tr, ElemA, ByteT, ByteAT >::reset_zip_stream(), zlib_stream::basic_zip_ostream< Elem, Tr, ElemA, ByteT, ByteAT >::zflush(), and zlib_stream::basic_zip_ostream< Elem, Tr, ElemA, ByteT, ByteAT >::zflush_finalize().
|
inlineprivate |
if end of stream, reset the zip stream and add header
References zlib_stream::basic_zip_ostream< Elem, Tr, ElemA, ByteT, ByteAT >::add_header(), zlib_stream::basic_zip_ostreambase< Elem, std::char_traits< Elem >, std::allocator< Elem >, unsigned char, std::allocator< unsigned char > >::get_zerr(), zlib_stream::basic_zip_ostream< Elem, Tr, ElemA, ByteT, ByteAT >::m_zip_stream_finalized, zlib_stream::basic_zip_ostream< Elem, Tr, ElemA, ByteT, ByteAT >::rdbuf(), and zlib_stream::basic_zip_streambuf< Elem, Tr, ElemA, ByteT, ByteAT >::reset_state().
Referenced by zlib_stream::basic_zip_ostream< Elem, Tr, ElemA, ByteT, ByteAT >::operator<<(), zlib_stream::basic_zip_ostream< Elem, Tr, ElemA, ByteT, ByteAT >::put(), and zlib_stream::basic_zip_ostream< Elem, Tr, ElemA, ByteT, ByteAT >::write().
|
inline |
write a string
if zip stream has been finalized, will reset
the stream and add header if necessary
References count, zlib_stream::basic_zip_ostream< Elem, Tr, ElemA, ByteT, ByteAT >::reset_zip_stream(), and str().
Referenced by zlib_stream::basic_zip_ostream< Elem, Tr, ElemA, ByteT, ByteAT >::put_long_as_uint32(), and utility::io::ozstream::write().
|
inline |
flush inner buffer and zipper buffer
References zlib_stream::basic_zip_streambuf< Elem, Tr, ElemA, ByteT, ByteAT >::flush(), and zlib_stream::basic_zip_ostream< Elem, Tr, ElemA, ByteT, ByteAT >::rdbuf().
Referenced by utility::io::ozstream::zflush().
|
inline |
flush inner and zipper buffers and finalize zip stream
References zlib_stream::basic_zip_ostream< Elem, Tr, ElemA, ByteT, ByteAT >::add_footer(), zlib_stream::basic_zip_streambuf< Elem, Tr, ElemA, ByteT, ByteAT >::flush_finalize(), zlib_stream::basic_zip_ostreambase< Elem, std::char_traits< Elem >, std::allocator< Elem >, unsigned char, std::allocator< unsigned char > >::get_zerr(), zlib_stream::basic_zip_ostream< Elem, Tr, ElemA, ByteT, ByteAT >::m_is_gzip, zlib_stream::basic_zip_ostream< Elem, Tr, ElemA, ByteT, ByteAT >::m_zip_stream_finalized, and zlib_stream::basic_zip_ostream< Elem, Tr, ElemA, ByteT, ByteAT >::rdbuf().
Referenced by utility::io::ozstream::close(), utility::io::ozstream::flush(), utility::io::ozstream::flush_finalize(), and utility::io::ozstream::zflush_finalize().
|
private |
|
private |
tracks to see if zip stream was finalized
set to true during zflush_finalize()
set to false during reset_state()
Referenced by zlib_stream::basic_zip_ostream< Elem, Tr, ElemA, ByteT, ByteAT >::reset_zip_stream(), and zlib_stream::basic_zip_ostream< Elem, Tr, ElemA, ByteT, ByteAT >::zflush_finalize().