5#include <portals/table_column.hpp>
7#include <boost/pfr/core.hpp>
26 decltype(
auto)
operator()(
const T &row)
const {
27 return boost::pfr::get<I>(row);
32template <
class T,
class Formatter, std::size_t... I>
33consteval bool aggregateFieldsFormattable(std::index_sequence<I...>) {
34 return (ColumnFormatter<T, AggregateFieldProjection<I, T>, Formatter> && ...);
37template <
class T,
class Formatter, std::size_t N, std::size_t... I>
38std::array<TableColumn<T>, N> makeAggregateColumns(std::array<TableColumnOptions, N> options, Formatter formatter,
39 std::index_sequence<I...>) {
40 return {
tableColumn<T>(std::move(options[I]), AggregateFieldProjection<I, T>{}, formatter)...};
54template <std::
size_t I,
class T,
class Formatter>
55 requires(std::is_aggregate_v<T> && I < boost::pfr::tuple_size_v<T> &&
72template <
class T, std::
size_t N,
class Formatter>
73 requires(std::is_aggregate_v<T> && N == boost::pfr::tuple_size_v<T> &&
74 detail::aggregateFieldsFormattable<T, Formatter>(std::make_index_sequence<N>{}))
76 return detail::makeAggregateColumns<T>(std::move(options), std::move(formatter), std::make_index_sequence<N>{});
80template <
class T,
class Formatter, std::size_t N, std::size_t... I>
81std::expected<std::array<TableColumn<T>, N>, TextError> makeAggregateSchema(std::array<ColumnCaption, N> captions,
82 Formatter formatter, WidthPolicy policy,
83 std::index_sequence<I...>) {
84 if constexpr (N == 0) {
85 return std::array<TableColumn<T>, 0>{};
88 policy,
tableColumn<T>(captions[I].header, AggregateFieldProjection<I, T>{}, formatter, captions[I].width)...);
105template <
class T, std::
size_t N,
class Formatter>
106 requires(std::is_aggregate_v<T> && N == boost::pfr::tuple_size_v<T> &&
107 detail::aggregateFieldsFormattable<T, Formatter>(std::make_index_sequence<N>{}))
110 return detail::makeAggregateSchema<T>(std::move(captions), std::move(formatter), policy,
111 std::make_index_sequence<N>{});
Public Portals API.
Definition action.hpp:8
std::array< TableColumn< T >, N > aggregateColumns(std::array< TableColumnOptions, N > options, Formatter formatter)
Create columns for every field in PFR's aggregate declaration order.
Definition aggregate_columns.hpp:75
std::expected< std::array< TableColumn< T >, 1+sizeof...(Rest)>, TextError > tableColumns(WidthPolicy policy, TableColumnSpec< T > first, Rest &&...rest)
Assemble a fixed schema and allocate deterministic table-local identities.
Definition table_column.hpp:265
TableColumn< T > tableColumn(TableColumnOptions options, Projection projection, Formatter formatter)
Compose an owning typed column from explicit projection and text formatting.
Definition table_column.hpp:84
TableColumn< T > aggregateColumn(TableColumnOptions options, Formatter formatter)
Create a typed column for one selected field of a PFR SimpleAggregate.
Definition aggregate_columns.hpp:57
Project one field from an immutable, borrowed aggregate row.
Definition aggregate_columns.hpp:21
Owning fixed-schema caption and sizing, without identity bookkeeping.
Definition table_column.hpp:37
Owning metadata for a typed column; validation remains part of table preparation.
Definition table_column.hpp:17
A typed owning column definition; identity is independent of visual order.
Definition virtual_table.hpp:25
Owning error value, independent of the failed input's lifetime.
Definition text.hpp:87
Owning deterministic width policy; no font or terminal matching promise.
Definition text.hpp:42