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

◆ from_rows()

std::shared_ptr< const XmlDocument > MayaFlux::IO::XmlDocument::from_rows ( Kakshya::CompositeArray rows,
std::string & error )
staticnodiscard

Take ownership of rows in the XML node layout.

Parameters
rowsRows laid out as xml_composite_layout in document order.
errorReceives the reason when nullptr is returned.
Returns
The document, or nullptr when the layout differs or a row's parent does not precede it.

Definition at line 20 of file XmlDocument.cpp.

22{
23 if (!rows.layout().same_structure(xml_composite_layout())) {
24 error = "Rows do not use the XML node layout";
25 return nullptr;
26 }
27 auto forest = Kakshya::CompositeForest::build(std::move(rows), "parent", error);
28 if (!forest)
29 return nullptr;
30 if (!forest->index().preorder()) {
31 error = "XML rows are not in document order";
32 return nullptr;
33 }
34 return std::shared_ptr<const XmlDocument>(new XmlDocument(std::move(forest)));
35}
XmlDocument(std::shared_ptr< const Kakshya::CompositeForest > forest) noexcept
const Kakshya::CompositeForest & forest() const noexcept
The rows together with their parent index.
static std::shared_ptr< const CompositeForest > build(CompositeArray rows, std::string_view parent_field, std::string &error, uint64_t *error_row=nullptr)
Index rows and take ownership of them.
Kakshya::CompositeLayout xml_composite_layout()
Composite row layout used by the XML reader and writer.
Definition XmlReader.cpp:13
void error(Component component, Context context, std::source_location location, std::string_view message)
Log an error message and optionally throw an exception.

References MayaFlux::Kakshya::CompositeForest::build(), forest(), MayaFlux::Kakshya::CompositeArray::layout(), MayaFlux::Kakshya::CompositeLayout::same_structure(), MayaFlux::IO::xml_composite_layout(), and XmlDocument().

Referenced by load().

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