102 lines
3.4 KiB
C++
102 lines
3.4 KiB
C++
/***
|
|
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
|
|
|
File: ICompressionStream.hpp
|
|
Date: 2021-7-14
|
|
Author: Reece
|
|
***/
|
|
#pragma once
|
|
|
|
#include <Aurora/IO/EStreamError.hpp>
|
|
#include <Aurora/IO/IStreamReader.hpp>
|
|
#include <Aurora/IO/ISeekingReader.hpp>
|
|
|
|
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 dwBytesFromUnprocessedInputSource
|
|
* @return
|
|
*/
|
|
virtual AuStreamReadWrittenPair_t Ingest(AuUInt32 dwBytesFromUnprocessedInputSource) = 0;
|
|
|
|
/**
|
|
* @brief Returns the available bytes for immediate release by ::Read (or ::ReadEx(..., false))
|
|
* @return
|
|
*/
|
|
virtual AuUInt32 GetAvailableProcessedBytes() = 0;
|
|
|
|
/**
|
|
* @brief Returns the allocation overhead of 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 bIngestUntilEOS 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 bIngestUntilEOS = true) = 0;
|
|
|
|
/**
|
|
* @brief Reads 'minimumProcessed', optionally into the first buffer, from the internal stream buffer
|
|
* @param dwOffset
|
|
* @return Bytes written
|
|
*/
|
|
virtual AuUInt32 Read(const Memory::MemoryViewWrite & /*opt*/ destination) = 0;
|
|
|
|
/**
|
|
* @brief Seek processed ::Read/::ReadEx backwards
|
|
* @param dwOffset
|
|
* @return
|
|
*/
|
|
virtual bool GoBackByProcessedN (AuUInt32 dwOffset) = 0;
|
|
|
|
/**
|
|
* @brief Seek processed ::Read/::ReadEx forwards
|
|
* @param dwOffset
|
|
* @return
|
|
*/
|
|
virtual bool GoForwardByProcessedN(AuUInt32 dwOffset) = 0;
|
|
|
|
/// Compression only
|
|
virtual bool Flush() = 0;
|
|
|
|
/// Compression only
|
|
virtual bool Finish() = 0;
|
|
|
|
/**
|
|
* @brief
|
|
* @return
|
|
*/
|
|
virtual AuOptional<int> GetLastError() = 0;
|
|
|
|
/**
|
|
* @brief
|
|
* @return
|
|
*/
|
|
virtual AuOptional<AuString> GetLastErrorString() = 0;
|
|
|
|
/**
|
|
* @brief
|
|
* @return
|
|
*/
|
|
virtual IO::IStreamReader *ToStreamReader() = 0;
|
|
|
|
/**
|
|
* @brief
|
|
* @return
|
|
*/
|
|
virtual IO::ISeekingReader *ToSeekingStreamReader() = 0;
|
|
};
|
|
} |