5#include <Common/assertion.h>
6#include <Common/io_exceptions.h>
29 void read(std::size_t numBytes, std::byte* out_bytes)
override;
30 void readString(std::string* out_string,
char delimiter)
override;
31 void seekGet(std::size_t pos)
override;
32 std::optional<std::size_t>
tellGet()
override;
33 operator bool ()
const override;
34 std::size_t
readSome(std::size_t numBytes, std::byte* out_bytes)
override;
64 bool canRead(std::size_t numBytes)
const;
73 std::unique_ptr<std::byte[]> m_byteBuffer;
74 std::size_t m_numBytes;
75 std::size_t m_readHead;
94 m_readHead += numBytes;
98 throw IOException(std::format(
99 "Attempt to read bytes in [{}, {}) which overflows [{}, {}).",
100 m_readHead, m_readHead + numBytes, m_readHead,
numBufferBytes()));
106 PH_ASSERT(out_string);
112 const char*
const charBufferView =
charBuffer();
114 const std::size_t beginIdx = m_readHead;
117 if(charBufferView[m_readHead] == delimiter)
125 PH_ASSERT_LT(beginIdx, m_readHead);
130 const auto numChars = m_readHead <
numBufferBytes() ? m_readHead - 1 - beginIdx : m_readHead - beginIdx;
132 &(charBufferView[beginIdx]),
137 throw IOException(std::format(
138 "Attempt to read a string with delimiter {} from buffer range [{}, {}).",
151 throw IOException(std::format(
152 "Attempt to seek to read position {} which overflows [0, {}).",
164 PH_ASSERT(out_bytes);
168 read(numBytes, out_bytes);
176 PH_ASSERT_LT(numRemainingBytes, numBytes);
177 read(numRemainingBytes, out_bytes);
178 return numRemainingBytes;
202inline ByteBufferInputStream::operator bool ()
const
210 static_assert(std::is_trivially_copyable_v<T>);
213 read(
sizeof(T),
reinterpret_cast<std::byte*
>(out_data));
223 PH_ASSERT(m_byteBuffer);
224 return m_byteBuffer.get();
229 PH_ASSERT(m_byteBuffer);
230 return m_byteBuffer.get();
240 return reinterpret_cast<const char*
>(
byteBuffer());
245 return reinterpret_cast<unsigned char*
>(
byteBuffer());
250 return reinterpret_cast<const unsigned char*
>(
byteBuffer());
The root for all renderer implementations.
Definition EEngineProject.h:6