MayaFlux
1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
◆
repeated()
template<Described Input, typename Source, typename Access = RecordAccess<Source>>
template<auto Pointer>
RecordBinding
&
MayaFlux::Reflect::RecordBinding
< Input, Source, Access >::repeated
(
std::string
child_name
,
std::string
defaults_name
=
{}
,
std::string
required_item_attribute
=
{}
,
size_t
minimum
=
0
)
inline
Definition at line
77
of file
RecordBinding.hpp
.
78
{},
79
std::string
required_item_attribute
= {},
80
size_t
minimum
= 0)
81
{
82
using
Values
=
std::remove_cvref_t<decltype(std::declval<Input&>
().*
Pointer
)>;
83
using
Item
=
typename
Values::value_type
;
84
static_assert
(
std::same_as<Values, std::vector<Item>
>);
85
static_assert
(
Described<Item>
);
86
87
ChildBinding
binding
;
88
binding
.name =
std::move
(
child_name
);
89
binding
.defaults_name =
std::move
(
defaults_name
);
90
binding
.decode = [
name
=
binding
.name,
defaults_name
=
binding
.defaults_name,
91
required_item_attribute
=
std::move
(
required_item_attribute
),
minimum
](
92
Input
&
input
,
const
Source
&
source
,
std::string
&
error
,
93
uint64_t
*
error_location
) {
94
Item
defaults
{};
95
bool
defaults_seen
=
false
;
96
size_t
count
= 0;
97
auto
&
values
=
input
.*
Pointer
;
98
const
bool
traversed
=
Access::for_each_child
(
source
, [&](
const
Source
&
child
) {
99
if
(
error_location
)
100
*
error_location
=
Access::location
(
child
);
101
102
const
auto
child_name
=
Access::name
(
child
);
103
if
(!
defaults_name
.empty() &&
child_name
==
defaults_name
) {
104
if
(
defaults_seen
||
count
!= 0) {
105
error
=
"<"
+
defaults_name
+
"> must appear once before the "
106
+
name
+
" children"
;
107
return
false
;
108
}
109
defaults_seen
=
true
;
110
if
(!
required_item_attribute
.empty()
111
&&
Access::attribute
(
child
,
required_item_attribute
)) {
112
error
=
"<"
+
defaults_name
+
"> has an unsupported attribute "
113
+
required_item_attribute
;
114
return
false
;
115
}
116
if
(
has_children
(
child
)) {
117
error
=
"<"
+
defaults_name
+
"> may not have children"
;
118
return
false
;
119
}
120
return
overlay
(
defaults
,
child
,
error
);
121
}
122
if
(
child_name
!=
name
)
123
return
true
;
124
if
(!
required_item_attribute
.empty()
125
&& !
Access::attribute
(
child
,
required_item_attribute
)) {
126
error
=
"<"
+
label
(
child
) +
"> needs a "
127
+
required_item_attribute
+
" attribute"
;
128
return
false
;
129
}
130
if
(
has_children
(
child
)) {
131
error
=
"<"
+
name
+
"> may not have children"
;
132
return
false
;
133
}
134
Item
item
=
defaults
;
135
if
(!
overlay
(
item
,
child
,
error
))
136
return
false
;
137
values
.push_back(
std::move
(
item
));
138
++
count
;
139
return
true
;
140
});
141
if
(!
traversed
)
142
return
false
;
143
if
(
count
<
minimum
) {
144
if
(
error_location
)
145
*
error_location
=
Access::location
(
source
);
146
error
=
"<"
+
std::string
(
Access::name
(
source
)) +
"> needs at least "
147
+
std::to_string
(
minimum
) +
" "
+
name
+
" children"
;
148
return
false
;
149
}
150
return
true
;
151
};
152
m_children
.push_back(
std::move
(
binding
));
153
return
*
this
;
154
}
MayaFlux::Reflect::RecordBinding::label
static std::string label(const Source &source)
Definition
RecordBinding.hpp:216
MayaFlux::Reflect::RecordBinding::has_children
static bool has_children(const Source &source)
Definition
RecordBinding.hpp:222
MayaFlux::Reflect::RecordBinding::overlay
static bool overlay(T &target, const Source &source, std::string &error)
Definition
RecordBinding.hpp:208
MayaFlux::Reflect::RecordBinding::m_children
std::vector< ChildBinding > m_children
Definition
RecordBinding.hpp:250
MayaFlux::Reflect::RecordBinding
Bind described attributes and configured child collections of a source element.
Definition
RecordBinding.hpp:30
MayaFlux::Reflect::RecordBinding::ChildBinding
Definition
RecordBinding.hpp:232
MayaFlux
Reflect
RecordBinding
Generated by
1.15.0