[+} NewMemoryViewReadAdapter
[+] NewMemoryViewLinearSeekableAdapter [+] NewMemoryViewWriteAdapter
This commit is contained in:
parent
19849ac0f2
commit
be60d2c80d
15
Include/Aurora/IO/Adapters/IOAdapterMemoryView.hpp
Normal file
15
Include/Aurora/IO/Adapters/IOAdapterMemoryView.hpp
Normal 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);
|
||||||
|
}
|
@ -50,6 +50,7 @@
|
|||||||
#include "Adapters/IOAdapterByteBuffer.hpp"
|
#include "Adapters/IOAdapterByteBuffer.hpp"
|
||||||
#include "Adapters/IOAdapterCompression.hpp"
|
#include "Adapters/IOAdapterCompression.hpp"
|
||||||
#include "Adapters/IOAdapterSeeking.hpp"
|
#include "Adapters/IOAdapterSeeking.hpp"
|
||||||
|
#include "Adapters/IOAdapterMemoryView.hpp"
|
||||||
|
|
||||||
#include "IIOWaitableTickLimiter.hpp"
|
#include "IIOWaitableTickLimiter.hpp"
|
||||||
#include "IIOWaitableIOTimer.hpp"
|
#include "IIOWaitableIOTimer.hpp"
|
||||||
|
58
Source/IO/Adapters/AuIOAdapterMemoryView.cpp
Normal file
58
Source/IO/Adapters/AuIOAdapterMemoryView.cpp
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
13
Source/IO/Adapters/AuIOAdapterMemoryView.hpp
Normal file
13
Source/IO/Adapters/AuIOAdapterMemoryView.hpp
Normal 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
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user