zipios 2.3.4
Zipios -- a small C++ library providing easy access to .zip files.
gzipoutputstreambuf.hpp
Go to the documentation of this file.
1#pragma once
2#ifndef GZIPOUTPUTSTREAMBUF_HPP
3#define GZIPOUTPUTSTREAMBUF_HPP
4
5/*
6 Zipios -- a small C++ library that provides easy access to .zip files.
7
8 Copyright (C) 2000-2007 Thomas Sondergaard
9 Copyright (c) 2015-2022 Made to Order Software Corp. All Rights Reserved
10
11 This library is free software; you can redistribute it and/or
12 modify it under the terms of the GNU Lesser General Public
13 License as published by the Free Software Foundation; either
14 version 2.1 of the License, or (at your option) any later version.
15
16 This library is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 Lesser General Public License for more details.
20
21 You should have received a copy of the GNU Lesser General Public
22 License along with this library; if not, write to the Free Software
23 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24*/
25
35
36
37namespace zipios
38{
39
40
42{
43public:
44 GZIPOutputStreambuf(std::streambuf * outbuf, FileEntry::CompressionLevel compression_level);
45 virtual ~GZIPOutputStreambuf() override;
46
47 void setFilename(std::string const & filename);
48 void setComment(std::string const & comment);
49 void close();
50 void finish();
51
52protected:
53 virtual int overflow(int c = EOF) override;
54 virtual int sync() override;
55
56private:
57 void writeHeader();
58 void writeTrailer();
59 void writeInt(uint32_t i);
60
61 std::string m_filename = std::string();
62 std::string m_comment = std::string();
63 bool m_open = false;
64};
65
66
67} // zipios namespace
68
69// Local Variables:
70// mode: cpp
71// indent-tabs-mode: nil
72// c-basic-offset: 4
73// tab-width: 4
74// End:
75
76// vim: ts=4 sw=4 et
77#endif
A class to handle stream deflate on the fly.
int CompressionLevel
The compression level to be used to save an entry.
Definition fileentry.hpp:85
Save the output stream buffer.
void setComment(std::string const &comment)
void finish()
Finishes the compression.
virtual int sync() override
Synchronize the buffer.
virtual ~GZIPOutputStreambuf() override
Ensures that the stream gets closed properly.
virtual int overflow(int c=EOF) override
Handle an overflow.
void close()
Close the stream.
void setFilename(std::string const &filename)
Header file that defines zipios::DeflateOutputStreambuf.
The zipios namespace includes the Zipios library definitions.