xentara-plugin v1.2.1
The Xentara Plugin Framework
Loading...
Searching...
No Matches
xentara::memory::MemoryHandle< RawMemory > Class Referencefinal

A handle to raw data located in a memory resource. More...

#include <memory/RawMemoryHandle.hpp>

Public Member Functions

 MemoryHandle () noexcept=default
 Default constructor.
 
 MemoryHandle (const MemoryResource::BlockHandle &blockHandle, std::size_t offset) noexcept
 Creates a handle for an object in a memory block.
 
 MemoryHandle (std::nullptr_t) noexcept
 Conversion from an null pointer.
 
auto operator= (std::nullptr_t) noexcept -> MemoryHandle &
 Assignment operator for a null pointer.
 
auto operator== (std::nullptr_t) const -> bool
 Comparison operator with a null pointer.
 
 operator bool () const noexcept
 Checks for a null handle.
 
auto operator== (const MemoryHandle &) const -> bool=default
 Comparison operator.
 
auto operator<=> (const MemoryHandle &rhs) const -> std::partial_ordering
 Comparison operator.
 
auto memoryResource () const noexcept -> MemoryResource &
 Returns the memory resource that the data resides in.
 
constexpr auto blockHandle () const noexcept -> const MemoryResource::BlockHandle &
 Returns a a handle to the memory block that holds the data.
 
auto offset () const noexcept -> std::size_t
 Gets the offset of the data within the block data.
 
auto initializer () const -> Initializer< RawMemory >
 Creates an initializer for additional initialization.
 
auto operator++ () noexcept -> MemoryHandle &
 Increments the handle by a one byte.
 
auto operator++ (int) noexcept -> MemoryHandle
 Increments the handle by a one byte.
 
auto operator-- () noexcept -> MemoryHandle &
 Decrements the handle by a one byte.
 
auto operator-- (int) noexcept -> MemoryHandle
 Decrements the handle by a one byte.
 
auto operator+= (std::ptrdiff_t offset) noexcept -> MemoryHandle &
 Offsets the handle by a specific number of bytes.
 
auto operator-= (std::ptrdiff_t offset) noexcept -> MemoryHandle &
 Offsets the handle by a specific number of bytes.
 

Detailed Description

A handle to raw data located in a memory resource.

Constructor & Destructor Documentation

◆ MemoryHandle() [1/3]

xentara::memory::MemoryHandle< RawMemory >::MemoryHandle ( )
defaultnoexcept

Default constructor.

This constructor constructs a null handle

◆ MemoryHandle() [2/3]

xentara::memory::MemoryHandle< RawMemory >::MemoryHandle ( const MemoryResource::BlockHandle blockHandle,
std::size_t  offset 
)
noexcept

Creates a handle for an object in a memory block.

◆ MemoryHandle() [3/3]

xentara::memory::MemoryHandle< RawMemory >::MemoryHandle ( std::nullptr_t  )
noexcept

Conversion from an null pointer.

This constructor constructs a null handle

Member Function Documentation

◆ blockHandle()

constexpr auto xentara::memory::MemoryHandle< RawMemory >::blockHandle ( ) const -> const MemoryResource::BlockHandle &
constexprnoexcept

Returns a a handle to the memory block that holds the data.

◆ initializer()

auto xentara::memory::MemoryHandle< RawMemory >::initializer ( ) const -> Initializer<RawMemory>

Creates an initializer for additional initialization.

This function can be used to perform additional initialization of the memory from code locations where the original initializer returned when the block was allocated is not available.

Attention
Do not call this function if any read or write sentinels may exist for the block this handle belongs to, or if anyone may be holding any read handles or write handles to any data within that block.
Returns
An initializer for additional initialization of the handle's memory

◆ memoryResource()

auto xentara::memory::MemoryHandle< RawMemory >::memoryResource ( ) const -> MemoryResource &
noexcept

Returns the memory resource that the data resides in.

◆ offset()

auto xentara::memory::MemoryHandle< RawMemory >::offset ( ) const -> std::size_t
noexcept

Gets the offset of the data within the block data.

◆ operator bool()

xentara::memory::MemoryHandle< RawMemory >::operator bool ( ) const
explicitnoexcept

Checks for a null handle.

◆ operator++() [1/2]

auto xentara::memory::MemoryHandle< RawMemory >::operator++ ( ) -> MemoryHandle &
noexcept

Increments the handle by a one byte.

Attention
This can make the handle point to invalid data. It is your respoinsibility to ensure that the handle does not end up pointing outside of the block's memory.
Returns
Returns a reference to this object

◆ operator++() [2/2]

auto xentara::memory::MemoryHandle< RawMemory >::operator++ ( int  ) -> MemoryHandle
noexcept

Increments the handle by a one byte.

Attention
This can make the handle point to invalid data. It is your respoinsibility to ensure that the handle does not end up pointing outside of the block's memory.
Returns
The old value of the handle

◆ operator+=()

auto xentara::memory::MemoryHandle< RawMemory >::operator+= ( std::ptrdiff_t  offset) -> MemoryHandle &
noexcept

Offsets the handle by a specific number of bytes.

Attention
This can make the handle point to invalid data. It is your respoinsibility to ensure that the handle does not end up pointing outside of the block's memory.
Parameters
offsetThe number of bytes to move the handle
Returns
Returns a reference to this object

◆ operator--() [1/2]

auto xentara::memory::MemoryHandle< RawMemory >::operator-- ( ) -> MemoryHandle &
noexcept

Decrements the handle by a one byte.

Attention
This can make the handle point to invalid data. It is your respoinsibility to ensure that the handle does not end up pointing outside of the block's memory.
Returns
Returns a reference to this object

◆ operator--() [2/2]

auto xentara::memory::MemoryHandle< RawMemory >::operator-- ( int  ) -> MemoryHandle
noexcept

Decrements the handle by a one byte.

Attention
This can make the handle point to invalid data. It is your respoinsibility to ensure that the handle does not end up pointing outside of the block's memory.
Returns
The old value of the handle

◆ operator-=()

auto xentara::memory::MemoryHandle< RawMemory >::operator-= ( std::ptrdiff_t  offset) -> MemoryHandle &
noexcept

Offsets the handle by a specific number of bytes.

Attention
This can make the handle point to invalid data. It is your respoinsibility to ensure that the handle does not end up pointing outside of the block's memory.
Parameters
offsetThe negative number of bytes to move the handle
Returns
Returns a reference to this object

◆ operator<=>()

auto xentara::memory::MemoryHandle< RawMemory >::operator<=> ( const MemoryHandle< RawMemory > &  rhs) const -> std::partial_ordering

Comparison operator.

◆ operator=()

auto xentara::memory::MemoryHandle< RawMemory >::operator= ( std::nullptr_t  ) -> MemoryHandle &
noexcept

Assignment operator for a null pointer.

◆ operator==() [1/2]

auto xentara::memory::MemoryHandle< RawMemory >::operator== ( const MemoryHandle< RawMemory > &  ) const -> bool=default
default

Comparison operator.

◆ operator==() [2/2]

auto xentara::memory::MemoryHandle< RawMemory >::operator== ( std::nullptr_t  ) const -> bool

Comparison operator with a null pointer.