diff options
| author | Stefan Boberg <[email protected]> | 2021-05-24 15:24:46 +0200 |
|---|---|---|
| committer | Stefan Boberg <[email protected]> | 2021-05-24 15:24:46 +0200 |
| commit | 326ae8b4e7fe7e0cb3eb18c345d374c0177354a8 (patch) | |
| tree | 6637a3a23b8a381837cdc201d40fafdc67dfa1b3 /zencore/include | |
| parent | Added support for constructing CompositeBuffer from std::vector<SharedBuffer> (diff) | |
| download | zen-326ae8b4e7fe7e0cb3eb18c345d374c0177354a8.tar.xz zen-326ae8b4e7fe7e0cb3eb18c345d374c0177354a8.zip | |
Added Mid/MidInline to MutableMemoryView
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 { |