Gzip.h 795 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #ifndef GZIP_H__
  2. #define GZIP_H__
  3. #include <zlib.h>
  4. namespace i2p {
  5. namespace data {
  6. class GzipInflator
  7. {
  8. public:
  9. GzipInflator ();
  10. ~GzipInflator ();
  11. size_t Inflate (const uint8_t * in, size_t inLen, uint8_t * out, size_t outLen);
  12. /** @note @a os failbit will be set in case of error */
  13. void Inflate (const uint8_t * in, size_t inLen, std::ostream& os);
  14. void Inflate (std::istream& in, std::ostream& out);
  15. private:
  16. z_stream m_Inflator;
  17. bool m_IsDirty;
  18. };
  19. class GzipDeflator
  20. {
  21. public:
  22. GzipDeflator ();
  23. ~GzipDeflator ();
  24. void SetCompressionLevel (int level);
  25. size_t Deflate (const uint8_t * in, size_t inLen, uint8_t * out, size_t outLen);
  26. private:
  27. z_stream m_Deflator;
  28. bool m_IsDirty;
  29. };
  30. } // data
  31. } // i2p
  32. #endif /* GZIP_H__ */