diff options
author | qrort <qrort@yandex-team.com> | 2022-11-30 23:47:12 +0300 |
---|---|---|
committer | qrort <qrort@yandex-team.com> | 2022-11-30 23:47:12 +0300 |
commit | 22f8ae0e3f5d68b92aecccdf96c1d841a0334311 (patch) | |
tree | bffa27765faf54126ad44bcafa89fadecb7a73d7 /library/cpp/streams/xz/decompress.h | |
parent | 332b99e2173f0425444abb759eebcb2fafaa9209 (diff) | |
download | ydb-22f8ae0e3f5d68b92aecccdf96c1d841a0334311.tar.gz |
validate canons without yatest_common
Diffstat (limited to 'library/cpp/streams/xz/decompress.h')
-rw-r--r-- | library/cpp/streams/xz/decompress.h | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/library/cpp/streams/xz/decompress.h b/library/cpp/streams/xz/decompress.h new file mode 100644 index 0000000000..8389cbdaf9 --- /dev/null +++ b/library/cpp/streams/xz/decompress.h @@ -0,0 +1,40 @@ +#pragma once + +#include <util/stream/buffered.h> +#include <util/stream/input.h> + +class IZeroCopyInput; + +/** + * Unbuffered decompressing stream for .XZ and .LZMA files. + * + * Do not use it for reading in small pieces. + */ +class TUnbufferedXzDecompress: public IInputStream { +public: + TUnbufferedXzDecompress(IInputStream* slave); + TUnbufferedXzDecompress(IZeroCopyInput* slave); + ~TUnbufferedXzDecompress() override; + +private: + size_t DoRead(void* buf, size_t len) override; + +private: + class TImpl; + std::unique_ptr<TImpl> Impl_; +}; + +/** + * Buffered decompressing stream for .XZ and .LZMA files. + * + * Supports efficient `ReadLine` calls and similar "reading in small pieces" + * usage patterns. + */ +class TXzDecompress: public TBuffered<TUnbufferedXzDecompress> { +public: + template <class T> + inline TXzDecompress(T&& t, size_t buf = 1 << 13) + : TBuffered<TUnbufferedXzDecompress>(buf, std::forward<T>(t)) + { + } +}; |