proxygen
Zlib.h
Go to the documentation of this file.
1 /*
2  * Copyright 2017-present Facebook, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 #include <folly/Portability.h>
21 
22 #if FOLLY_HAVE_LIBZ
23 
24 #include <zlib.h>
25 
29 namespace folly {
30 namespace io {
31 namespace zlib {
32 
33 struct Options {
46  enum class Format { ZLIB, GZIP, RAW, AUTO };
47 
48  explicit Options(
49  Format format_ = Format::ZLIB,
50  int windowSize_ = 15,
51  int memLevel_ = 8,
52  int strategy_ = Z_DEFAULT_STRATEGY)
53  : format(format_),
54  windowSize(windowSize_),
55  memLevel(memLevel_),
56  strategy(strategy_) {}
57 
58  Format format;
59 
70  int windowSize;
71 
78  int memLevel;
79 
92  int strategy;
93 };
94 
99 Options defaultGzipOptions();
100 
105 Options defaultZlibOptions();
106 
118 std::unique_ptr<Codec> getCodec(
119  Options options = Options(),
120  int level = COMPRESSION_LEVEL_DEFAULT);
121 std::unique_ptr<StreamCodec> getStreamCodec(
122  Options options = Options(),
123  int level = COMPRESSION_LEVEL_DEFAULT);
124 
125 } // namespace zlib
126 } // namespace io
127 } // namespace folly
128 
129 #endif // FOLLY_HAVE_LIBZ
constexpr int COMPRESSION_LEVEL_DEFAULT
Definition: Compression.h:441
—— Concurrent Priority Queue Implementation ——
Definition: AtomicBitSet.h:29
std::unique_ptr< StreamCodec > getStreamCodec(CodecType type, int level)
std::string format_
Formatter< false, Args... > format(StringPiece fmt, Args &&...args)
Definition: Format.h:271
std::unique_ptr< Codec > getCodec(CodecType type, int level)