proxygen
ZlibStreamCompressor.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015-present, Facebook, Inc.
3  * All rights reserved.
4  *
5  * This source code is licensed under the BSD-style license found in the
6  * LICENSE file in the root directory of this source tree. An additional grant
7  * of patent rights can be found in the PATENTS file in the same directory.
8  *
9  */
10 #pragma once
11 
13 #include <memory>
15 #include <zlib.h>
16 
17 namespace folly {
18 class IOBuf;
19 }
20 
21 DECLARE_int64(zlib_compressor_buffer_growth);
22 
23 namespace proxygen {
24 
26  public:
27  explicit ZlibStreamCompressor(ZlibCompressionType type, int level);
28 
30 
31  void init(ZlibCompressionType type, int level);
32 
33  std::unique_ptr<folly::IOBuf> compress(const folly::IOBuf* in,
34  bool trailer = true);
35 
36  int getStatus() { return status_; }
37 
38  bool hasError() { return status_ != Z_OK && status_ != Z_STREAM_END; }
39 
40  bool finished() { return status_ == Z_STREAM_END; }
41 
42  private:
44  int level_{Z_DEFAULT_COMPRESSION};
45  z_stream zlibStream_;
46  int status_{-1};
47 };
48 }
PskType type
—— Concurrent Priority Queue Implementation ——
Definition: AtomicBitSet.h:29
void init(int *argc, char ***argv, bool removeFlags)
Definition: Init.cpp:34
Type type_
Definition: JSONSchema.cpp:208
DECLARE_int64(zlib_compressor_buffer_growth)