|
tagval 0.2.0
Modern C++23 header-only library of tagged values (open/closed enumerations with metadata)
|
CRTP base for tag-value kinds whose values are fixed at compile time. More...
#include <closed_ended.hpp>
Inheritance diagram for tagval::ClosedEnded< Id, Derived >:
Collaboration diagram for tagval::ClosedEnded< Id, Derived >:Static Public Member Functions | |
| template<typename E > | |
| static const Derived & | value () noexcept |
| Compile-time canonical handle for an entry. | |
| static std::span< const TagValMetadata > | all_values () noexcept |
| All values for this kind, in declaration order. | |
| static Derived | of (std::string_view code) |
| Look up a value by code. Throws UnknownCodeError on miss. | |
| static std::expected< Derived, ParseError > | try_of (std::string_view code) noexcept |
| Look up a value by code. Returns ParseError on miss. | |
Static Public Member Functions inherited from tagval::detail::HandleBase< Id, Derived > | |
| static constexpr std::string_view | kind_id () noexcept |
| static constexpr TagValDescriptor | descriptor () noexcept |
Additional Inherited Members | |
Public Member Functions inherited from tagval::detail::HandleBase< Id, Derived > | |
| 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 | |
Protected Member Functions inherited from tagval::detail::HandleBase< Id, Derived > | |
| constexpr | HandleBase (const TagValMetadata *m) noexcept |
Static Protected Member Functions inherited from tagval::detail::HandleBase< Id, Derived > | |
| static Derived | make_handle (const TagValMetadata *m) noexcept |
| Build a Derived handle from a stable metadata pointer. | |
| static const TagValMetadata * | find_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, ParseError > | try_of_impl (const std::span< const TagValMetadata > values, const std::string_view code) noexcept |
Protected Attributes inherited from tagval::detail::HandleBase< Id, Derived > | |
| const TagValMetadata * | meta_ = nullptr |
CRTP base for tag-value kinds whose values are fixed at compile time.
class Status : public tagval::ClosedEnded<"status", Status> {
public:
using base_t = tagval::ClosedEnded<"status", Status>;
using base_t::base_t;
TAGVAL_ENTRY(Status, Active, active);
TAGVAL_ENTRY(Status, Inactive, inactive, "Inactive");
using values_t = tagval::Values<Active, Inactive>;
};
|
inlinestaticnoexcept |
Compile-time canonical handle for an entry.
Static-asserts the entry is listed in Derived::values_t. The handle's address is the address of the matching record inside all_values(), so it compares equal to the result of of(E::code).
|
inlinestaticnoexcept |
All values for this kind, in declaration order.
Span points into a constexpr static array — valid for the program's lifetime.
|
inlinestatic |
Look up a value by code. Throws UnknownCodeError on miss.
|
inlinestaticnoexcept |
Look up a value by code. Returns ParseError on miss.