LIBRCSC Docs
Documentation for HELIOS's BASE LIBRCSC library for RoboCup 2D Simulation League.
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros
gzfilterstream.h
Go to the documentation of this file.
1// -*-c++-*-
2
8/*
9 *Copyright:
10
11 Copyright (C) Hidehisa Akiyama
12
13 This code is free software; you can redistribute it and/or
14 modify it under the terms of the GNU Lesser General Public
15 License as published by the Free Software Foundation; either
16 version 3 of the License, or (at your option) any later version.
17
18 This library is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 Lesser General Public License for more details.
22
23 You should have received a copy of the GNU Lesser General Public
24 License along with this library; if not, write to the Free Software
25 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26
27 *EndCopyright:
28 */
29
31
32#ifndef RCSC_GZ_GZFILTERSTREAM_H
33#define RCSC_GZ_GZFILTERSTREAM_H
34
35#include <boost/scoped_ptr.hpp>
36#include <iostream>
37
38namespace rcsc {
39
41
47 : public std::streambuf {
48public:
59 DEFAULT_COMPRESSION = 6,
60 NO_COMPRESSION = 0,
61 BEST_SPEED = 1,
62 BEST_COMPRESSION = 9,
63 };
64
68 enum FlushType {
69 NO_FLUSH = 0,
70 PARTIAL_FLUSH = 1, // will be removed, use SYNC_FLUSH instead
71 SYNC_FLUSH = 2,
72 FULL_FLUSH = 3,
73 FINISH = 4
74 };
75
76private:
78 std::streambuf & M_strmbuf;
80 std::ostream * M_output_stream;
82 std::istream * M_input_stream;
84 std::streamsize M_buf_size;
86 char_type * M_read_buf;
88 char_type * M_input_buf;
90 char_type * M_output_buf;
92 char_type * M_write_buf;
93
95 struct Impl;
96
98 std::unique_ptr< Impl > M_impl;
103 int M_level;
104
106 gzfilterstreambuf( const gzfilterstreambuf & ) = delete;
108 gzfilterstreambuf & operator=( const gzfilterstreambuf & ) = delete;
109
110public:
111
121 explicit
122 gzfilterstreambuf( std::streambuf & strm,
123 int level = DEFAULT_COMPRESSION,
124 std::size_t buf_size = 8192 );
125
132
140 bool setLevel( const int level );
141
142protected:
143
149 bool writeData( int flush_type = NO_FLUSH );
150
157 int readData( char * dest,
158 int & dest_size );
159
166 virtual
167 int_type overflow( int_type c );
168
174 virtual
175 int sync();
176
183 virtual
184 int_type underflow();
185};
186
188
194 : public std::iostream {
195private:
197 gzfilterstreambuf M_filter_buf;
198
200 gzfilterstream( const gzfilterstream & ) = delete;
202 gzfilterstream & operator=( const gzfilterstream & ) = delete;
203
204public:
211 explicit
212 gzfilterstream( std::streambuf & strmbuf,
213 int level = gzfilterstreambuf::DEFAULT_COMPRESSION,
214 std::size_t buf_size = 8192 );
215
222 explicit
223 gzfilterstream( std::iostream & strm,
224 int level = gzfilterstreambuf::DEFAULT_COMPRESSION,
225 std::size_t buf_size = 8192 );
226
234 bool setLevel( const int level )
235 {
236 return M_filter_buf.setLevel( level );
237 }
238
239};
240
242
248 : public std::istream {
249private:
251 gzfilterstreambuf M_filter_buf;
252
254 gzifilterstream( const gzifilterstream & ) = delete;
256 gzifilterstream & operator=( const gzifilterstream & ) = delete;
257
258public:
265 explicit
266 gzifilterstream( std::streambuf & src,
267 int level = gzfilterstreambuf::DEFAULT_COMPRESSION,
268 std::size_t buf_size = 8192 );
269
276 explicit
277 gzifilterstream( std::istream & src,
278 int level = gzfilterstreambuf::DEFAULT_COMPRESSION,
279 std::size_t buf_size = 8192 );
280
288 bool setLevel( const int level )
289 {
290 return M_filter_buf.setLevel( level );
291 }
292
293};
294
296
302 : public std::ostream {
303private:
305 gzfilterstreambuf M_filter_buf;
306
308 gzofilterstream( const gzofilterstream & ) = delete;
310 gzofilterstream & operator=( const gzofilterstream & ) = delete;
311public:
312
319 explicit
320 gzofilterstream( std::streambuf & dest,
321 int level = gzfilterstreambuf::DEFAULT_COMPRESSION,
322 std::size_t buf_size = 8192 );
323
330 explicit
331 gzofilterstream( std::ostream & dest,
332 int level = gzfilterstreambuf::DEFAULT_COMPRESSION,
333 std::size_t buf_size = 8192 );
334
342 bool setLevel( const int level )
343 {
344 return M_filter_buf.setLevel( level );
345 }
346
347};
348
349} // end namespace
350
351#endif
gzip filtering stream class.
Definition: gzfilterstream.h:194
gzfilterstream(std::iostream &strm, int level=gzfilterstreambuf::DEFAULT_COMPRESSION, std::size_t buf_size=8192)
constructor with another stream
bool setLevel(const int level)
change complession level
Definition: gzfilterstream.h:234
gzfilterstream(std::streambuf &strmbuf, int level=gzfilterstreambuf::DEFAULT_COMPRESSION, std::size_t buf_size=8192)
constructor with another stream buffer
gzip filtering stream buffer class.
Definition: gzfilterstream.h:47
bool writeData(int flush_type=NO_FLUSH)
write data to buffer and/or destination
virtual int_type overflow(int_type c)
flush current internal buffer.
virtual int sync()
syncronize data to output devide
FlushType
flush type enumeration.
Definition: gzfilterstream.h:68
CompressionLevel
typical compression level enumeration
Definition: gzfilterstream.h:58
~gzfilterstreambuf()
destructor
gzfilterstreambuf(std::streambuf &strm, int level=DEFAULT_COMPRESSION, std::size_t buf_size=8192)
constructor with another stream buffer
bool setLevel(const int level)
change complession level
int readData(char *dest, int &dest_size)
read data from destination.
virtual int_type underflow()
read data from input device
gzip filtering input stream class.
Definition: gzfilterstream.h:248
gzifilterstream(std::istream &src, int level=gzfilterstreambuf::DEFAULT_COMPRESSION, std::size_t buf_size=8192)
constructor with another stream
bool setLevel(const int level)
change complession level
Definition: gzfilterstream.h:288
gzifilterstream(std::streambuf &src, int level=gzfilterstreambuf::DEFAULT_COMPRESSION, std::size_t buf_size=8192)
constructor with another stream buffer
gzip filtering output stream class.
Definition: gzfilterstream.h:302
gzofilterstream(std::ostream &dest, int level=gzfilterstreambuf::DEFAULT_COMPRESSION, std::size_t buf_size=8192)
constructor with another stream
bool setLevel(const int level)
change complession level
Definition: gzfilterstream.h:342
gzofilterstream(std::streambuf &dest, int level=gzfilterstreambuf::DEFAULT_COMPRESSION, std::size_t buf_size=8192)
constructor with another stream buffer