[+] ICompressionStream::ToStreamReader
This commit is contained in:
parent
7c65affc76
commit
69188d8c1e
@ -82,5 +82,11 @@ namespace Aurora::Compression
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
virtual AuOptional<AuString> GetLastErrorString() = 0;
|
virtual AuOptional<AuString> GetLastErrorString() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
virtual IO::IStreamReader *ToStreamReader() = 0;
|
||||||
};
|
};
|
||||||
}
|
}
|
@ -227,4 +227,9 @@ namespace Aurora::Compression
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IO::IStreamReader *BaseStream::ToStreamReader()
|
||||||
|
{
|
||||||
|
return &this->reader_;
|
||||||
|
}
|
||||||
}
|
}
|
@ -8,12 +8,18 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "AuIngestableReadBase.hpp"
|
#include "AuIngestableReadBase.hpp"
|
||||||
|
#include <Source/IO/Adapters/AuIOAdapterCompression.hpp>
|
||||||
|
|
||||||
namespace Aurora::Compression
|
namespace Aurora::Compression
|
||||||
{
|
{
|
||||||
struct BaseStream : ICompressionStream, protected IngestableReadBase
|
struct BaseStream :
|
||||||
|
ICompressionStream,
|
||||||
|
protected IngestableReadBase
|
||||||
{
|
{
|
||||||
inline BaseStream(AuUInt32 bufferSize = 4096 * 64) : _outbufferOwned(bufferSize, true), uBufferSize_(bufferSize)
|
inline BaseStream(AuUInt32 bufferSize = 4096 * 64) :
|
||||||
|
_outbufferOwned(bufferSize, true),
|
||||||
|
uBufferSize_(bufferSize),
|
||||||
|
reader_(AuUnsafeRaiiToShared(this))
|
||||||
{
|
{
|
||||||
SetBuffer({});
|
SetBuffer({});
|
||||||
}
|
}
|
||||||
@ -48,6 +54,8 @@ namespace Aurora::Compression
|
|||||||
virtual bool Flush() override;
|
virtual bool Flush() override;
|
||||||
virtual bool Finish() override;
|
virtual bool Finish() override;
|
||||||
|
|
||||||
|
virtual IO::IStreamReader *ToStreamReader() override;
|
||||||
|
|
||||||
bool IsValid();
|
bool IsValid();
|
||||||
|
|
||||||
AuSPtr<Memory::ByteBuffer> GetBuffer();
|
AuSPtr<Memory::ByteBuffer> GetBuffer();
|
||||||
@ -61,7 +69,7 @@ namespace Aurora::Compression
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual AuStreamReadWrittenPair_t Ingest_s(AuUInt32 dwBytesFromUnprocessedInputSource) = 0;
|
virtual AuStreamReadWrittenPair_t Ingest_s(AuUInt32 dwBytesFromUnprocessedInputSource) = 0;
|
||||||
|
IO::Adapters::CompressionStreamReader reader_;
|
||||||
AuSPtr<Memory::ByteBuffer> pOutputBuffer_;
|
AuSPtr<Memory::ByteBuffer> pOutputBuffer_;
|
||||||
AuWPtr<Memory::ByteBuffer> wpInBuffer_;
|
AuWPtr<Memory::ByteBuffer> wpInBuffer_;
|
||||||
AuSPtr<AuIO::IStreamWriter> pOutputBufferInterface_;
|
AuSPtr<AuIO::IStreamWriter> pOutputBufferInterface_;
|
||||||
|
@ -25,7 +25,14 @@ namespace Aurora::IO::Adapters
|
|||||||
|
|
||||||
EStreamError CompressionStreamReader::IsOpen()
|
EStreamError CompressionStreamReader::IsOpen()
|
||||||
{
|
{
|
||||||
return this->bErrored_ ? EStreamError::eErrorEndOfStream : EStreamError::eErrorNone;
|
if (this->pCompressionStream->GetLastError())
|
||||||
|
{
|
||||||
|
return EStreamError::eErrorGenericFault;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this->bErrored_ ?
|
||||||
|
EStreamError::eErrorEndOfStream :
|
||||||
|
EStreamError::eErrorNone;
|
||||||
}
|
}
|
||||||
|
|
||||||
EStreamError CompressionStreamReader::Read(const Memory::MemoryViewStreamWrite ¶meters)
|
EStreamError CompressionStreamReader::Read(const Memory::MemoryViewStreamWrite ¶meters)
|
||||||
@ -67,7 +74,7 @@ namespace Aurora::IO::Adapters
|
|||||||
if (!this->pCompressionStream->GoBackByProcessedN(this->uOffset - offset))
|
if (!this->pCompressionStream->GoBackByProcessedN(this->uOffset - offset))
|
||||||
{
|
{
|
||||||
SysPushErrorIO("Negative compression seek out of bounds");
|
SysPushErrorIO("Negative compression seek out of bounds");
|
||||||
return EStreamError::eErrorStreamInterrupted;
|
return EStreamError::eErrorOutOfBounds;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -75,7 +82,7 @@ namespace Aurora::IO::Adapters
|
|||||||
if (!this->pCompressionStream->GoForwardByProcessedN(offset - this->uOffset))
|
if (!this->pCompressionStream->GoForwardByProcessedN(offset - this->uOffset))
|
||||||
{
|
{
|
||||||
SysPushErrorIO("Positive compression seek out of bounds");
|
SysPushErrorIO("Positive compression seek out of bounds");
|
||||||
return EStreamError::eErrorStreamInterrupted;
|
return EStreamError::eErrorOutOfBounds;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,11 +107,13 @@ namespace Aurora::IO::Adapters
|
|||||||
|
|
||||||
AUKN_SYM AuSPtr<IStreamReader> NewCompressionReadAdapter(const AuSPtr<Compression::ICompressionStream> &pCompresionStream)
|
AUKN_SYM AuSPtr<IStreamReader> NewCompressionReadAdapter(const AuSPtr<Compression::ICompressionStream> &pCompresionStream)
|
||||||
{
|
{
|
||||||
|
SysCheckArgNotNull(pCompresionStream, {});
|
||||||
return AuMakeShared<CompressionStreamReader>(pCompresionStream);
|
return AuMakeShared<CompressionStreamReader>(pCompresionStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
AUKN_SYM AuSPtr<ISeekingReader> NewCompressionSeekingAdapter(const AuSPtr<Compression::ICompressionStream> &pCompresionStream)
|
AUKN_SYM AuSPtr<ISeekingReader> NewCompressionSeekingAdapter(const AuSPtr<Compression::ICompressionStream> &pCompresionStream)
|
||||||
{
|
{
|
||||||
|
SysCheckArgNotNull(pCompresionStream, {});
|
||||||
return AuMakeShared<CompressionSeekingReader>(pCompresionStream);
|
return AuMakeShared<CompressionSeekingReader>(pCompresionStream);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user