#pragma region CPL License /* Nuclex Native Framework Copyright (C) 2002-2021 Nuclex Development Labs This library is free software; you can redistribute it and/or modify it under the terms of the IBM Common Public License as published by the IBM Corporation; either version 1.0 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the IBM Common Public License for more details. You should have received a copy of the IBM Common Public License along with this library */ #pragma endregion // CPL License #ifndef NUCLEX_STORAGE_COMPRESSION_ZLIB_DEFLATECOMPRESSOR_H #define NUCLEX_STORAGE_COMPRESSION_ZLIB_DEFLATECOMPRESSOR_H #include "Nuclex/Storage/Config.h" #if defined(NUCLEX_STORAGE_HAVE_ZLIB) #include "Nuclex/Storage/Compression/Compressor.h" #include namespace Nuclex { namespace Storage { namespace Compression { namespace ZLib { // ------------------------------------------------------------------------------------------- // /// Compresses data using the ZLib implementation of the deflate algorithm class DeflateCompressor : public Compressor { /// Initializes a new ZLib compressor /// /// Compression level that will be passed to the ZLib compressor /// public: DeflateCompressor(int level = Z_DEFAULT_COMPRESSION); /// Frees all resources owned by the instance public: ~DeflateCompressor() override; /// /// Compresses the data in the input buffer and writes it to the output buffer /// /// Buffer containing the uncompressed data /// /// Number of uncompressed bytes in the uncompressed buffer. Will be set to /// the number of remaining bytes when the method returns /// /// Buffer in which the compressed data will be stored /// /// Available space in the output buffer. Will be set to the numer of bytes actually /// stored in the output buffer when the method returns /// /// /// The reason why the method stopped processing data. This may either be because /// all available input was compressed (), /// or because the compressor ran out of space in the output buffer /// (). /// public: StopReason Process( const std::uint8_t *uncompressedBuffer, std::size_t &uncompressedByteCount, std::uint8_t *outputBuffer, std::size_t &outputByteCount ) override; /// Finishes compressing and writes any remaining output bytes /// Buffer in which the compressed data will be stored /// /// Available space in the output buffer. Will be set to the numer of bytes actually /// stored in the output buffer when the method returns /// /// /// The reason why the method stopped processing. This should normally be the /// value but may also be /// if the output buffer was insufficient /// to output all data (in which case you need to call Finish() another time). /// public: StopReason Finish( std::uint8_t *outputBuffer, std::size_t &outputByteCount ) override; /// Maintains the ZLib deflate compressor's state private: ::z_stream stream; }; // ------------------------------------------------------------------------------------------- // }}}} // namespace Nuclex::Storage::Compression::ZLib #endif // defined(NUCLEX_STORAGE_HAVE_ZLIB) #endif // NUCLEX_STORAGE_COMPRESSION_ZLIB_DEFLATECOMPRESSOR_H