tagval 0.2.0
Modern C++23 header-only library of tagged values (open/closed enumerations with metadata)
Loading...
Searching...
No Matches
tagval::detail::HandleBase< Id, Derived > Class Template Reference

CRTP handle. More...

#include <base.hpp>

+ Inheritance diagram for tagval::detail::HandleBase< Id, Derived >:
+ Collaboration diagram for tagval::detail::HandleBase< Id, Derived >:

Public Member Functions

constexpr HandleBase () noexcept=default
 Default-constructed handle: empty(), bool() == false.
 
std::string_view code () const noexcept
 
std::string_view label () const noexcept
 
std::optional< comms::Icon > icon () const noexcept
 
std::optional< comms::Color > color () const noexcept
 
bool empty () const noexcept
 
 operator bool () const noexcept
 

Static Public Member Functions

static constexpr std::string_view kind_id () noexcept
 
static constexpr TagValDescriptor descriptor () noexcept
 

Protected Member Functions

constexpr HandleBase (const TagValMetadata *m) noexcept
 

Static Protected Member Functions

static Derived make_handle (const TagValMetadata *m) noexcept
 Build a Derived handle from a stable metadata pointer.
 
static const TagValMetadatafind_in (const std::span< const TagValMetadata > values, const std::string_view code) noexcept
 Linear search a metadata range by code.
 
static Derived of_impl (const std::span< const TagValMetadata > values, const std::string_view code)
 
static std::expected< Derived, ParseErrortry_of_impl (const std::span< const TagValMetadata > values, const std::string_view code) noexcept
 

Protected Attributes

const TagValMetadatameta_ = nullptr
 

Friends

constexpr bool operator== (const HandleBase &a, const HandleBase &b) noexcept
 
constexpr std::strong_ordering operator<=> (const HandleBase &a, const HandleBase &b) noexcept
 

Detailed Description

template<comms::FixedString Id, typename Derived>
class tagval::detail::HandleBase< Id, Derived >

CRTP handle.

Both ClosedEnded and OpenEnded derive from this; the concrete user type then derives from one of those.

Constructor & Destructor Documentation

◆ HandleBase() [1/2]

template<comms::FixedString Id, typename Derived >
constexpr tagval::detail::HandleBase< Id, Derived >::HandleBase ( )
constexprdefaultnoexcept

Default-constructed handle: empty(), bool() == false.

Useful as a not-yet-set sentinel.

◆ HandleBase() [2/2]

template<comms::FixedString Id, typename Derived >
constexpr tagval::detail::HandleBase< Id, Derived >::HandleBase ( const TagValMetadata m)
inlineexplicitconstexprprotectednoexcept

Member Function Documentation

◆ code()

template<comms::FixedString Id, typename Derived >
std::string_view tagval::detail::HandleBase< Id, Derived >::code ( ) const
inlinenoexcept

◆ label()

template<comms::FixedString Id, typename Derived >
std::string_view tagval::detail::HandleBase< Id, Derived >::label ( ) const
inlinenoexcept

◆ icon()

template<comms::FixedString Id, typename Derived >
std::optional< comms::Icon > tagval::detail::HandleBase< Id, Derived >::icon ( ) const
inlinenoexcept

◆ color()

template<comms::FixedString Id, typename Derived >
std::optional< comms::Color > tagval::detail::HandleBase< Id, Derived >::color ( ) const
inlinenoexcept

◆ empty()

template<comms::FixedString Id, typename Derived >
bool tagval::detail::HandleBase< Id, Derived >::empty ( ) const
inlinenoexcept

◆ operator bool()

template<comms::FixedString Id, typename Derived >
tagval::detail::HandleBase< Id, Derived >::operator bool ( ) const
inlineexplicitnoexcept

◆ kind_id()

template<comms::FixedString Id, typename Derived >
static constexpr std::string_view tagval::detail::HandleBase< Id, Derived >::kind_id ( )
inlinestaticconstexprnoexcept

◆ descriptor()

template<comms::FixedString Id, typename Derived >
static constexpr TagValDescriptor tagval::detail::HandleBase< Id, Derived >::descriptor ( )
inlinestaticconstexprnoexcept

◆ make_handle()

template<comms::FixedString Id, typename Derived >
static Derived tagval::detail::HandleBase< Id, Derived >::make_handle ( const TagValMetadata m)
inlinestaticprotectednoexcept

Build a Derived handle from a stable metadata pointer.

◆ find_in()

template<comms::FixedString Id, typename Derived >
static const TagValMetadata * tagval::detail::HandleBase< Id, Derived >::find_in ( const std::span< const TagValMetadata values,
const std::string_view  code 
)
inlinestaticprotectednoexcept

Linear search a metadata range by code.

◆ of_impl()

template<comms::FixedString Id, typename Derived >
static Derived tagval::detail::HandleBase< Id, Derived >::of_impl ( const std::span< const TagValMetadata values,
const std::string_view  code 
)
inlinestaticprotected

◆ try_of_impl()

template<comms::FixedString Id, typename Derived >
static std::expected< Derived, ParseError > tagval::detail::HandleBase< Id, Derived >::try_of_impl ( const std::span< const TagValMetadata values,
const std::string_view  code 
)
inlinestaticprotectednoexcept

Friends And Related Symbol Documentation

◆ operator==

template<comms::FixedString Id, typename Derived >
constexpr bool operator== ( const HandleBase< Id, Derived > &  a,
const HandleBase< Id, Derived > &  b 
)
friend

◆ operator<=>

template<comms::FixedString Id, typename Derived >
constexpr std::strong_ordering operator<=> ( const HandleBase< Id, Derived > &  a,
const HandleBase< Id, Derived > &  b 
)
friend

Member Data Documentation

◆ meta_

template<comms::FixedString Id, typename Derived >
const TagValMetadata* tagval::detail::HandleBase< Id, Derived >::meta_ = nullptr
protected

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