[+} NewMemoryViewReadAdapter

[+] NewMemoryViewLinearSeekableAdapter
[+] NewMemoryViewWriteAdapter
This commit is contained in:
Reece Wilson 2023-10-13 21:08:00 +01:00
parent 19849ac0f2
commit be60d2c80d
4 changed files with 87 additions and 0 deletions

View File

@ -0,0 +1,15 @@
/***
Copyright (C) 2023 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: IOAdapterMemoryView.hpp
Date: 2023-09-23
Author: Reece
***/
#pragma once
namespace Aurora::IO::Adapters
{
AUKN_SYM AuSPtr<IStreamReader> NewMemoryViewReadAdapter(const AuSPtr<Memory::MemoryViewRead> &pView);
AUKN_SYM AuSPtr<ISeekingReader> NewMemoryViewLinearSeekableAdapter(const AuSPtr<Memory::MemoryViewRead> &pView);
AUKN_SYM AuSPtr<IStreamWriter> NewMemoryViewWriteAdapter(const AuSPtr<Memory::MemoryViewWrite> &pView);
}

View File

@ -50,6 +50,7 @@
#include "Adapters/IOAdapterByteBuffer.hpp"
#include "Adapters/IOAdapterCompression.hpp"
#include "Adapters/IOAdapterSeeking.hpp"
#include "Adapters/IOAdapterMemoryView.hpp"
#include "IIOWaitableTickLimiter.hpp"
#include "IIOWaitableIOTimer.hpp"

View File

@ -0,0 +1,58 @@
/***
Copyright (C) 2023 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: AuIOAdapterMemoryView.cpp
Date: 2023-09-23
Author: Reece
***/
#include <Source/RuntimeInternal.hpp>
#include <Aurora/IO/IOExperimental.hpp>
#include "AuIOAdapterByteBuffer.hpp"
namespace Aurora::IO::Adapters
{
AUKN_SYM AuSPtr<IStreamReader> NewMemoryViewReadAdapter(const AuSPtr<Memory::MemoryViewRead> &pView)
{
SysCheckArgNotNull(pView, {});
auto pBuffer = AuMakeShared<AuMemory::SharedByteBuffer>(pView, AuMemoryViewWrite { (void *)pView->ptr, pView->length });
if (!pBuffer)
{
SysPushErrorArg();
return {};
}
return AuMakeShared<Buffered::BlobReader>(pBuffer);
}
AUKN_SYM AuSPtr<ISeekingReader> NewMemoryViewLinearSeekableAdapter(const AuSPtr<Memory::MemoryViewRead> &pView)
{
SysCheckArgNotNull(pView, {});
auto pBuffer = AuMakeShared<AuMemory::SharedByteBuffer>(pView, AuMemoryViewWrite { (void *)pView->ptr, pView->length });
if (!pBuffer)
{
SysPushErrorArg();
return {};
}
return AuMakeShared<Buffered::BlobSeekableReader>(pBuffer);
}
AUKN_SYM AuSPtr<IStreamWriter> NewMemoryViewWriteAdapter(const AuSPtr<Memory::MemoryViewWrite> &pView)
{
SysCheckArgNotNull(pView, {});
auto pBuffer = AuMakeShared<AuMemory::SharedByteBuffer>(pView, *pView);
if (!pBuffer)
{
SysPushErrorArg();
return {};
}
pBuffer->writePtr = (AuUInt8 *)pView->ptr;
return AuMakeShared<Buffered::BlobWriter>(pBuffer);
}
}

View File

@ -0,0 +1,13 @@
/***
Copyright (C) 2023 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: AuIOAdapterMemoryView.hpp
Date: 2023-09-23
Author: Reece
***/
#pragma once
namespace Aurora::IO::Adapters
{
}