diff options
author | Devtools Arcadia <arcadia-devtools@yandex-team.ru> | 2022-02-07 18:08:42 +0300 |
---|---|---|
committer | Devtools Arcadia <arcadia-devtools@mous.vla.yp-c.yandex.net> | 2022-02-07 18:08:42 +0300 |
commit | 1110808a9d39d4b808aef724c861a2e1a38d2a69 (patch) | |
tree | e26c9fed0de5d9873cce7e00bc214573dc2195b7 /library/cpp/streams/brotli/brotli.h | |
download | ydb-1110808a9d39d4b808aef724c861a2e1a38d2a69.tar.gz |
intermediate changes
ref:cde9a383711a11544ce7e107a78147fb96cc4029
Diffstat (limited to 'library/cpp/streams/brotli/brotli.h')
-rw-r--r-- | library/cpp/streams/brotli/brotli.h | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/library/cpp/streams/brotli/brotli.h b/library/cpp/streams/brotli/brotli.h new file mode 100644 index 00000000000..b3af869e29c --- /dev/null +++ b/library/cpp/streams/brotli/brotli.h @@ -0,0 +1,52 @@ +#pragma once + +#include <util/generic/ptr.h> +#include <util/stream/input.h> +#include <util/stream/output.h> + +/** + * @addtogroup Streams_Archs + * @{ + */ + +class TBrotliCompress: public IOutputStream { +public: + static constexpr int BEST_QUALITY = 11; + + /** + @param slave stream to write compressed data to + @param quality the higher the quality, the slower and better the compression. Range is 0 to 11. + */ + explicit TBrotliCompress(IOutputStream* slave, int quality = BEST_QUALITY); + ~TBrotliCompress() override; + +private: + void DoWrite(const void* buffer, size_t size) override; + void DoFlush() override; + void DoFinish() override; + +public: + class TImpl; + THolder<TImpl> Impl_; +}; + +//////////////////////////////////////////////////////////////////////////////// + +class TBrotliDecompress: public IInputStream { +public: + /** + @param slave stream to read compressed data from + @param bufferSize approximate size of buffer compressed data is read in + */ + explicit TBrotliDecompress(IInputStream* slave, size_t bufferSize = 8 * 1024); + ~TBrotliDecompress() override; + +private: + size_t DoRead(void* buffer, size_t size) override; + +private: + class TImpl; + THolder<TImpl> Impl_; +}; + +/** @} */ |