From 8e1eb4f5dc052496295f60d5c9f28c5b6d347ae7 Mon Sep 17 00:00:00 2001 From: kobalicek Date: Fri, 14 Feb 2020 00:08:47 +0100 Subject: [PATCH] Added begin()/end() + operator[] to CodeBuffer --- src/asmjit/core/codeholder.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/asmjit/core/codeholder.h b/src/asmjit/core/codeholder.h index 3275fdb..8bbe058 100644 --- a/src/asmjit/core/codeholder.h +++ b/src/asmjit/core/codeholder.h @@ -115,6 +115,21 @@ struct CodeBuffer { kFlagIsFixed = 0x00000002u }; + //! \name Overloaded Operators + //! \{ + + inline uint8_t& operator[](size_t index) noexcept { + ASMJIT_ASSERT(index < _size); + return _data[index]; + } + + inline const uint8_t& operator[](size_t index) const noexcept { + ASMJIT_ASSERT(index < _size); + return _data[index]; + } + + //! \} + //! \name Accessors //! \{ @@ -133,6 +148,17 @@ struct CodeBuffer { inline size_t capacity() const noexcept { return _capacity; } //! \} + + //! \name Iterators + //! \{ + + inline uint8_t* begin() noexcept { return _data; } + inline const uint8_t* begin() const noexcept { return _data; } + + inline uint8_t* end() noexcept { return _data + _size; } + inline const uint8_t* end() const noexcept { return _data + _size; } + + //! \} }; // ============================================================================