microfmt
Zero-allocation C++ formatting for constrained environments
Loading...
Searching...
No Matches
Classes | Public Member Functions | Static Public Member Functions | List of all members
microfmt::elf_image_enumerator_ref Class Reference

Type-erased, two-word handle to an ELF image enumerator. More...

#include <elf_enumerator.hpp>

Classes

struct  vtable
 Virtual table of image enumeration operations. More...
 

Public Member Functions

constexpr elf_image_enumerator_ref () noexcept=default
 Constructs an empty (invalid) handle.
 
template<typename Tag , typename Context , typename Traits = elf_image_enumerator_traits<Tag>, std::enable_if_t< std::is_convertible_v< const Context *, const typename Traits::context_type * >, int > = 0>
constexpr elf_image_enumerator_ref (Tag, const Context &ctx RELOCO_LIFETIMEBOUND RELOCO_LIFETIME_CAPTURE_BY_THIS) noexcept
 Constructs a handle from a tag and its traits context.
 
template<typename Tag , typename Context , std::enable_if_t<!std::is_lvalue_reference_v< Context >, int > = 0>
constexpr elf_image_enumerator_ref (Tag, Context &&)=delete
 
bool enumerate (span< elf_image_info > out_buffer, size_t &out_count) const noexcept
 Fills a caller-provided buffer with registered ELF images.
 
bool find_by_pc (uintptr_t pc, elf_image_info &out_info) const noexcept
 Locates the ELF image containing the given PC address.
 
constexpr operator bool () const noexcept
 Reports whether the handle is bound to an enumerator.
 

Static Public Member Functions

template<typename Tag , typename Context , typename Traits = elf_image_enumerator_traits<Tag>>
static constexpr elf_image_enumerator_ref make (const Context &ctx RELOCO_LIFETIMEBOUND) noexcept
 
template<typename Tag , typename Context , std::enable_if_t<!std::is_lvalue_reference_v< Context >, int > = 0>
static elf_image_enumerator_ref make (Context &&)=delete
 

Detailed Description

Type-erased, two-word handle to an ELF image enumerator.

Binds a traits-selected provider context with zero allocation.

Constructor & Destructor Documentation

◆ elf_image_enumerator_ref() [1/3]

constexpr microfmt::elf_image_enumerator_ref::elf_image_enumerator_ref ( )
constexprdefaultnoexcept

Constructs an empty (invalid) handle.

◆ elf_image_enumerator_ref() [2/3]

template<typename Tag , typename Context , typename Traits = elf_image_enumerator_traits<Tag>, std::enable_if_t< std::is_convertible_v< const Context *, const typename Traits::context_type * >, int > = 0>
constexpr microfmt::elf_image_enumerator_ref::elf_image_enumerator_ref ( Tag  ,
const Context &ctx RELOCO_LIFETIMEBOUND  RELOCO_LIFETIME_CAPTURE_BY_THIS 
)
inlineconstexprnoexcept

Constructs a handle from a tag and its traits context.

Template Parameters
TagImplementation tag type.
ContextConcrete context type exposing enumerate and find_by_pc.
Parameters
ctxContext object performing the enumeration.

◆ elf_image_enumerator_ref() [3/3]

template<typename Tag , typename Context , std::enable_if_t<!std::is_lvalue_reference_v< Context >, int > = 0>
constexpr microfmt::elf_image_enumerator_ref::elf_image_enumerator_ref ( Tag  ,
Context &&   
)
constexprdelete

Member Function Documentation

◆ enumerate()

bool microfmt::elf_image_enumerator_ref::enumerate ( span< elf_image_info >  out_buffer,
size_t &  out_count 
) const
inlinenoexcept

Fills a caller-provided buffer with registered ELF images.

Parameters
out_bufferDestination buffer for image records.
out_countReceives the number of images stored.
Returns
true on success, false if the handle is empty.

◆ find_by_pc()

bool microfmt::elf_image_enumerator_ref::find_by_pc ( uintptr_t  pc,
elf_image_info &  out_info 
) const
inlinenoexcept

Locates the ELF image containing the given PC address.

Parameters
pcCode address to look up.
out_infoReceives the owning image record.
Returns
true when an owning image was found.

◆ make() [1/2]

template<typename Tag , typename Context , typename Traits = elf_image_enumerator_traits<Tag>>
static constexpr elf_image_enumerator_ref microfmt::elf_image_enumerator_ref::make ( const Context &ctx  RELOCO_LIFETIMEBOUND)
inlinestaticconstexprnoexcept

◆ make() [2/2]

template<typename Tag , typename Context , std::enable_if_t<!std::is_lvalue_reference_v< Context >, int > = 0>
static elf_image_enumerator_ref microfmt::elf_image_enumerator_ref::make ( Context &&  )
staticdelete

◆ operator bool()

constexpr microfmt::elf_image_enumerator_ref::operator bool ( ) const
inlineexplicitconstexprnoexcept

Reports whether the handle is bound to an enumerator.

Returns
true when the handle is valid.

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