Jamie Reece Wilson
4ce49941ff
[+] SysCheckNotNull [+] SysCheckRetExpNotNull [+] SysCheckRetExpNotNullMemory
46 lines
1.6 KiB
C++
46 lines
1.6 KiB
C++
/***
|
|
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 });
|
|
SysCheckNotNull(pBuffer, {});
|
|
|
|
SysCheckRetExpNotNullMemory(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 });
|
|
SysCheckNotNull(pBuffer, {});
|
|
|
|
SysCheckRetExpNotNullMemory(AuMakeShared<Buffered::BlobSeekableReader>(pBuffer), {});
|
|
}
|
|
|
|
AUKN_SYM AuSPtr<IStreamWriter> NewMemoryViewWriteAdapter(const AuSPtr<Memory::MemoryViewWrite> &pView)
|
|
{
|
|
SysCheckArgNotNull(pView, {});
|
|
|
|
auto pBuffer = AuMakeShared<AuMemory::SharedByteBuffer>(pView, *pView);
|
|
SysCheckNotNull(pBuffer, {});
|
|
|
|
pBuffer->writePtr = (AuUInt8 *)pView->ptr;
|
|
|
|
SysCheckRetExpNotNullMemory(AuMakeShared<Buffered::BlobWriter>(pBuffer), {});
|
|
}
|
|
} |