Rosetta 3.3
Public Types | Public Member Functions
zlib_stream::basic_zip_ostream< Elem, Tr, ElemA, ByteT, ByteAT > Class Template Reference

A zipper ostream. More...

#include <zipstream.hpp>

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

List of all members.

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

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.
 ~basic_zip_ostream ()
bool is_gzip () const
 returns true if it is a gzip
basic_zip_ostream< Elem, Tr > & zflush ()
 flush inner buffer and zipper buffer
basic_zip_ostream< Elem, Tr > & zflush_finalize ()
 flush inner and zipper buffers and finalize zip stream
template<typename T >
basic_zip_ostreamoperator<< (T const &t)
 stream output
basic_zip_ostreamput (char const c)
 write char
basic_zip_ostreamwrite (char const *str, std::streamsize const count)
 write a string

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_ostream< Elem, Tr, ElemA, ByteT, ByteAT >

A zipper ostream.

Remarks:

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:

 // creating the target zip string, could be a fstream
 ostringstream ostringstream_;
 // creating the zip layer
 zip_ostream zipper(ostringstream_);


 // writing data
 zipper<<f<<" "<<d<<" "<<ui<<" "<<ul<<" "<<us<<" "<<c<<" "<<dum;
 // zip ostream needs special flushing...
 zipper.zflush();

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 Elem zlib_stream::basic_zip_ostream< 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::basic_ostream< Elem, Tr >& zlib_stream::basic_zip_ostream< 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 std::basic_ostream< Elem, Tr > zlib_stream::basic_zip_ostream< Elem, Tr, ElemA, ByteT, ByteAT >::ostream_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 basic_zip_ostreambase< Elem, Tr, ElemA, ByteT, ByteAT > zlib_stream::basic_zip_ostream< Elem, Tr, ElemA, ByteT, ByteAT >::zip_ostreambase_type

Constructor & Destructor Documentation

template<typename Elem, typename Tr = std::char_traits< Elem >, typename ElemA = std::allocator< Elem >, typename ByteT = unsigned char, typename ByteAT = std::allocator< ByteT >>
zlib_stream::basic_zip_ostream< Elem, Tr, ElemA, ByteT, ByteAT >::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 
) [inline]

Constructs a zipper ostream decorator.

Parameters:
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
Note:
When is_gzip_ is true, a gzip header and footer is automatically added
template<typename Elem, typename Tr = std::char_traits< Elem >, typename ElemA = std::allocator< Elem >, typename ByteT = unsigned char, typename ByteAT = std::allocator< ByteT >>
zlib_stream::basic_zip_ostream< Elem, Tr, ElemA, ByteT, ByteAT >::~basic_zip_ostream ( ) [inline]

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 >>
bool zlib_stream::basic_zip_ostream< Elem, Tr, ElemA, ByteT, ByteAT >::is_gzip ( ) const [inline]

returns true if it is a gzip

Referenced by utility::io::ozstream::open(), and utility::io::ozstream::open_append().

template<typename Elem, typename Tr = std::char_traits< Elem >, typename ElemA = std::allocator< Elem >, typename ByteT = unsigned char, typename ByteAT = std::allocator< ByteT >>
template<typename T >
basic_zip_ostream& zlib_stream::basic_zip_ostream< Elem, Tr, ElemA, ByteT, ByteAT >::operator<< ( T const &  t) [inline]

stream output

if zip stream has been finalized, will reset

the stream and add header if necessary

References sd::t.

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_ostream& zlib_stream::basic_zip_ostream< Elem, Tr, ElemA, ByteT, ByteAT >::put ( char const  c) [inline]

write char

if zip stream has been finalized, will reset

the stream and add header if necessary

Referenced by utility::io::ozstream::put().

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_ostream& zlib_stream::basic_zip_ostream< Elem, Tr, ElemA, ByteT, ByteAT >::write ( char const *  str,
std::streamsize const  count 
) [inline]

write a string

if zip stream has been finalized, will reset

the stream and add header if necessary

Referenced by utility::io::ozstream::write().

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_ostream< Elem, Tr >& zlib_stream::basic_zip_ostream< Elem, Tr, ElemA, ByteT, ByteAT >::zflush ( ) [inline]
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_ostream< Elem, Tr >& zlib_stream::basic_zip_ostream< Elem, Tr, ElemA, ByteT, ByteAT >::zflush_finalize ( ) [inline]

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines