/*** Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved. File: ICompressionStream.hpp Date: 2021-7-14 Author: Reece ***/ #pragma once namespace Aurora::Compression { struct ICompressionStream { /** * @brief Ingest n bytes from the input stream assigned to the compression object. * On error, returns {0, 0} or {bytesRead, 0} * If the stream buffer runs out of memory, {bytesRead, 0} is expected, and although * `GetAvailableProcessedBytes()` will still return some data, the decompressed data * or uncompressed stream will be dropped in part, and you should destroy from the stream object * @param bytesFromUnprocessedInputSource * @return */ virtual AuStreamReadWrittenPair_t Ingest(AuUInt32 bytesFromUnprocessedInputSource) = 0; /** * @brief Returns the available bytes for immediate release * @return */ virtual AuUInt32 GetAvailableProcessedBytes() = 0; /** * @brief Returns the internal overhead to store the seekable stream buffer * @return */ virtual AuUInt32 GetInternalBufferSize() = 0; /** * @brief Reads 'minimumProcessed', optionally into the first buffer, until EOS or destination length. * If the destination is null and the length is a nonzero value, the stream seeks ahead * If the destination is null and the length is a zero, {0, GetAvailableProcessedBytes} is returned * @param destination * @param ingestUntilEOS should continue to poll Ingest with an arbitrary page size to fulfill destination.length * @return Bytes read / written */ virtual AuStreamReadWrittenPair_t ReadEx(const Memory::MemoryViewWrite & /*opt*/ destination, bool ingestUntilEOS = true) = 0; /** * @brief Reads 'minimumProcessed', optionally into the first buffer, from the internal stream buffer * @param destination * @return Bytes written */ virtual AuUInt32 Read(const Memory::MemoryViewWrite & /*opt*/ destination) = 0; /** * @brief Seek processed read functions backwards * @param offset * @return */ virtual bool GoBackByProcessedN (AuUInt32 offset) = 0; /** * @brief Seek read processed forward * @param offset * @return */ virtual bool GoForwardByProcessedN(AuUInt32 offset) = 0; /// Compression only virtual bool Flush() = 0; /// Compression only virtual bool Finish() = 0; }; }