decompress.h 950 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #pragma once
  2. #include <util/stream/buffered.h>
  3. #include <util/stream/input.h>
  4. class IZeroCopyInput;
  5. /**
  6. * Unbuffered decompressing stream for .XZ and .LZMA files.
  7. *
  8. * Do not use it for reading in small pieces.
  9. */
  10. class TUnbufferedXzDecompress: public IInputStream {
  11. public:
  12. TUnbufferedXzDecompress(IInputStream* slave);
  13. TUnbufferedXzDecompress(IZeroCopyInput* slave);
  14. ~TUnbufferedXzDecompress() override;
  15. private:
  16. size_t DoRead(void* buf, size_t len) override;
  17. private:
  18. class TImpl;
  19. std::unique_ptr<TImpl> Impl_;
  20. };
  21. /**
  22. * Buffered decompressing stream for .XZ and .LZMA files.
  23. *
  24. * Supports efficient `ReadLine` calls and similar "reading in small pieces"
  25. * usage patterns.
  26. */
  27. class TXzDecompress: public TBuffered<TUnbufferedXzDecompress> {
  28. public:
  29. template <class T>
  30. inline TXzDecompress(T&& t, size_t buf = 1 << 13)
  31. : TBuffered<TUnbufferedXzDecompress>(buf, std::forward<T>(t))
  32. {
  33. }
  34. };