xapian-core  2.0.0
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, see
19  * <https://www.gnu.org/licenses/>.
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 = 0;
33 
34  char* out = nullptr;
35 
37  z_stream* deflate_zstream = nullptr;
38 
40  z_stream* inflate_zstream = nullptr;
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  { }
57 
59 
60  const char* compress(const char* buf, size_t* p_size);
61 
63 
65  bool decompress_chunk(const char* p, int len, std::string& buf);
66 };
67 
68 #endif // XAPIAN_INCLUDED_COMPRESSION_STREAM_H
void lazy_alloc_inflate_zstream()
Allocate the zstream for inflating, if not already allocated.
bool decompress_chunk(const char *p, int len, std::string &buf)
Returns true if this was the final chunk.
CompressionStream(int compress_strategy_=Z_DEFAULT_STRATEGY)
z_stream * inflate_zstream
Zlib state object for inflating.
void lazy_alloc_deflate_zstream()
Allocate the zstream for deflating, if not already allocated.
const char * compress(const char *buf, size_t *p_size)
z_stream * deflate_zstream
Zlib state object for deflating.
PositionList * p
Types used internally.