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

◆ for_each_field()

template<typename Fn>
bool MayaFlux::IO::XmlElementView::for_each_field ( Fn && visitor) const

Visit attributes and immediate child elements in document order.

Returns
False if a boolean visitor stops traversal; true otherwise.

Definition at line 73 of file XmlReader.hpp.

74{
75 const size_t end = m_row + m_forest->subtree_size(m_row);
76 for (size_t index = m_row + 1; index < end; index += m_forest->subtree_size(index)) {
77 const auto source = m_rows->at(index);
78 if (!source)
79 continue;
80
81 const auto kind = source->text("kind");
82 if (!kind || (*kind != "attribute" && *kind != "element"))
83 continue;
84
85 const auto field_name = source->text("name");
86 if (!field_name)
87 continue;
88
89 const XmlFieldView field {
90 .kind = *kind == "attribute" ? XmlFieldKind::Attribute : XmlFieldKind::Element,
91 .name = *field_name,
92 .value = source->text("value").value_or(std::string_view {}),
93 .row = static_cast<uint64_t>(index),
94 .element = *kind == "element"
95 ? std::optional<XmlElementView>(XmlElementView(*m_rows, *m_forest, index))
96 : std::nullopt,
97 };
98 if constexpr (std::same_as<std::invoke_result_t<Fn&, const XmlFieldView&>, bool>) {
99 if (!std::invoke(visitor, field))
100 return false;
101 } else {
102 std::invoke(visitor, field);
103 }
104 }
105 return true;
106}
const Kakshya::CompositeArray * m_rows
Definition XmlReader.hpp:55
XmlElementView(const Kakshya::CompositeArray &rows, const Kakshya::ForestIndex &forest, size_t row) noexcept
Definition XmlReader.hpp:47
uint64_t row() const noexcept
Definition XmlReader.hpp:32
const Kakshya::ForestIndex * m_forest
Definition XmlReader.hpp:56
Source source()
Begin a Source chain.
Definition Plot.hpp:127

References MayaFlux::IO::Attribute, MayaFlux::IO::Element, m_forest, m_row, m_rows, row(), and XmlElementView().

Referenced by MayaFlux::IO::XmlRecordAccess< XmlElementView >::for_each_attribute(), MayaFlux::IO::XmlRecordAccess< XmlElementView >::for_each_child(), MayaFlux::IO::overlay_xml_attributes(), and MayaFlux::IO::overlay_xml_element().

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