zipios
2.2.0
Zipios -- a small C++ library that provides easy access to .zip files.
src
deflateoutputstreambuf.hpp
Go to the documentation of this file.
1
#pragma once
2
#ifndef DEFLATEOUTPUTSTREAMBUF_HPP
3
#define DEFLATEOUTPUTSTREAMBUF_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-2019 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.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
#include "
filteroutputstreambuf.hpp
"
36
37
#include "
zipios/fileentry.hpp
"
38
39
#include <cstdint>
40
41
#include <zlib.h>
42
43
44
namespace
zipios
45
{
46
47
class
DeflateOutputStreambuf
:
public
FilterOutputStreambuf
48
{
49
public
:
50
DeflateOutputStreambuf
(std::streambuf * outbuf);
51
DeflateOutputStreambuf
(
DeflateOutputStreambuf
const
& src) =
delete
;
52
DeflateOutputStreambuf
&
operator =
(
DeflateOutputStreambuf
const
& rhs) =
delete
;
53
virtual
~DeflateOutputStreambuf
();
54
55
bool
init
(
FileEntry::CompressionLevel
compression_level);
56
void
closeStream
();
57
uint32_t
getCrc32
()
const
;
58
size_t
getSize
()
const
;
59
60
protected
:
61
virtual
int
overflow
(
int
c = EOF);
62
virtual
int
sync
();
63
64
uint32_t
m_overflown_bytes
= 0;
65
std::vector<char>
m_invec
;
66
67
private
:
68
void
endDeflation
();
69
void
flushOutvec
();
70
71
z_stream
m_zs
= z_stream();
72
bool
m_zs_initialized
=
false
;
73
74
std::vector<char>
m_outvec
;
75
76
uint32_t
m_crc32
= 0;
77
};
78
79
80
}
// zipios namespace
81
82
// Local Variables:
83
// mode: cpp
84
// indent-tabs-mode: nil
85
// c-basic-offset: 4
86
// tab-width: 4
87
// End:
88
89
// vim: ts=4 sw=4 et
90
#endif
zipios::FileEntry::CompressionLevel
int CompressionLevel
The compression level to be used to save an entry.
Definition:
fileentry.hpp:85
zipios::DeflateOutputStreambuf::getSize
size_t getSize() const
Retrieve the size of the file deflated.
Definition:
deflateoutputstreambuf.cpp:256
zipios::DeflateOutputStreambuf::m_invec
std::vector< char > m_invec
Definition:
deflateoutputstreambuf.hpp:65
zipios::FilterOutputStreambuf
A base class to develop output stream filters.
Definition:
filteroutputstreambuf.hpp:40
zipios::DeflateOutputStreambuf::flushOutvec
void flushOutvec()
Flush the cached output data.
Definition:
deflateoutputstreambuf.cpp:351
zipios::DeflateOutputStreambuf::init
bool init(FileEntry::CompressionLevel compression_level)
Initialize the zlib library.
Definition:
deflateoutputstreambuf.cpp:106
zipios::DeflateOutputStreambuf::overflow
virtual int overflow(int c=EOF)
Handle an overflow.
Definition:
deflateoutputstreambuf.cpp:275
zipios::DeflateOutputStreambuf::sync
virtual int sync()
Synchronize the buffer.
Definition:
deflateoutputstreambuf.cpp:340
zipios::DeflateOutputStreambuf::endDeflation
void endDeflation()
End deflation of current file.
Definition:
deflateoutputstreambuf.cpp:382
zipios::DeflateOutputStreambuf::DeflateOutputStreambuf
DeflateOutputStreambuf(std::streambuf *outbuf)
Initialize a DeflateOutputStreambuf object.
Definition:
deflateoutputstreambuf.cpp:57
zipios::DeflateOutputStreambuf::getCrc32
uint32_t getCrc32() const
Get the CRC32 of the file.
Definition:
deflateoutputstreambuf.cpp:239
zipios::DeflateOutputStreambuf::m_zs_initialized
bool m_zs_initialized
Definition:
deflateoutputstreambuf.hpp:72
zipios::DeflateOutputStreambuf::closeStream
void closeStream()
Closing the stream.
Definition:
deflateoutputstreambuf.cpp:205
zipios::DeflateOutputStreambuf::m_crc32
uint32_t m_crc32
Definition:
deflateoutputstreambuf.hpp:76
filteroutputstreambuf.hpp
Declarations of the zipios::FilterOutputStreambuf.
zipios::DeflateOutputStreambuf
A class to handle stream deflate on the fly.
Definition:
deflateoutputstreambuf.hpp:47
zipios::DeflateOutputStreambuf::m_outvec
std::vector< char > m_outvec
Definition:
deflateoutputstreambuf.hpp:74
zipios::DeflateOutputStreambuf::m_zs
z_stream m_zs
Definition:
deflateoutputstreambuf.hpp:71
zipios::DeflateOutputStreambuf::~DeflateOutputStreambuf
virtual ~DeflateOutputStreambuf()
Clean up any resources used by this object.
Definition:
deflateoutputstreambuf.cpp:87
fileentry.hpp
Define the zipios::FileEntry class.
zipios::DeflateOutputStreambuf::operator=
DeflateOutputStreambuf & operator=(DeflateOutputStreambuf const &rhs)=delete
zipios::DeflateOutputStreambuf::m_overflown_bytes
uint32_t m_overflown_bytes
Definition:
deflateoutputstreambuf.hpp:64
zipios
The zipios namespace includes the Zipios library definitions.
Definition:
backbuffer.cpp:35
Generated on Tue Feb 11 2020 21:26:26 for zipios by
1.8.17