Asylo
Public Member Functions | List of all members
asylo::primitives::Extent Class Reference

A extent object suitable for sharing address ranges between trusted and untrusted code. More...

#include <asylo/platform/primitives/extent.h>

Public Member Functions

constexpr Extent ()
 Initializes an empty extent. More...
 
constexpr Extent (void *data, size_t size)
 Initializes an extent with a void pointer. More...
 
template<typename T >
constexpr Extent (T *data)
 Initializes an extent with a pointer to a value. More...
 
template<typename T >
constexpr Extent (T *data, size_t count)
 Initializes an extent with a pointer to an array of count objects of type T. More...
 
size_t size () const
 
void * data ()
 
const void * data () const
 
bool empty () const
 A predicate for whether the extent is empty. More...
 
void CopyTo (char *out) const
 Copies the contents of the extent to out. More...
 
template<typename T >
T * As ()
 A size-aware reinterpret_cast for a mutable pointer. More...
 
template<typename T >
const T * As () const
 A size-aware reinterpret_cast for a constant pointer. More...
 

Detailed Description

A extent object suitable for sharing address ranges between trusted and untrusted code.

Constructor & Destructor Documentation

◆ Extent() [1/4]

constexpr asylo::primitives::Extent::Extent ( )
inline

Initializes an empty extent.

◆ Extent() [2/4]

constexpr asylo::primitives::Extent::Extent ( void *  data,
size_t  size 
)
inline

Initializes an extent with a void pointer.

Parameters
dataA pointer to the start of the extent of memory.
sizeThe number of bytes in the extent.

◆ Extent() [3/4]

template<typename T >
constexpr asylo::primitives::Extent::Extent ( T *  data)
inlineexplicit

Initializes an extent with a pointer to a value.

The number of bytes stored for the extent is sizeof(T).

Parameters
dataA pointer to an object of type T

◆ Extent() [4/4]

template<typename T >
constexpr asylo::primitives::Extent::Extent ( T *  data,
size_t  count 
)
inline

Initializes an extent with a pointer to an array of count objects of type T.

The size of the extent is count * sizeof(T).

Parameters
dataA pointer to the start of the array slice.
countThe number of elements included in the extent.

Member Function Documentation

◆ As() [1/2]

template<typename T >
T* asylo::primitives::Extent::As ( )
inline

A size-aware reinterpret_cast for a mutable pointer.

Returns
The extent data as a pointer to an object of type T, or nullptr if the extent is smaller than sizeof(T).

◆ As() [2/2]

template<typename T >
const T* asylo::primitives::Extent::As ( ) const
inline

A size-aware reinterpret_cast for a constant pointer.

Returns
The extent data as a constant pointer to an object of type T, or nullptr if the extent is smaller than sizeof(T).

◆ CopyTo()

void asylo::primitives::Extent::CopyTo ( char *  out) const
inline

Copies the contents of the extent to out.

The caller is responsible for allocating and freeing out correctly.

Parameters
outA pointer to a mutable array of bytes.

◆ data() [1/2]

void* asylo::primitives::Extent::data ( )
inline
Returns
The extent data as a pointer to an array of bytes.

◆ data() [2/2]

const void* asylo::primitives::Extent::data ( ) const
inline
Returns
The extent data as a constant pointer to an array of bytes.

◆ empty()

bool asylo::primitives::Extent::empty ( ) const
inline

A predicate for whether the extent is empty.

Returns
True if and only if either the extent data is null or the size is 0.

◆ size()

size_t asylo::primitives::Extent::size ( ) const
inline
Returns
The size of the extent in bytes.

The documentation for this class was generated from the following file: