AuroraRuntime/Source/Compression/BaseStream.hpp
Reece Wilson 8844e8fe64 [+] AuCrypto::BCrypt
> GetForcedMinRounds
> GenSalt
> HashPW
> HashPWEx
> CheckPassword
> CheckPasswordEx
[*] Refactor AuCompression APIs
[*] Clean up AuTryConstructs
[+] Internal compression API for compression based interceptors
[+] Root-level input stream arg check for all compression apis (harden)
[*] Clean up AuCompression code
[+] Solar Designer / OpenWall blowfish crypt
[*] BlowCrypt: accept length input parameter
[*] Split locale into 2 source files
[-] Ugly comment from Open.Win32.cpp. TODO: Readd later. Might warn on empty string bc it makes sense given, "." and "/" normalizes to nothing, and memory pre-idc-if-drops are dropped siliently.
2022-09-15 20:48:50 +01:00

62 lines
1.8 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 : ICompressionStream, protected IngestableReadBase
{
inline BaseStream(AuUInt32 bufferSize = 4096 * 4) : _outbufferOwned(bufferSize), uBufferSize_(bufferSize)
{
SetBuffer({});
}
inline 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;
inline virtual bool Flush() override
{
return false;
}
inline virtual bool Finish() override
{
return false;
}
bool IsValid();
AuSPtr<Memory::ByteBuffer> GetBuffer();
void SetBuffer(const AuSPtr<Memory::ByteBuffer> &pBuffer);
protected:
virtual AuStreamReadWrittenPair_t Ingest_s(AuUInt32 bytesFromUnprocessedInputSource) = 0;
AuSPtr<Memory::ByteBuffer> pOutputBuffer_;
Memory::ByteBuffer _outbufferOwned;
AuThreadPrimitives::SpinLock _spinlock;
AuUInt32 uBufferSize_;
};
}