The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

85 lines
3.6KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library - "Jules' Utility Class Extensions"
  4. Copyright 2004-9 by Raw Material Software Ltd.
  5. ------------------------------------------------------------------------------
  6. JUCE can be redistributed and/or modified under the terms of the GNU General
  7. Public License (Version 2), as published by the Free Software Foundation.
  8. A copy of the license is included in the JUCE distribution, or can be found
  9. online at www.gnu.org/licenses.
  10. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  11. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  12. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  13. ------------------------------------------------------------------------------
  14. To release a closed-source product which uses JUCE, commercial licenses are
  15. available: visit www.rawmaterialsoftware.com/juce for more information.
  16. ==============================================================================
  17. */
  18. #ifndef __JUCE_GZIPCOMPRESSOROUTPUTSTREAM_JUCEHEADER__
  19. #define __JUCE_GZIPCOMPRESSOROUTPUTSTREAM_JUCEHEADER__
  20. #include "juce_OutputStream.h"
  21. //==============================================================================
  22. /**
  23. A stream which uses zlib to compress the data written into it.
  24. @see GZIPDecompressorInputStream
  25. */
  26. class JUCE_API GZIPCompressorOutputStream : public OutputStream
  27. {
  28. public:
  29. //==============================================================================
  30. /** Creates a compression stream.
  31. @param destStream the stream into which the compressed data should
  32. be written
  33. @param compressionLevel how much to compress the data, between 1 and 9, where
  34. 1 is the fastest/lowest compression, and 9 is the
  35. slowest/highest compression. Any value outside this range
  36. indicates that a default compression level should be used.
  37. @param deleteDestStreamWhenDestroyed whether or not to delete the destStream object when
  38. this stream is destroyed
  39. @param noWrap this is used internally by the ZipFile class
  40. and should be ignored by user applications
  41. */
  42. GZIPCompressorOutputStream (OutputStream* const destStream,
  43. int compressionLevel = 0,
  44. const bool deleteDestStreamWhenDestroyed = false,
  45. const bool noWrap = false);
  46. /** Destructor. */
  47. ~GZIPCompressorOutputStream();
  48. //==============================================================================
  49. void flush();
  50. int64 getPosition();
  51. bool setPosition (int64 newPosition);
  52. bool write (const void* destBuffer, int howMany);
  53. //==============================================================================
  54. juce_UseDebuggingNewOperator
  55. private:
  56. OutputStream* const destStream;
  57. const bool deleteDestStream;
  58. HeapBlock <uint8> buffer;
  59. void* helper;
  60. bool doNextBlock();
  61. GZIPCompressorOutputStream (const GZIPCompressorOutputStream&);
  62. const GZIPCompressorOutputStream& operator= (const GZIPCompressorOutputStream&);
  63. };
  64. #endif // __JUCE_GZIPCOMPRESSOROUTPUTSTREAM_JUCEHEADER__