From 326ae8b4e7fe7e0cb3eb18c345d374c0177354a8 Mon Sep 17 00:00:00 2001 From: Stefan Boberg Date: Mon, 24 May 2021 15:24:46 +0200 Subject: Added Mid/MidInline to MutableMemoryView --- zencore/include/zencore/memory.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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 { -- cgit v1.2.3