brotli.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #pragma once
  2. #include <util/generic/ptr.h>
  3. #include <util/stream/input.h>
  4. #include <util/stream/output.h>
  5. /**
  6. * @addtogroup Streams_Archs
  7. * @{
  8. */
  9. class TBrotliCompress: public IOutputStream {
  10. public:
  11. static constexpr int BEST_QUALITY = 11;
  12. /**
  13. @param slave stream to write compressed data to
  14. @param quality the higher the quality, the slower and better the compression. Range is 0 to 11.
  15. */
  16. explicit TBrotliCompress(IOutputStream* slave, int quality = BEST_QUALITY);
  17. ~TBrotliCompress() override;
  18. private:
  19. void DoWrite(const void* buffer, size_t size) override;
  20. void DoFlush() override;
  21. void DoFinish() override;
  22. public:
  23. class TImpl;
  24. THolder<TImpl> Impl_;
  25. };
  26. ////////////////////////////////////////////////////////////////////////////////
  27. class TBrotliDecompress: public IInputStream {
  28. public:
  29. /**
  30. @param slave stream to read compressed data from
  31. @param bufferSize approximate size of buffer compressed data is read in
  32. */
  33. explicit TBrotliDecompress(IInputStream* slave, size_t bufferSize = 8 * 1024);
  34. ~TBrotliDecompress() override;
  35. private:
  36. size_t DoRead(void* buffer, size_t size) override;
  37. private:
  38. class TImpl;
  39. THolder<TImpl> Impl_;
  40. };
  41. /** @} */