bzip2.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #pragma once
  2. #include <util/stream/input.h>
  3. #include <util/stream/output.h>
  4. #include <util/generic/ptr.h>
  5. #include <util/generic/yexception.h>
  6. #define BZIP_BUF_LEN (8 * 1024)
  7. #define BZIP_COMPRESSION_LEVEL 6
  8. /**
  9. * @addtogroup Streams_Archs
  10. * @{
  11. */
  12. class TBZipException: public yexception {
  13. };
  14. class TBZipDecompressError: public TBZipException {
  15. };
  16. class TBZipCompressError: public TBZipException {
  17. };
  18. class TBZipDecompress: public IInputStream {
  19. public:
  20. TBZipDecompress(IInputStream* input, size_t bufLen = BZIP_BUF_LEN);
  21. ~TBZipDecompress() override;
  22. private:
  23. size_t DoRead(void* buf, size_t size) override;
  24. private:
  25. class TImpl;
  26. THolder<TImpl> Impl_;
  27. };
  28. class TBZipCompress: public IOutputStream {
  29. public:
  30. TBZipCompress(IOutputStream* out, size_t compressionLevel = BZIP_COMPRESSION_LEVEL, size_t bufLen = BZIP_BUF_LEN);
  31. ~TBZipCompress() override;
  32. private:
  33. void DoWrite(const void* buf, size_t size) override;
  34. void DoFlush() override;
  35. void DoFinish() override;
  36. public:
  37. class TImpl;
  38. THolder<TImpl> Impl_;
  39. };
  40. /** @} */