#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_BROTLI_BROTLICOMPRESSOR_H #define NUCLEX_STORAGE_COMPRESSION_BROTLI_BROTLICOMPRESSOR_H #include "Nuclex/Storage/Config.h" #if defined(NUCLEX_STORAGE_HAVE_BROTLI) #include "Nuclex/Storage/Compression/Compressor.h" #include namespace Nuclex { namespace Storage { namespace Compression { namespace Brotli { // ------------------------------------------------------------------------------------------- // /// Compresses and decompresses data using Google's Brotli algorithm class BrotliCompressor : public Compressor { /// Initializes a new Brotli compressor /// /// Compression quality that will be passed to the Brotli encoder /// public: BrotliCompressor(int quality = BROTLI_DEFAULT_QUALITY); /// Frees all resources owned by the instance public: ~BrotliCompressor() 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 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 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; /// State of the Brotli encoder private: ::BrotliEncoderState *state; }; // ------------------------------------------------------------------------------------------- // }}}} // namespace Nuclex::Storage::Compression::Brotli #endif // defined(NUCLEX_STORAGE_HAVE_BROTLI) #endif // NUCLEX_STORAGE_COMPRESSION_BROTLI_BROTLICOMPRESSOR_H