69 lines
2.2 KiB
C++
69 lines
2.2 KiB
C++
/***
|
|
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
|
|
|
File: AuBaseStream.hpp
|
|
Date: 2022-2-14
|
|
Author: Reece
|
|
***/
|
|
#pragma once
|
|
|
|
#include "AuIngestableReadBase.hpp"
|
|
|
|
namespace Aurora::Compression
|
|
{
|
|
struct BaseStream : ICompressionStream, protected IngestableReadBase
|
|
{
|
|
inline BaseStream(AuUInt32 bufferSize = 4096 * 64) : _outbufferOwned(bufferSize, true), uBufferSize_(bufferSize)
|
|
{
|
|
SetBuffer({});
|
|
}
|
|
|
|
inline virtual ~BaseStream()
|
|
{}
|
|
|
|
virtual bool Init(const AuSPtr<IO::IStreamReader> &reader) = 0;
|
|
|
|
virtual AuUInt32 GetAvailableProcessedBytes() override;
|
|
virtual AuStreamReadWrittenPair_t ReadEx(const AuMemoryViewWrite & /*opt*/ destination, bool bIngestUntilEOS) override;
|
|
virtual AuUInt32 Read(const AuMemoryViewWrite & /*opt*/ destination) override;
|
|
|
|
virtual bool GoBackByProcessedN(AuUInt32 dwOffset) override;
|
|
virtual bool GoForwardByProcessedN(AuUInt32 dwOffset) override;
|
|
|
|
virtual AuUInt32 GetInternalBufferSize() override;
|
|
|
|
bool Write(const void *pDest, AuUInt32 dwLength);
|
|
bool Write2(const void *pDest, AuUInt32 dwLength);
|
|
|
|
AuPair<char *, AuUInt32> GetDOutPair();
|
|
|
|
virtual AuStreamReadWrittenPair_t Ingest(AuUInt32 bytesFromUnprocessedInputSource) override;
|
|
|
|
virtual bool Flush() override;
|
|
virtual bool Finish() override;
|
|
|
|
bool IsValid();
|
|
|
|
AuSPtr<Memory::ByteBuffer> GetBuffer();
|
|
void SetBuffer(const AuSPtr<Memory::ByteBuffer> &pBuffer);
|
|
|
|
AuSPtr<Memory::ByteBuffer> GetWeakBuffer();
|
|
void SetWeakBuffer(const AuSPtr<Memory::ByteBuffer> &pBuffer);
|
|
|
|
void InitByDesc(CompressInfo &info);
|
|
void InitByDesc(DecompressInfo &info);
|
|
|
|
protected:
|
|
virtual AuStreamReadWrittenPair_t Ingest_s(AuUInt32 dwBytesFromUnprocessedInputSource) = 0;
|
|
|
|
AuSPtr<Memory::ByteBuffer> pOutputBuffer_;
|
|
AuWPtr<Memory::ByteBuffer> wpInBuffer_;
|
|
AuSPtr<AuIO::IStreamWriter> pOutputBufferInterface_;
|
|
AuSPtr<Memory::ByteBuffer> pFallbackTempBuffer_;
|
|
Memory::ByteBuffer _outbufferOwned;
|
|
AuThreadPrimitives::SpinLock _spinlock;
|
|
AuUInt32 uBufferSize_;
|
|
};
|
|
}
|
|
|
|
#include "AuIngestableReadBase.inl" |