MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
XmlRecordAccess.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "XmlReader.hpp"
4
6
7namespace MayaFlux::Reflect {
8
9template <>
10struct RecordAccess<IO::XmlElementView> {
12
13 static std::string_view name(const Source& source) { return source.name(); }
14 static uint64_t location(const Source& source) { return source.row(); }
15
16 static std::optional<std::string_view> attribute(const Source& source,
17 std::string_view name)
18 {
19 return source.attribute(name);
20 }
21
22 template <typename Visitor>
23 static bool for_each_attribute(const Source& source, Visitor&& visit)
24 {
25 return source.for_each_field([&](const IO::XmlFieldView& field) {
26 return field.kind == IO::XmlFieldKind::Element || visit(field.name, field.value);
27 });
28 }
29
30 template <typename Visitor>
31 static bool for_each_child(const Source& source, Visitor&& visit)
32 {
33 return source.for_each_field([&](const IO::XmlFieldView& field) {
34 return field.kind == IO::XmlFieldKind::Attribute || visit(*field.element);
35 });
36 }
37};
38
39}
Borrowed XML element with named attributes and immediate child elements.
Definition XmlReader.hpp:30
std::string_view name
Definition XmlReader.hpp:66
std::string_view value
Definition XmlReader.hpp:67
std::optional< XmlElementView > element
Definition XmlReader.hpp:69
One attribute or immediate child element borrowed from an XML element.
Definition XmlReader.hpp:64
static bool for_each_attribute(const Source &source, Visitor &&visit)
static uint64_t location(const Source &source)
static std::optional< std::string_view > attribute(const Source &source, std::string_view name)
static std::string_view name(const Source &source)
static bool for_each_child(const Source &source, Visitor &&visit)
How a record binding reads one source element of a document tree.