2022-06-11 23:01:27 +00:00
|
|
|
/***
|
|
|
|
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
|
|
|
|
2022-12-17 20:14:19 +00:00
|
|
|
File: AuIOAdapterByteBuffer.cpp
|
2022-06-11 23:01:27 +00:00
|
|
|
Date: 2022-6-6
|
|
|
|
Author: Reece
|
|
|
|
***/
|
|
|
|
#include <Source/RuntimeInternal.hpp>
|
|
|
|
#include <Aurora/IO/IOExperimental.hpp>
|
2022-12-17 20:14:19 +00:00
|
|
|
#include "AuIOAdapterByteBuffer.hpp"
|
2022-06-11 23:01:27 +00:00
|
|
|
|
2023-09-23 15:40:13 +00:00
|
|
|
namespace Aurora::IO::Adapters
|
2022-06-11 23:01:27 +00:00
|
|
|
{
|
2022-12-17 20:14:19 +00:00
|
|
|
AUKN_SYM AuSPtr<IStreamReader> NewByteBufferReadAdapter(const AuSPtr<Memory::ByteBuffer> &pBuffer)
|
2022-06-11 23:01:27 +00:00
|
|
|
{
|
2023-10-24 16:43:00 +00:00
|
|
|
SysCheckArgNotNull(pBuffer, {});
|
|
|
|
SysCheckRetExpNotNullMemory(AuMakeShared<Buffered::BlobReader>(pBuffer), {});
|
2022-06-11 23:01:27 +00:00
|
|
|
}
|
|
|
|
|
2024-03-07 06:49:23 +00:00
|
|
|
AUKN_SYM AuSPtr<ISeekingReader> NewByteBufferLinearReadSeekableAdapter(const AuSPtr<Memory::ByteBuffer> &pBuffer)
|
2022-06-11 23:01:27 +00:00
|
|
|
{
|
2023-10-24 16:43:00 +00:00
|
|
|
SysCheckArgNotNull(pBuffer, {});
|
2022-12-17 20:14:19 +00:00
|
|
|
if (pBuffer->flagCircular)
|
2022-06-11 23:01:27 +00:00
|
|
|
{
|
|
|
|
SysPushErrorIO("Seekable buffer must not be circular");
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
|
2023-10-24 16:43:00 +00:00
|
|
|
SysCheckRetExpNotNullMemory(AuMakeShared<Buffered::BlobSeekableReader>(pBuffer), {});
|
2022-06-11 23:01:27 +00:00
|
|
|
}
|
|
|
|
|
2024-03-07 06:49:23 +00:00
|
|
|
AUKN_SYM AuSPtr<ISeekingWriter> NewByteBufferLinearWriteSeekableAdapter(const AuSPtr<Memory::ByteBuffer> &pBuffer)
|
|
|
|
{
|
|
|
|
SysCheckArgNotNull(pBuffer, {});
|
|
|
|
if (pBuffer->flagCircular)
|
|
|
|
{
|
|
|
|
SysPushErrorIO("Seekable buffer must not be circular");
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
|
|
|
|
SysCheckRetExpNotNullMemory(AuMakeShared<Buffered::BlobSeekableWriter>(pBuffer), {});
|
|
|
|
}
|
|
|
|
|
2022-12-17 20:14:19 +00:00
|
|
|
AUKN_SYM AuSPtr<IStreamWriter> NewByteBufferWriteAdapter(const AuSPtr<Memory::ByteBuffer> &pBuffer)
|
2022-06-11 23:01:27 +00:00
|
|
|
{
|
2023-10-24 16:43:00 +00:00
|
|
|
SysCheckArgNotNull(pBuffer, {});
|
|
|
|
SysCheckRetExpNotNullMemory(AuMakeShared<Buffered::BlobWriter>(pBuffer), {});
|
2022-06-11 23:01:27 +00:00
|
|
|
}
|
|
|
|
}
|