xapian-core  1.4.21
compression_stream.h
Go to the documentation of this file.
1 
4 /* Copyright (C) 2012 Dan Colish
5  * Copyright (C) 2012,2013,2014,2016 Olly Betts
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 #ifndef XAPIAN_INCLUDED_COMPRESSION_STREAM_H
23 #define XAPIAN_INCLUDED_COMPRESSION_STREAM_H
24 
25 #include "internaltypes.h"
26 #include <string>
27 #include <zlib.h>
28 
31 
32  size_t out_len;
33 
34  char* out;
35 
37  z_stream* deflate_zstream;
38 
40  z_stream* inflate_zstream;
41 
44 
47 
48  public:
49  /* Create a new CompressionStream object.
50  *
51  * @param compress_strategy_ Z_DEFAULT_STRATEGY,
52  * Z_FILTERED, Z_HUFFMAN_ONLY, or Z_RLE.
53  */
54  explicit CompressionStream(int compress_strategy_ = Z_DEFAULT_STRATEGY)
55  : compress_strategy(compress_strategy_),
56  out_len(0),
57  out(NULL),
58  deflate_zstream(NULL),
59  inflate_zstream(NULL)
60  { }
61 
63 
64  const char* compress(const char* buf, size_t* p_size);
65 
67 
69  bool decompress_chunk(const char* p, int len, std::string& buf);
70 };
71 
72 #endif // XAPIAN_INCLUDED_COMPRESSION_STREAM_H
void lazy_alloc_inflate_zstream()
Allocate the zstream for inflating, if not already allocated.
const char * compress(const char *buf, size_t *p_size)
z_stream * deflate_zstream
Zlib state object for deflating.
CompressionStream(int compress_strategy_=Z_DEFAULT_STRATEGY)
void lazy_alloc_deflate_zstream()
Allocate the zstream for deflating, if not already allocated.
bool decompress_chunk(const char *p, int len, std::string &buf)
Returns true if this was the final chunk.
z_stream * inflate_zstream
Zlib state object for inflating.
Types used internally.