diff options
Diffstat (limited to 'zencore/include')
| -rw-r--r-- | zencore/include/zencore/memory.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/zencore/include/zencore/memory.h b/zencore/include/zencore/memory.h index ec945c07c..b060006b0 100644 --- a/zencore/include/zencore/memory.h +++ b/zencore/include/zencore/memory.h @@ -125,6 +125,21 @@ struct MutableMemoryView /** Modifies the view to be the given number of bytes from the left. */ constexpr inline void LeftInline(uint64_t InSize) { m_DataEnd = std::min(m_DataEnd, m_Data + InSize); } + /** Modifies the view to be the middle part by taking up to the given number of bytes from the given offset. */ + inline void MidInline(uint64_t InOffset, uint64_t InSize = ~uint64_t(0)) + { + RightChopInline(InOffset); + LeftInline(InSize); + } + + /** Returns the middle part of the view by taking up to the given number of bytes from the given position. */ + [[nodiscard]] inline MutableMemoryView Mid(uint64_t InOffset, uint64_t InSize = ~uint64_t(0)) const + { + MutableMemoryView View(*this); + View.MidInline(InOffset, InSize); + return View; + } + /** Returns the right-most part of the view by chopping the given number of bytes from the left. */ [[nodiscard]] inline MutableMemoryView RightChop(uint64_t InSize) const { |