Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DataReader: Minor API changes #6460

Merged
merged 5 commits into from Mar 19, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 11 additions & 10 deletions Source/Core/VideoCommon/DataReader.h
Expand Up @@ -13,18 +13,19 @@
class DataReader
{
public:
__forceinline DataReader() : buffer(nullptr), end(nullptr) {}
__forceinline DataReader(u8* src, u8* _end) : buffer(src), end(_end) {}
__forceinline u8* GetPointer() { return buffer; }
__forceinline u8* operator=(u8* src)
DataReader() = default;
DataReader(u8* src, u8* end_) : buffer(src), end(end_) {}
u8* GetPointer() { return buffer; }
const u8* GetPointer() const { return buffer; }
DataReader& operator=(u8* src)
{
buffer = src;
return src;
return *this;
}

__forceinline size_t size() { return end - buffer; }
size_t size() const { return end - buffer; }
template <typename T, bool swapped = true>
__forceinline T Peek(int offset = 0)
__forceinline T Peek(int offset = 0) const
{
T data;
std::memcpy(&data, &buffer[offset], sizeof(T));
Expand Down Expand Up @@ -54,12 +55,12 @@ class DataReader
}

template <typename T = u8>
__forceinline void Skip(size_t data = 1)
void Skip(size_t data = 1)
{
buffer += sizeof(T) * data;
}

private:
u8* __restrict buffer;
u8* end;
u8* __restrict buffer = nullptr;
u8* end = nullptr;
};