]> git.donarmstrong.com Git - flightcrew.git/blob - src/zipios/zipios++/zipoutputstream.h
Imported Upstream version 0.7.2+dfsg
[flightcrew.git] / src / zipios / zipios++ / zipoutputstream.h
1 #ifndef ZIPOUTPUTSTREAM_H
2 #define ZIPOUTPUTSTREAM_H
3
4 #include "zipios++/zipios-config.h"
5
6 #include "zipios++/meta-iostreams.h"
7
8 #include <string>
9
10 #include "zipios++/ziphead.h"
11 #include "zipios++/zipoutputstreambuf.h"
12
13 namespace zipios {
14
15 /** \anchor ZipOutputStream_anchor
16     ZipOutputStream is an ostream that writes the output to a zip file. The
17     interface approximates the interface of the Java ZipOutputStream. */
18 class ZipOutputStream : public std::ostream {
19 public:
20
21   /** ZipOutputStream constructor.
22       @param os ostream to which the compressed zip archive is written.
23       @param pos position to reposition the ostream to before reading.  */
24   explicit ZipOutputStream( std::ostream &os ) ;
25
26   /** ZipOutputStream constructor.
27       @filename filename to write the zip archive to. */
28   explicit ZipOutputStream( const std::string &filename ) ;
29   
30   /** Closes the current entry updates its header with the relevant
31       size information and positions the stream write pointer for the
32       next entry header. Puts the stream in EOF state. Call
33       putNextEntry() to clear the EOF stream state flag. */
34   void closeEntry() ;
35
36   /** Calls finish and if the ZipOutputStream was created with a
37       filename as a parameter that file is closed as well. If the
38       ZipOutputStream was created with an ostream as its first
39       parameter nothing but the call to finish happens. */
40   void close() ;
41
42   /** Closes the current entry (if one is open), then writes the Zip
43       Central Directory Structure closing the ZipOutputStream. The
44       output stream that the zip archive is being written to is not
45       closed. */
46   void finish() ;
47
48   /** \anchor ZipOutputStream_putnextentry_anchor
49       Begins writing the next entry.
50   */
51   void putNextEntry( const ZipCDirEntry &entry ) ;
52
53   /** \anchor ZipOutputStream_putnextentry2_anchor
54       Begins writing the next entry.
55   */
56   void putNextEntry(const std::string& entryName);
57
58   /** Sets the global comment for the Zip archive. */
59   void setComment( const std::string& comment ) ;
60
61   /** Sets the compression level to be used for subsequent entries. */
62   void setLevel( int level ) ;
63
64   /** Sets the compression method to be used. only STORED and DEFLATED are
65       supported. */
66   void setMethod( StorageMethod method ) ;
67
68   /** Destructor. */
69   virtual ~ZipOutputStream() ;
70
71 private:
72   std::ofstream *ofs ;
73   ZipOutputStreambuf *ozf ;
74 };
75  
76 } // namespace.
77
78 #endif
79
80 /** \file 
81     Header file that defines ZipOutputStream.
82 */
83
84 /*
85   Zipios++ - a small C++ library that provides easy access to .zip files.
86   Copyright (C) 2000  Thomas Søndergaard
87   
88   This library is free software; you can redistribute it and/or
89   modify it under the terms of the GNU Lesser General Public
90   License as published by the Free Software Foundation; either
91   version 2 of the License, or (at your option) any later version.
92   
93   This library is distributed in the hope that it will be useful,
94   but WITHOUT ANY WARRANTY; without even the implied warranty of
95   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
96   Lesser General Public License for more details.
97   
98   You should have received a copy of the GNU Lesser General Public
99   License along with this library; if not, write to the Free Software
100   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
101 */