/
redgpu
/
ezEngine
Обзор
Документация
Войти
/
redgpu
/
ezEngine
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
dev
Code/Engine/Foundation/IO/StreamWithStats.h
67 строк
2 KB
Jan Krassnigg
FMOD, Project Export and other fixes (#1350)
14 июл 2024, 23:06
Не верифицирован
14 июл 2024, 23:06
1c33687
Код
Авторство
О чём код?
#pragma once #include <Foundation/IO/Stream.h> /// \brief A stream reader that wraps another stream to track how many bytes are read from it. class EZ_FOUNDATION_DLL ezStreamReaderWithStats : public ezStreamReader { public: ezStreamReaderWithStats() = default; ezStreamReaderWithStats(ezStreamReader* pStream) : m_pStream(pStream) { } virtual ezUInt64 ReadBytes(void* pReadBuffer, ezUInt64 uiBytesToRead) override { const ezUInt64 uiRead = m_pStream->ReadBytes(pReadBuffer, uiBytesToRead); m_uiBytesRead += uiRead; return uiRead; } ezUInt64 SkipBytes(ezUInt64 uiBytesToSkip) override { const ezUInt64 uiSkipped = m_pStream->SkipBytes(uiBytesToSkip); m_uiBytesSkipped += uiSkipped; return uiSkipped; } /// the stream to forward all requests to ezStreamReader* m_pStream = nullptr; /// the number of bytes that were read from the wrapped stream /// public access so that users can read and modify this in case they want to reset the value at any time ezUInt64 m_uiBytesRead = 0; /// the number of bytes that were skipped from the wrapped stream ezUInt64 m_uiBytesSkipped = 0; }; /// \brief A stream writer that wraps another stream to track how many bytes are written to it. class EZ_FOUNDATION_DLL ezStreamWriterWithStats : public ezStreamWriter { public: ezStreamWriterWithStats() = default; ezStreamWriterWithStats(ezStreamWriter* pStream) : m_pStream(pStream) { } virtual ezResult WriteBytes(const void* pWriteBuffer, ezUInt64 uiBytesToWrite) override { m_uiBytesWritten += uiBytesToWrite; return m_pStream->WriteBytes(pWriteBuffer, uiBytesToWrite); } ezResult Flush() override { return m_pStream->Flush(); } /// the stream to forward all requests to ezStreamWriter* m_pStream = nullptr; /// the number of bytes that were written to the wrapped stream /// public access so that users can read and modify this in case they want to reset the value at any time ezUInt64 m_uiBytesWritten = 0; };