aboutsummaryrefslogtreecommitdiffstats
path: root/util/stream/zlib.h
diff options
context:
space:
mode:
authorAnton Samokhvalov <pg83@yandex.ru>2022-02-10 16:45:17 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:17 +0300
commitd3a398281c6fd1d3672036cb2d63f842d2cb28c5 (patch)
treedd4bd3ca0f36b817e96812825ffaf10d645803f2 /util/stream/zlib.h
parent72cb13b4aff9bc9cf22e49251bc8fd143f82538f (diff)
downloadydb-d3a398281c6fd1d3672036cb2d63f842d2cb28c5.tar.gz
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 2 of 2.
Diffstat (limited to 'util/stream/zlib.h')
-rw-r--r--util/stream/zlib.h186
1 files changed, 93 insertions, 93 deletions
diff --git a/util/stream/zlib.h b/util/stream/zlib.h
index dd70488b95..e7de7c81b7 100644
--- a/util/stream/zlib.h
+++ b/util/stream/zlib.h
@@ -1,42 +1,42 @@
#pragma once
-
+
#include "fwd.h"
#include "input.h"
#include "output.h"
#include "buffered.h"
-
+
#include <util/system/defaults.h>
#include <util/generic/ptr.h>
#include <util/generic/yexception.h>
-
+
/**
* @addtogroup Streams_Archs
* @{
*/
-struct TZLibError: public yexception {
+struct TZLibError: public yexception {
+};
+
+struct TZLibCompressorError: public TZLibError {
};
-struct TZLibCompressorError: public TZLibError {
-};
-
-struct TZLibDecompressorError: public TZLibError {
-};
-
-namespace ZLib {
- enum StreamType: ui8 {
- Auto = 0, /**< Auto detect format. Can be used for decompression only. */
- ZLib = 1,
- GZip = 2,
+struct TZLibDecompressorError: public TZLibError {
+};
+
+namespace ZLib {
+ enum StreamType: ui8 {
+ Auto = 0, /**< Auto detect format. Can be used for decompression only. */
+ ZLib = 1,
+ GZip = 2,
Raw = 3,
Invalid = 4
- };
+ };
enum {
ZLIB_BUF_LEN = 8 * 1024
};
-}
-
+}
+
/**
* Non-buffered ZLib decompressing stream.
*
@@ -46,11 +46,11 @@ namespace ZLib {
* aka `TZDecompress`.
*/
class TZLibDecompress: public IInputStream {
-public:
+public:
TZLibDecompress(IZeroCopyInput* input, ZLib::StreamType type = ZLib::Auto, TStringBuf dict = {});
TZLibDecompress(IInputStream* input, ZLib::StreamType type = ZLib::Auto, size_t buflen = ZLib::ZLIB_BUF_LEN,
TStringBuf dict = {});
-
+
/**
* Allows/disallows multiple sequential compressed streams. Allowed by default.
*
@@ -67,92 +67,92 @@ public:
protected:
size_t DoRead(void* buf, size_t size) override;
-public:
- class TImpl;
- THolder<TImpl> Impl_;
-};
-
+public:
+ class TImpl;
+ THolder<TImpl> Impl_;
+};
+
/**
* Non-buffered ZLib compressing stream.
*/
class TZLibCompress: public IOutputStream {
-public:
- struct TParams {
+public:
+ struct TParams {
inline TParams(IOutputStream* out)
- : Out(out)
- , Type(ZLib::ZLib)
- , CompressionLevel(6)
+ : Out(out)
+ , Type(ZLib::ZLib)
+ , CompressionLevel(6)
, BufLen(ZLib::ZLIB_BUF_LEN)
- {
- }
-
+ {
+ }
+
inline TParams& SetType(ZLib::StreamType type) noexcept {
- Type = type;
-
- return *this;
- }
-
+ Type = type;
+
+ return *this;
+ }
+
inline TParams& SetCompressionLevel(size_t level) noexcept {
- CompressionLevel = level;
-
- return *this;
- }
-
+ CompressionLevel = level;
+
+ return *this;
+ }
+
inline TParams& SetBufLen(size_t buflen) noexcept {
- BufLen = buflen;
-
- return *this;
- }
-
+ BufLen = buflen;
+
+ return *this;
+ }
+
inline TParams& SetDict(const TStringBuf dict) noexcept {
- Dict = dict;
-
- return *this;
- }
-
+ Dict = dict;
+
+ return *this;
+ }
+
IOutputStream* Out;
- ZLib::StreamType Type;
- size_t CompressionLevel;
- size_t BufLen;
- TStringBuf Dict;
- };
-
- inline TZLibCompress(const TParams& params) {
- Init(params);
- }
-
+ ZLib::StreamType Type;
+ size_t CompressionLevel;
+ size_t BufLen;
+ TStringBuf Dict;
+ };
+
+ inline TZLibCompress(const TParams& params) {
+ Init(params);
+ }
+
inline TZLibCompress(IOutputStream* out, ZLib::StreamType type) {
- Init(TParams(out).SetType(type));
- }
-
+ Init(TParams(out).SetType(type));
+ }
+
inline TZLibCompress(IOutputStream* out, ZLib::StreamType type, size_t compression_level) {
- Init(TParams(out).SetType(type).SetCompressionLevel(compression_level));
- }
-
+ Init(TParams(out).SetType(type).SetCompressionLevel(compression_level));
+ }
+
inline TZLibCompress(IOutputStream* out, ZLib::StreamType type, size_t compression_level, size_t buflen) {
- Init(TParams(out).SetType(type).SetCompressionLevel(compression_level).SetBufLen(buflen));
- }
-
+ Init(TParams(out).SetType(type).SetCompressionLevel(compression_level).SetBufLen(buflen));
+ }
+
~TZLibCompress() override;
-
-private:
- void Init(const TParams& opts);
-
+
+private:
+ void Init(const TParams& opts);
+
void DoWrite(const void* buf, size_t size) override;
void DoFlush() override;
void DoFinish() override;
-
-public:
- class TImpl;
-
+
+public:
+ class TImpl;
+
/** To allow inline constructors. */
- struct TDestruct {
- static void Destroy(TImpl* impl);
- };
-
- THolder<TImpl, TDestruct> Impl_;
-};
-
+ struct TDestruct {
+ static void Destroy(TImpl* impl);
+ };
+
+ THolder<TImpl, TDestruct> Impl_;
+};
+
/**
* Buffered ZLib decompressing stream.
*
@@ -160,12 +160,12 @@ public:
* usage patterns.
*/
class TBufferedZLibDecompress: public TBuffered<TZLibDecompress> {
-public:
- template <class T>
- inline TBufferedZLibDecompress(T* in, ZLib::StreamType type = ZLib::Auto, size_t buf = 1 << 13)
- : TBuffered<TZLibDecompress>(buf, in, type)
- {
- }
+public:
+ template <class T>
+ inline TBufferedZLibDecompress(T* in, ZLib::StreamType type = ZLib::Auto, size_t buf = 1 << 13)
+ : TBuffered<TZLibDecompress>(buf, in, type)
+ {
+ }
~TBufferedZLibDecompress() override;
};