18#include <commons/fixed_string.hpp>
36template <comms::FixedString Id,
typename Derived>
48 [[nodiscard]]
static const Derived&
value() noexcept {
50 "tagval: kind type is missing `using values_t = tagval::Values<...>;`");
51 static_assert(Derived::values_t::template contains<E>,
52 "Entry type is not listed in Derived::values_t");
59 [[nodiscard]]
static std::span<const TagValMetadata>
all_values() noexcept {
61 "tagval: kind type is missing `using values_t = tagval::Values<...>;`");
62 static constexpr auto arr = values_metadata_array<typename Derived::values_t>();
63 return std::span<const TagValMetadata>{arr};
67 [[nodiscard]]
static Derived
of(std::string_view
code) {
72 [[nodiscard]]
static std::expected<Derived, ParseError>
try_of(std::string_view
code)
noexcept {
CRTP HandleBase used by ClosedEnded and OpenEnded.
CRTP base for tag-value kinds whose values are fixed at compile time.
Definition closed_ended.hpp:37
static std::span< const TagValMetadata > all_values() noexcept
All values for this kind, in declaration order.
Definition closed_ended.hpp:59
static Derived of(std::string_view code)
Look up a value by code. Throws UnknownCodeError on miss.
Definition closed_ended.hpp:67
static const Derived & value() noexcept
Compile-time canonical handle for an entry.
Definition closed_ended.hpp:48
static std::expected< Derived, ParseError > try_of(std::string_view code) noexcept
Look up a value by code. Returns ParseError on miss.
Definition closed_ended.hpp:72
CRTP handle.
Definition base.hpp:49
static Derived of_impl(const std::span< const TagValMetadata > values, const std::string_view code)
Definition base.hpp:126
static const TagValMetadata * find_in(const std::span< const TagValMetadata > values, const std::string_view code) noexcept
Linear search a metadata range by code.
Definition base.hpp:116
static std::expected< Derived, ParseError > try_of_impl(const std::span< const TagValMetadata > values, const std::string_view code) noexcept
Definition base.hpp:141
static Derived make_handle(const TagValMetadata *m) noexcept
Build a Derived handle from a stable metadata pointer.
Definition base.hpp:109
std::string_view code() const noexcept
Definition base.hpp:55
Definition open_ended.hpp:42
Compile-time Entry NTTP and the runtime-view TagValMetadata struct.
OpenEnded base — same in-class declaration shape as ClosedEnded (TAGVAL_ENTRY + using values_t = tagv...
Compile-time list of Entry types for ClosedEnded kinds.