zipios++  2.0.2
Zipios++ – a small C++ library that provides easy access to .zip files.
Public Member Functions | Private Attributes | List of all members
zipios::GZIPOutputStream Class Reference

A stream implementation that outputs data to a ZIP file. More...

#include <gzipoutputstream.hpp>

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

Public Member Functions

 GZIPOutputStream (std::ostream &os, FileEntry::CompressionLevel compression_level)
 Create a ZIP output stream object. More...
 
 GZIPOutputStream (std::string const &filename, FileEntry::CompressionLevel compression_level)
 Create a named ZIP stream for output. More...
 
virtual ~GZIPOutputStream ()
 Destroy the output stream. More...
 
void close ()
 Close the streams. More...
 
void finish ()
 Finishes the stream. More...
 
void setComment (std::string const &comment)
 Set a comment in the stream. More...
 
void setFilename (std::string const &filename)
 Set the filename of a stream. More...
 

Private Attributes

std::unique_ptr< std::ofstream > m_ofs
 
std::unique_ptr
< GZIPOutputStreambuf
m_ozf
 

Detailed Description

GZIPOutputStream is an ostream that writes the output to a zip file. The interface approximates the interface of the Java GZIPOutputStream.

It can be used with either an existing std::ostream object, or a filename.

Definition at line 42 of file gzipoutputstream.hpp.

Constructor & Destructor Documentation

zipios::GZIPOutputStream::GZIPOutputStream ( std::ostream &  os,
FileEntry::CompressionLevel  compression_level 
)

This constructor creates a zip stream from an existing standard output stream.

Warning
You must keep the output stream valid for as long as this object exists (although this object close() function can be used to close the os stream.)
Parameters
[in,out]osostream to which the compressed zip archive is written.
[in]compression_levelThe compression level to use to compress.

Definition at line 63 of file gzipoutputstream.cpp.

References m_ozf.

zipios::GZIPOutputStream::GZIPOutputStream ( std::string const &  filename,
FileEntry::CompressionLevel  compression_level 
)
Note
The fielname is not automatically saved as part of the stream. To do so, call the setFilename() function.
Parameters
[in]filenameName of the file where the zip archive is to be written.
[in]compression_levelThe compression level to use to compress.

Definition at line 82 of file gzipoutputstream.cpp.

References m_ozf.

zipios::GZIPOutputStream::~GZIPOutputStream ( )
virtual

The destructor ensures that all allocated resources get destroyed.

Definition at line 95 of file gzipoutputstream.cpp.

Member Function Documentation

void zipios::GZIPOutputStream::close ( )

This function closes the streams making sure that all data gets saved in the output file.

It is not required since destroying the object will also force a close.

Definition at line 137 of file gzipoutputstream.cpp.

References m_ofs, and m_ozf.

void zipios::GZIPOutputStream::finish ( )

Definition at line 150 of file gzipoutputstream.cpp.

References m_ozf.

void zipios::GZIPOutputStream::setComment ( std::string const &  comment)

This function can be used to add a comment to the zip file.

A comment is optional.

Parameters
[in]commentThe comment to attach to this stream.

Definition at line 123 of file gzipoutputstream.cpp.

References m_ozf.

void zipios::GZIPOutputStream::setFilename ( std::string const &  filename)

This function can be used to set the name of the file being added to this stream.

The filename is optional.

Parameters
[in]filenameThe filename to attach to this stream.

Definition at line 109 of file gzipoutputstream.cpp.

References m_ozf.

Member Data Documentation

std::unique_ptr<std::ofstream> zipios::GZIPOutputStream::m_ofs
private

Definition at line 55 of file gzipoutputstream.hpp.

Referenced by close().

std::unique_ptr<GZIPOutputStreambuf> zipios::GZIPOutputStream::m_ozf
private

Definition at line 56 of file gzipoutputstream.hpp.

Referenced by close(), finish(), GZIPOutputStream(), setComment(), and setFilename().


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