zipios
2.3.4
Zipios -- a small C++ library providing 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-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
#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
& rhs) =
delete
;
52
virtual
~DeflateOutputStreambuf
();
53
54
DeflateOutputStreambuf
&
operator =
(
DeflateOutputStreambuf
const
& rhs) =
delete
;
55
56
bool
init
(
FileEntry::CompressionLevel
compression_level);
57
void
closeStream
();
58
uint32_t
getCrc32
()
const
;
59
size_t
getSize
()
const
;
60
61
protected
:
62
virtual
int
overflow
(
int
c = EOF);
63
virtual
int
sync
();
64
65
uint32_t
m_overflown_bytes
= 0;
66
std::vector<char>
m_invec
= std::vector<char>();
67
uint32_t
m_crc32
= 0;
68
69
private
:
70
void
endDeflation
();
71
void
flushOutvec
();
72
73
z_stream
m_zs
= z_stream();
74
bool
m_zs_initialized
=
false
;
75
76
std::vector<char>
m_outvec
= std::vector<char>();
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::DeflateOutputStreambuf
A class to handle stream deflate on the fly.
Definition
deflateoutputstreambuf.hpp:48
zipios::DeflateOutputStreambuf::~DeflateOutputStreambuf
virtual ~DeflateOutputStreambuf()
Clean up any resources used by this object.
Definition
deflateoutputstreambuf.cpp:78
zipios::DeflateOutputStreambuf::init
bool init(FileEntry::CompressionLevel compression_level)
Initialize the zlib library.
Definition
deflateoutputstreambuf.cpp:101
zipios::DeflateOutputStreambuf::getCrc32
uint32_t getCrc32() const
Get the CRC32 of the file.
Definition
deflateoutputstreambuf.cpp:234
zipios::DeflateOutputStreambuf::m_zs_initialized
bool m_zs_initialized
Definition
deflateoutputstreambuf.hpp:74
zipios::DeflateOutputStreambuf::endDeflation
void endDeflation()
End deflation of current file.
Definition
deflateoutputstreambuf.cpp:377
zipios::DeflateOutputStreambuf::m_overflown_bytes
uint32_t m_overflown_bytes
Definition
deflateoutputstreambuf.hpp:65
zipios::DeflateOutputStreambuf::m_outvec
std::vector< char > m_outvec
Definition
deflateoutputstreambuf.hpp:76
zipios::DeflateOutputStreambuf::flushOutvec
void flushOutvec()
Flush the cached output data.
Definition
deflateoutputstreambuf.cpp:346
zipios::DeflateOutputStreambuf::m_zs
z_stream m_zs
Definition
deflateoutputstreambuf.hpp:73
zipios::DeflateOutputStreambuf::sync
virtual int sync()
Synchronize the buffer.
Definition
deflateoutputstreambuf.cpp:335
zipios::DeflateOutputStreambuf::m_invec
std::vector< char > m_invec
Definition
deflateoutputstreambuf.hpp:66
zipios::DeflateOutputStreambuf::overflow
virtual int overflow(int c=EOF)
Handle an overflow.
Definition
deflateoutputstreambuf.cpp:270
zipios::DeflateOutputStreambuf::m_crc32
uint32_t m_crc32
Definition
deflateoutputstreambuf.hpp:67
zipios::DeflateOutputStreambuf::closeStream
void closeStream()
Closing the stream.
Definition
deflateoutputstreambuf.cpp:200
zipios::DeflateOutputStreambuf::operator=
DeflateOutputStreambuf & operator=(DeflateOutputStreambuf const &rhs)=delete
zipios::DeflateOutputStreambuf::DeflateOutputStreambuf
DeflateOutputStreambuf(DeflateOutputStreambuf const &rhs)=delete
zipios::DeflateOutputStreambuf::getSize
size_t getSize() const
Retrieve the size of the file deflated.
Definition
deflateoutputstreambuf.cpp:251
zipios::FileEntry::CompressionLevel
int CompressionLevel
The compression level to be used to save an entry.
Definition
fileentry.hpp:85
zipios::FilterOutputStreambuf
A base class to develop output stream filters.
Definition
filteroutputstreambuf.hpp:41
fileentry.hpp
Define the zipios::FileEntry class.
filteroutputstreambuf.hpp
Declarations of the zipios::FilterOutputStreambuf.
zipios
The zipios namespace includes the Zipios library definitions.
Definition
zipios-config.hpp:50
Generated on Sun Aug 17 2025 05:47:41 for zipios by
1.9.8