diff options
Diffstat (limited to 'src/zencore')
| -rw-r--r-- | src/zencore/include/zencore/stream.h | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/zencore/include/zencore/stream.h b/src/zencore/include/zencore/stream.h index a28290041..fae393666 100644 --- a/src/zencore/include/zencore/stream.h +++ b/src/zencore/include/zencore/stream.h @@ -70,14 +70,25 @@ public: inline void Read(void* DataPtr, size_t ByteCount) { + ZEN_ASSERT(m_Offset + ByteCount <= m_BufferSize); memcpy(DataPtr, m_BufferBase + m_Offset, ByteCount); m_Offset += ByteCount; } + inline MemoryView GetView(size_t ByteCount) const + { + ZEN_ASSERT(m_Offset + ByteCount <= m_BufferSize); + return MemoryView((const void*)(m_BufferBase + m_Offset), (const void*)(m_BufferBase + m_Offset + ByteCount)); + } inline uint64_t Size() const { return m_BufferSize; } inline uint64_t GetSize() const { return Size(); } inline uint64_t CurrentOffset() const { return m_Offset; } - inline void Skip(size_t ByteCount) { m_Offset += ByteCount; }; + inline uint64_t Remaining() const { return m_BufferSize - m_Offset; } + inline void Skip(size_t ByteCount) + { + ZEN_ASSERT(m_Offset + ByteCount <= m_BufferSize); + m_Offset += ByteCount; + }; protected: const uint8_t* m_BufferBase; |