MayaFlux
1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
◆
repeated()
template<Reflect::Described Input, typename Node, typename Access = XmlRecordAccess<Node>>
template<auto Pointer>
XmlRecordBinding
&
MayaFlux::IO::XmlRecordBinding
< Input, Node, Access >::repeated
(
std::string
child_name
,
std::string
defaults_name
=
{}
,
std::string
required_item_attribute
=
{}
,
size_t
minimum
=
0
)
inline
Definition at line
63
of file
XmlRecordBinding.hpp
.
64
{},
65
std::string
required_item_attribute
= {},
66
size_t
minimum
= 0)
67
{
68
using
Values
=
std::remove_cvref_t<decltype(std::declval<Input&>
().*
Pointer
)>;
69
using
Item
=
typename
Values::value_type
;
70
static_assert
(
std::same_as<Values, std::vector<Item>
>);
71
static_assert
(
Reflect::Described<Item>
);
72
73
ChildBinding
binding
;
74
binding
.name =
std::move
(
child_name
);
75
binding
.defaults_name =
std::move
(
defaults_name
);
76
binding
.decode = [
name
=
binding
.name,
defaults_name
=
binding
.defaults_name,
77
required_item_attribute
=
std::move
(
required_item_attribute
),
minimum
](
78
Input
&
input
,
const
Node
&
node
,
std::string
&
error
,
79
uint64_t
*
error_row
) {
80
Item
defaults
{};
81
bool
defaults_seen
=
false
;
82
size_t
count
= 0;
83
auto
&
values
=
input
.*
Pointer
;
84
const
bool
traversed
=
Access::for_each_child
(
node
, [&](
const
Node
&
child
) {
85
if
(
error_row
)
86
*
error_row
=
Access::row
(
child
);
87
88
const
auto
child_name
=
Access::name
(
child
);
89
if
(!
defaults_name
.empty() &&
child_name
==
defaults_name
) {
90
if
(
defaults_seen
||
count
!= 0) {
91
error
=
"<"
+
defaults_name
+
"> must appear once before the "
92
+
name
+
" children"
;
93
return
false
;
94
}
95
defaults_seen
=
true
;
96
if
(!
required_item_attribute
.empty()
97
&&
Access::attribute
(
child
,
required_item_attribute
)) {
98
error
=
"<"
+
defaults_name
+
"> has an unsupported attribute "
99
+
required_item_attribute
;
100
return
false
;
101
}
102
if
(
has_children
(
child
)) {
103
error
=
"<"
+
defaults_name
+
"> may not have children"
;
104
return
false
;
105
}
106
return
overlay
(
defaults
,
child
,
error
);
107
}
108
if
(
child_name
!=
name
)
109
return
true
;
110
if
(!
required_item_attribute
.empty()
111
&& !
Access::attribute
(
child
,
required_item_attribute
)) {
112
error
=
"<"
+
label
(
child
) +
"> needs a "
113
+
required_item_attribute
+
" attribute"
;
114
return
false
;
115
}
116
if
(
has_children
(
child
)) {
117
error
=
"<"
+
name
+
"> may not have children"
;
118
return
false
;
119
}
120
Item
item
=
defaults
;
121
if
(!
overlay
(
item
,
child
,
error
))
122
return
false
;
123
values
.push_back(
std::move
(
item
));
124
++
count
;
125
return
true
;
126
});
127
if
(!
traversed
)
128
return
false
;
129
if
(
count
<
minimum
) {
130
if
(
error_row
)
131
*
error_row
=
Access::row
(
node
);
132
error
=
"<"
+
std::string
(
Access::name
(
node
)) +
"> needs at least "
133
+
std::to_string
(
minimum
) +
" "
+
name
+
" children"
;
134
return
false
;
135
}
136
return
true
;
137
};
138
m_children
.push_back(
std::move
(
binding
));
139
return
*
this
;
140
}
MayaFlux::IO::XmlRecordBinding::has_children
static bool has_children(const Node &node)
Definition
XmlRecordBinding.hpp:204
MayaFlux::IO::XmlRecordBinding::m_children
std::vector< ChildBinding > m_children
Definition
XmlRecordBinding.hpp:222
MayaFlux::IO::XmlRecordBinding::overlay
static bool overlay(T &target, const Node &node, std::string &error)
Definition
XmlRecordBinding.hpp:190
MayaFlux::IO::XmlRecordBinding::label
static std::string label(const Node &node)
Definition
XmlRecordBinding.hpp:198
MayaFlux::IO::XmlRecordBinding
Bind described attributes and configured XML child collections.
Definition
XmlRecordBinding.hpp:41
MayaFlux::IO::XmlRecordBinding::ChildBinding
Definition
XmlRecordBinding.hpp:214
MayaFlux
IO
XmlRecordBinding
Generated by
1.15.0