Skip to content

Commit

Permalink
Added buffer cursor util functions
Browse files Browse the repository at this point in the history
  • Loading branch information
RobbeBryssinck committed Jan 14, 2022
1 parent bfd3b9e commit 8d4dec4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Code/core/include/Buffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ namespace TiltedPhoques
[[nodiscard]] size_t GetBytePosition() const;
[[nodiscard]] size_t GetBitPosition() const;

[[nodiscard]] Buffer* GetBuffer() const noexcept;
[[nodiscard]] uint8_t* GetDataAtPosition() const noexcept;

protected:

size_t m_bitPosition;
Expand Down
10 changes: 10 additions & 0 deletions Code/core/src/Buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,16 @@ namespace TiltedPhoques
return bitPosition / 8;
}

Buffer* Buffer::Cursor::GetBuffer() const noexcept
{
return m_pBuffer;
}

uint8_t* Buffer::Cursor::GetDataAtPosition() const noexcept
{
return m_pBuffer->GetWriteData() + GetBytePosition();
}

Buffer::Reader::Reader(Buffer* apBuffer)
: Cursor(apBuffer)
{
Expand Down

0 comments on commit 8d4dec4

Please sign in to comment.