MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ records_of()

template<Reflect::Described T>
std::optional< std::vector< T > > MayaFlux::IO::records_of ( const Kakshya::CompositeArray & rows,
std::string & error )
nodiscard

Decode every row of a typed Composite array into values.

Works for rows from any source whose layout is the one derived from T: a delimited file loaded with that layout, or rows made by collect_records.

Parameters
rowsArray whose layout matches described_composite_layout of T.
errorReceives the reason when nullopt is returned.

Definition at line 53 of file DescribedRecords.hpp.

55{
57 error = "Composite layout does not match the described type";
58 return std::nullopt;
59 }
60 std::vector<T> values;
61 values.reserve(rows.size());
62 for (size_t i = 0; i < rows.size(); ++i) {
63 const auto row = rows.at(i);
64 T value {};
65 if (!row || !Kakshya::overlay_described(*row, value, error))
66 return std::nullopt;
67 values.push_back(std::move(value));
68 }
69 return values;
70}
size_t size() const noexcept
Number of packed elements.
const CompositeLayout & layout() const noexcept
Finalized layout shared by all elements.
std::optional< Composite > at(size_t index) const noexcept
Borrow an element by index.
bool same_structure(const CompositeLayout &other) const noexcept
Compare declared field names, kinds, and nested layouts.
Definition Composite.cpp:71
CompositeLayout described_composite_layout()
Derive a Composite layout from a generated member description.
bool overlay_described(const Composite &source, T &target, std::string &error)
Apply present Composite fields to a described value, preserving other members.

References MayaFlux::Kakshya::CompositeArray::at(), MayaFlux::Kakshya::described_composite_layout(), MayaFlux::Kakshya::CompositeArray::layout(), MayaFlux::Kakshya::overlay_described(), MayaFlux::Kakshya::CompositeLayout::same_structure(), MayaFlux::Kakshya::CompositeArray::size(), and T.

Here is the call graph for this function: