AuroraRuntime/Source/IO/Adapters/AuIOAdapterZeros.cpp
Jamie Reece Wilson 72a3513a04 [+] New stream adapters
[+] IRandomDevice::ToStreamReader
[+] AuIO::Adapters::NewRandomAdapter
[+] AuIO::Adapters::NewNOPsReadAdapter
[+] AuIO::Adapters::NewNOPsSeekingAdapter
[+] AuIO::Adapters::NewNOPsWriteAdapter
[+] AuIO::Adapters::NewZerosReadAdapter
[+] AuIO::Adapters::NewZerosSeekingAdapter
2024-01-03 23:54:46 +00:00

68 lines
1.7 KiB
C++

/***
Copyright (C) 2024 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: AuIOAdapterZeros.cpp
Date: 2024-1-3
Author: Reece
***/
#include <Source/RuntimeInternal.hpp>
#include "AuIOAdapterZeros.hpp"
namespace Aurora::IO::Adapters
{
EStreamError ZerosStreamReader::IsOpen()
{
return EStreamError::eErrorNone;
}
EStreamError ZerosStreamReader::Read(const Memory::MemoryViewStreamWrite &parameters)
{
if (!parameters)
{
parameters.outVariable = 0;
return EStreamError::eErrorOutOfBounds;
}
AuMemset(parameters.ptr, 0, parameters.length);
parameters.outVariable = parameters.length;
return EStreamError::eErrorNone;
}
void ZerosStreamReader::Close()
{
}
EStreamError ZerosStreamSeekingReader::IsOpen()
{
return EStreamError::eErrorNone;
}
EStreamError ZerosStreamSeekingReader::ArbitraryRead(AuUInt uOffset, const Memory::MemoryViewStreamWrite &parameters)
{
if (!parameters)
{
parameters.outVariable = 0;
return EStreamError::eErrorOutOfBounds;
}
AuMemset(parameters.ptr, 0, parameters.length);
parameters.outVariable = parameters.length;
return EStreamError::eErrorNone;
}
void ZerosStreamSeekingReader::Close()
{
}
AUKN_SYM AuSPtr<IStreamReader> NewZerosReadAdapter()
{
SysCheckRetExpNotNullMemory(AuMakeShared<ZerosStreamReader>(), {});
}
AUKN_SYM AuSPtr<ISeekingReader> NewZerosSeekingAdapter()
{
SysCheckRetExpNotNullMemory(AuMakeShared<ZerosStreamSeekingReader>(), {});
}
}