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

◆ index_composite_forest()

MAYAFLUX_API std::optional< ForestIndex > MayaFlux::Kakshya::index_composite_forest ( const CompositeArray & rows,
std::string_view parent_field,
std::string & error,
uint64_t * error_row = nullptr )
nodiscard

Index the parent links of a Composite array.

Parameters
rowsArray with a uint64_t parent field; a row without it present is a root.
parent_fieldName of the parent field.
errorReceives the reason when nullopt is returned.
error_rowReceives the failing row when given.
Returns
The index, or nullopt when the field is missing or not uint64_t, or a parent does not precede its child.

Definition at line 7 of file CompositeForest.cpp.

10{
11 const auto field = rows.layout().find_field(parent_field);
12 if (!field || rows.layout().fields()[*field].type != std::type_index(typeid(uint64_t))) {
13 error = "Composite has no uint64_t field " + std::string(parent_field);
14 return std::nullopt;
15 }
16
17 const std::string name(parent_field);
18 return build_forest_index(rows,
19 [&name](const Composite& row) { return row.get<uint64_t>(name); },
20 error, error_row);
21}
const CompositeLayout & layout() const noexcept
Finalized layout shared by all elements.
const std::vector< CompositeField > & fields() const noexcept
Declared fields in element order, with finalized byte offsets.
std::optional< size_t > find_field(std::string_view name) const noexcept
Find a field index by name, or std::nullopt if absent.
std::optional< ForestIndex > build_forest_index(const Array &array, Parent &&parent, std::string &error, uint64_t *error_row=nullptr)
Build a ForestIndex from an array whose elements carry a parent row.

References build_forest_index(), MayaFlux::Kakshya::CompositeLayout::fields(), MayaFlux::Kakshya::CompositeLayout::find_field(), MayaFlux::Kakshya::Composite::get(), and MayaFlux::Kakshya::CompositeArray::layout().

Referenced by MayaFlux::Kakshya::CompositeForest::build(), MayaFlux::Kakshya::CompositeContainer::index_forest(), and MayaFlux::IO::XmlReader::open().

Here is the call graph for this function:
Here is the caller graph for this function: