53 lines
1.5 KiB
C++
53 lines
1.5 KiB
C++
|
/***
|
||
|
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||
|
|
||
|
File: BaseStream.hpp
|
||
|
Date: 2022-2-14
|
||
|
Author: Reece
|
||
|
***/
|
||
|
#pragma once
|
||
|
|
||
|
#include "IngestableReadBase.hpp"
|
||
|
|
||
|
namespace Aurora::Compression
|
||
|
{
|
||
|
struct BaseStream : public ICompressionStream, protected IngestableReadBase
|
||
|
{
|
||
|
BaseStream(int bufferSize = 4096 * 4) : _outbuffer(bufferSize)
|
||
|
{}
|
||
|
|
||
|
virtual ~BaseStream()
|
||
|
{}
|
||
|
|
||
|
virtual bool Init(const AuSPtr<IO::IStreamReader> &reader) = 0;
|
||
|
|
||
|
virtual AuUInt32 GetAvailableProcessedBytes() override;
|
||
|
virtual AuStreamReadWrittenPair_t ReadEx(const Memory::MemoryViewWrite & /*opt*/ destination, bool ingestUntilEOS) override;
|
||
|
virtual AuUInt32 Read(const Memory::MemoryViewWrite & /*opt*/ destination) override;
|
||
|
|
||
|
virtual bool GoBackByProcessedN(AuUInt32 offset) override;
|
||
|
virtual bool GoForwardByProcessedN(AuUInt32 offset) override;
|
||
|
|
||
|
virtual AuUInt32 GetInternalBufferSize() override;
|
||
|
|
||
|
bool Write(const void *a, AuUInt32 length);
|
||
|
|
||
|
virtual AuStreamReadWrittenPair_t Ingest(AuUInt32 bytesFromUnprocessedInputSource) override;
|
||
|
|
||
|
virtual bool Flush() override
|
||
|
{
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
virtual bool Finish() override
|
||
|
{
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
protected:
|
||
|
virtual AuStreamReadWrittenPair_t Ingest_s(AuUInt32 bytesFromUnprocessedInputSource) = 0;
|
||
|
|
||
|
Memory::ByteBuffer _outbuffer;
|
||
|
AuThreadPrimitives::SpinLock _spinlock;
|
||
|
};
|
||
|
}
|