Zipios++
gzipoutputstream.cpp
Go to the documentation of this file.
1
2#include "zipios++/zipios-config.h"
3
4#include "zipios++/meta-iostreams.h"
5
8
9using std::ostream;
10
11namespace zipios {
12
14 : ostream( 0 ),
15 ofs( 0 )
16{
17 ozf = new GZIPOutputStreambuf( os.rdbuf() ) ;
18
19 init( ozf ) ;
20}
21
22GZIPOutputStream::GZIPOutputStream( const std::string &filename )
23 : ostream( 0 ),
24 ofs( 0 )
25{
26 ofs = new std::ofstream( filename.c_str(), std::ios::out | std::ios::binary ) ;
27 ozf = new GZIPOutputStreambuf( ofs->rdbuf() ) ;
28 init( ozf ) ;
29}
30
31void GZIPOutputStream::setFilename( const string &filename ) {
32 ozf->setFilename(filename);
33}
34
35void GZIPOutputStream::setComment( const string &comment ) {
36 ozf->setComment(comment);
37}
38
40 ozf->close() ;
41 if ( ofs )
42 ofs->close() ;
43}
44
45
47 ozf->finish() ;
48}
49
50
52 // It's ok to call delete with a Null pointer.
53 delete ozf ;
54 delete ofs ;
55}
56
57} // namespace
58
63/*
64 Zipios++ - a small C++ library that provides easy access to .zip files.
65 Copyright (C) 2000 Thomas Søndergaard
66
67 This library is free software; you can redistribute it and/or
68 modify it under the terms of the GNU Lesser General Public
69 License as published by the Free Software Foundation; either
70 version 2 of the License, or (at your option) any later version.
71
72 This library is distributed in the hope that it will be useful,
73 but WITHOUT ANY WARRANTY; without even the implied warranty of
74 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
75 Lesser General Public License for more details.
76
77 You should have received a copy of the GNU Lesser General Public
78 License along with this library; if not, write to the Free Software
79 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
80*/
void close()
Calls finish and closes the stream.
virtual ~GZIPOutputStream()
Destructor.
void finish()
Finishes the stream.
GZIPOutputStream(std::ostream &os)
GZIPOutputStream constructor.
GZIPOutputStreambuf is a zip output streambuf filter.
void finish()
Finishes the compression.
Header file that defines GZIPOutputStream.
Header file that defines ZipOutputStreambuf.