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

◆ read()

template<Reflect::Described Input, typename Node, typename Access = XmlRecordAccess<Node>>
std::optional< Input > MayaFlux::IO::XmlRecordBinding< Input, Node, Access >::read ( const Node & node,
std::string & error,
uint64_t * error_row = nullptr ) const
inlinenodiscard

Definition at line 142 of file XmlRecordBinding.hpp.

144 {
145 if (error_row)
147 for (const auto& name : m_required) {
148 if (!Access::attribute(node, name)) {
149 error = "<" + label(node) + "> needs a " + name + " attribute";
150 return std::nullopt;
151 }
152 }
153
154 Input input {};
156 [&](const auto& visit) {
159 return std::ranges::find(m_ignored, name) != m_ignored.end()
160 || visit(name, value);
161 });
162 }, label(node), error);
163 if (!overlaid)
164 return std::nullopt;
165 const bool known_children = Access::for_each_child(node, [&](const Node& child) {
166 const auto child_name = Access::name(child);
167 const bool known = std::ranges::any_of(m_children, [&](const ChildBinding& binding) {
168 return child_name == binding.name
169 || (!binding.defaults_name.empty() && child_name == binding.defaults_name);
170 });
171 if (known)
172 return true;
173 if (error_row)
175 error = "<" + std::string(child_name) + "> is not allowed in <"
176 + std::string(Access::name(node)) + ">";
177 return false;
178 });
179 if (!known_children)
180 return std::nullopt;
181 for (const ChildBinding& binding : m_children) {
182 if (!binding.decode(input, node, error, error_row))
183 return std::nullopt;
184 }
185 return input;
186 }
std::vector< ChildBinding > m_children
std::vector< std::string > m_required
std::vector< std::string > m_ignored
static std::string label(const Node &node)
Bind described attributes and configured XML child collections.
bool overlay_xml_attributes(T &target, Attributes &&attributes, std::string_view label, std::string &error)
Overlay XML text attributes onto a described value.

References MayaFlux::IO::XmlRecordBinding< Input, Node, Access >::ChildBinding::defaults_name, label(), m_children, m_ignored, m_required, MayaFlux::IO::XmlRecordBinding< Input, Node, Access >::ChildBinding::name, and MayaFlux::IO::overlay_xml_attributes().

Here is the call graph for this function: