zipios++  2.0.2
Zipios++ – a small C++ library that provides 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 Made to Order Software Corporation
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 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25 
35 
36 
37 namespace zipios
38 {
39 
40 
42 {
43 public:
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 
52 protected:
53  virtual int overflow(int c = EOF) override;
54  virtual int sync() override;
55 
56 private:
57  void writeHeader();
58  void writeTrailer();
59  void writeInt(uint32_t i);
60 
61  std::string m_filename;
62  std::string m_comment;
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
virtual int overflow(int c=EOF) override
Handle an overflow.
Save the output stream buffer.
void setComment(std::string const &comment)
int CompressionLevel
The compression level to be used to save an entry.
Definition: fileentry.hpp:85
void finish()
Finishes the compression.
void close()
Close the stream.
Header file that defines zipios::DeflateOutputStreambuf.
virtual ~GZIPOutputStreambuf() override
Ensures that the stream gets closed properly.
virtual int sync() override
Synchronize the buffer.
GZIPOutputStreambuf(std::streambuf *outbuf, FileEntry::CompressionLevel compression_level)
Initialize a GZIPOutputStreambuf object.
void setFilename(std::string const &filename)
A class to handle stream deflate on the fly.