Reece
44108a322e
[+] TTYConsole::GetPaddingTopOfLog,GetPaddingHeadOfLog,GetPaddingTopOfLog [+ set variants] [+] IO::IOYield() [+] IO::IAsyncTransaction::Failed,GetOSErrorCode() [+] IByteBufferStreamPair [+] IIOBufferedInterceptor [+] IIOBufferedProcessor [+] IIOEventListener [+] IIOPipeEventListener [+] IIOProcessorEventListener [+] IIOProcessorManualInvoker [+] IIOWaitableIOLoopSource [+] IIOWaitableIOTimer [+] IIOWaitableItem [+] IIOWaitableTickLimiter [+] IOAdapterAsyncStream [+] IOAdapterByteBuffer [+] IOAdapterCompression [+] IOAdapterSeeking [*] Cleanup CpuInfo.Linux.cpp [*] Fixup async threadpool some more [*] LSTimer.NT.cpp updates timer object on tick state update, akin to Linux
84 lines
2.2 KiB
C++
84 lines
2.2 KiB
C++
/***
|
|
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
|
|
|
File: ByteBufferStreamPair.cpp
|
|
Date: 2022-6-6
|
|
Author: Reece
|
|
***/
|
|
#include <Source/RuntimeInternal.hpp>
|
|
#include <Aurora/IO/IOExperimental.hpp>
|
|
#include "ByteBufferStreamPair.hpp"
|
|
|
|
namespace Aurora::IO
|
|
{
|
|
ByteBufferStreamPair::ByteBufferStreamPair(const AuSPtr<Memory::ByteBuffer> &buffer) :
|
|
buffer(buffer),
|
|
reader(buffer),
|
|
writer(buffer),
|
|
seeker(buffer)
|
|
{
|
|
|
|
}
|
|
|
|
AuSPtr<IStreamReader> ByteBufferStreamPair::ToStreamReader()
|
|
{
|
|
return AuSPtr<IStreamReader>(AuSharedFromThis(), AuStaticCast<IStreamReader>(&this->reader));
|
|
}
|
|
|
|
AuSPtr<ISeekingReader> ByteBufferStreamPair::ToSeekingReader()
|
|
{
|
|
if (this->buffer->flagCircular)
|
|
{
|
|
SysPushErrorIO("ring buffer must not be seekable");
|
|
return {};
|
|
}
|
|
|
|
return AuSPtr<ISeekingReader>(AuSharedFromThis(), AuStaticCast<ISeekingReader>(&this->seeker));
|
|
}
|
|
|
|
AuSPtr<IStreamWriter> ByteBufferStreamPair::ToStreamWriter()
|
|
{
|
|
return AuSPtr<IStreamWriter>(AuSharedFromThis(), AuStaticCast<IStreamWriter>(&this->writer));
|
|
}
|
|
|
|
AuSPtr<Memory::ByteBuffer> ByteBufferStreamPair::ToByteBuffer()
|
|
{
|
|
return this->buffer;
|
|
}
|
|
|
|
AUKN_SYM AuSPtr<IByteBufferStreamPair> NewByteBufferPair()
|
|
{
|
|
auto scalable = AuMakeShared<AuByteBuffer>();
|
|
if (!scalable)
|
|
{
|
|
SysPushErrorMem();
|
|
return {};
|
|
}
|
|
|
|
return AuMakeShared<ByteBufferStreamPair>(scalable);
|
|
}
|
|
|
|
AUKN_SYM AuSPtr<IByteBufferStreamPair> NewByteBufferPairEx(AuUInt length, bool permitResize)
|
|
{
|
|
auto buffer = AuMakeShared<AuByteBuffer>(length, false, permitResize);
|
|
if (!buffer)
|
|
{
|
|
SysPushErrorMem();
|
|
return {};
|
|
}
|
|
|
|
return AuMakeShared<ByteBufferStreamPair>(buffer);
|
|
}
|
|
|
|
AUKN_SYM AuSPtr<IByteBufferStreamPair> NewRingByteBuffer(AuUInt length)
|
|
{
|
|
auto buffer = AuMakeShared<AuByteBuffer>(length, false, false);
|
|
if (!buffer)
|
|
{
|
|
SysPushErrorMem();
|
|
return {};
|
|
}
|
|
|
|
return AuMakeShared<ByteBufferStreamPair>(buffer);
|
|
}
|
|
} |