diff options
author | bunnei <bunneidev@gmail.com> | 2020-10-27 07:02:42 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-27 07:02:42 +0100 |
commit | d33399e1f46a10490b586196c6d0db0f04be4206 (patch) | |
tree | 8b2e1d98bf832049936ab931fc3a120e70bc36c2 /src/common/stream.h | |
parent | Merge pull request #4832 from bunnei/cpu-manager-microprofile-fix (diff) | |
parent | video_core: NVDEC Implementation (diff) | |
download | yuzu-d33399e1f46a10490b586196c6d0db0f04be4206.tar yuzu-d33399e1f46a10490b586196c6d0db0f04be4206.tar.gz yuzu-d33399e1f46a10490b586196c6d0db0f04be4206.tar.bz2 yuzu-d33399e1f46a10490b586196c6d0db0f04be4206.tar.lz yuzu-d33399e1f46a10490b586196c6d0db0f04be4206.tar.xz yuzu-d33399e1f46a10490b586196c6d0db0f04be4206.tar.zst yuzu-d33399e1f46a10490b586196c6d0db0f04be4206.zip |
Diffstat (limited to '')
-rw-r--r-- | src/common/stream.h | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/src/common/stream.h b/src/common/stream.h new file mode 100644 index 000000000..2585c16af --- /dev/null +++ b/src/common/stream.h @@ -0,0 +1,50 @@ +// Copyright 2020 yuzu Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +#include <vector> +#include "common/common_types.h" + +namespace Common { + +enum class SeekOrigin { + SetOrigin, + FromCurrentPos, + FromEnd, +}; + +class Stream { +public: + /// Stream creates a bitstream and provides common functionality on the stream. + explicit Stream(); + ~Stream(); + + /// Reposition bitstream "cursor" to the specified offset from origin + void Seek(s32 offset, SeekOrigin origin); + + /// Reads next byte in the stream buffer and increments position + u8 ReadByte(); + + /// Writes byte at current position + void WriteByte(u8 byte); + + std::size_t GetPosition() const { + return position; + } + + std::vector<u8>& GetBuffer() { + return buffer; + } + + const std::vector<u8>& GetBuffer() const { + return buffer; + } + +private: + std::vector<u8> buffer; + std::size_t position{0}; +}; + +} // namespace Common |