|
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 partly compile-time (Derived::values_t) and partly contributed by plugins via TAGVAL_EXTERN_ENTRY. More...
#include <open_ended.hpp>
Inheritance diagram for tagval::OpenEnded< Id, Derived >:
Collaboration diagram for tagval::OpenEnded< Id, Derived >:Static Public Member Functions | |
| template<typename E > | |
| static const Derived & | value () noexcept |
| Canonical handle for an entry. | |
| static auto | all_values () noexcept |
Range of TagValMetadata covering compile-time values_t entries (seeded lazily on first call) plus extern entries currently registered in OpenEndedRegistry<Derived>. | |
| 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 partly compile-time (Derived::values_t) and partly contributed by plugins via TAGVAL_EXTERN_ENTRY.
class Kind : public tagval::OpenEnded<"kind", Kind> {
public:
using base_t = tagval::OpenEnded<"kind", Kind>;
using base_t::base_t;
TAGVAL_ENTRY(Kind, Phone, phone, "Phone")
TAGVAL_ENTRY(Kind, Tablet, tablet, "Tablet")
using values_t = tagval::Values<Phone, Tablet>;
};
namespace vendor {
TAGVAL_EXTERN_ENTRY(::Kind, SmartWatch, smart_watch, "Smart Watch");
}
|
inlinestaticnoexcept |
Canonical handle for an entry.
Looked up via OpenEndedRegistry, so the handle's address agrees with of(E::code) whether E came from values_t or from a TAGVAL_EXTERN_ENTRY in another translation unit.
|
inlinestaticnoexcept |
Range of TagValMetadata covering compile-time values_t entries (seeded lazily on first call) plus extern entries currently registered in OpenEndedRegistry<Derived>.
Each element is a reference to the pinned metadata storage and remains 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.