15#include "IInputStream.h"
16#include "IOutputStream.h"
17#include "AUI/Common/AQueue.h"
33 void write(
const char* src,
size_t size)
override;
34 size_t read(
char* dst,
size_t size)
override;
38 bool empty()
const noexcept {
39 return mQueue.empty();
43 static constexpr std::size_t FRAGMENT_CAPACITY = 0x10000;
46 std::array<std::uint8_t, FRAGMENT_CAPACITY> data;
47 std::size_t writerPos = 0;
48 std::size_t readerPos = 0;
51 std::size_t writerRemaining()
const noexcept {
return FRAGMENT_CAPACITY - writerPos; }
54 std::size_t readerRemaining()
const noexcept {
return writerPos - readerPos; }
56 void push(
const char*& src,
size_t& size) {
57 std::size_t sizeForCurrentFragment = glm::min(size, writerRemaining());
58 std::memcpy(data.data() + writerPos, src, sizeForCurrentFragment);
59 writerPos += sizeForCurrentFragment;
60 src += sizeForCurrentFragment;
61 size -= sizeForCurrentFragment;
An asynchronous buffer that converts an IInputStream to IOutputStream (and otherwise).
Definition: ADynamicPipe.h:29
A std::queue with AUI extensions.
Definition: AQueue.h:24
Definition: IOutputStream.h:20
virtual void write(const char *src, size_t size)=0
Writes exact size bytes to stream. Blocking (waiting for write all data) is allowed.