@@ -153,92 +153,90 @@ struct Node {
153
153
template <auto refl, typename T> std::string format (T const &t) {
154
154
std::string out;
155
155
156
- auto delim = [&, first = true ]() mutable {
157
- if (!first) {
158
- std::format_to (std::back_inserter (out), [:refl:] ::delimiter ());
159
- }
160
- first = false ;
161
- };
162
-
163
- std::format_to (std::back_inserter (out), " {}" , [:refl:] ::start ());
164
- util::for_range<0 , util::number_of_base<T>()>([&]<auto I>() {
165
- constexpr auto base = util::base_info<T>(I);
166
- delim ();
167
- std::format_to (std::back_inserter (out), " {}" ,
168
- format<refl>((typename [:type_of (base):] const & )(t)));
169
- });
170
-
171
- util::for_range<0 , util::number_of_members<T>()>([&]<auto I>() {
172
- constexpr auto mem = util::member_info<T>(I);
173
- constexpr auto name = util::name_of (mem);
174
- constexpr auto type = type_of (mem);
175
- delim ();
176
-
177
- if constexpr (std::is_arithmetic_v<[:type_of (mem):]>) {
178
- std::format_to (std::back_inserter (out),
179
- std::runtime_format ([:refl:] ::withLevelKnown ()), name,
180
- t.[:mem:]);
181
- } else if constexpr (std::same_as<[:type_of (mem):], std::string>) {
182
- std::format_to (std::back_inserter (out),
183
- std::runtime_format ([:refl:] ::withLevelKnown ()), name,
184
- std::format (" \" {}\" " , t.[:mem:]));
185
- } else if constexpr (std::is_constructible_v<
186
- std::formatter<[:type_of (mem):]>>) {
187
- std::format_to (std::back_inserter (out),
188
- std::runtime_format ([:refl:] ::withLevelKnown ()), name,
189
- std::format (" {}" , t.[:mem:]));
190
- } else {
191
- std::format_to (std::back_inserter (out),
192
- std::runtime_format ([:refl:] ::withLevelNested ()), name,
193
- [&]() {
194
- [:refl:] ::increase_level ();
195
- return format<refl>(t.[:mem:]);
196
- }());
197
- [:refl:] ::decrease_level ();
198
- }
199
- });
200
- std::format_to (std::back_inserter (out), " {}" , [:refl:] ::end ());
156
+ // auto delim = [&, first = true]() mutable {
157
+ // if (!first) {
158
+ // std::format_to(std::back_inserter(out), "{}", [:refl:] ::delimiter());
159
+ // }
160
+ // first = false;
161
+ // };
162
+
163
+ // std::format_to(std::back_inserter(out), "{}", [:refl:] ::start());
164
+ // util::for_range<0, util::number_of_base<T>()>([&]<auto I>() {
165
+ // constexpr auto base = util::base_info<T>(I);
166
+ // delim();
167
+ // std::format_to(std::back_inserter(out), "{}",
168
+ // format<refl>((typename[:type_of(base):] const &)(t)));
169
+ // });
170
+
171
+ // util::for_range<0, util::number_of_members<T>()>([&]<auto I>() {
172
+ // constexpr auto mem = util::member_info<T>(I);
173
+ // constexpr auto name = util::name_of(mem);
174
+ // constexpr auto type = type_of(mem);
175
+ // // delim();
176
+
177
+ // if constexpr (std::is_arithmetic_v<[:type_of(mem):]>) {
178
+ // std::format_to(
179
+ // std::back_inserter(out), [:refl:] ::withLevelKnown(), name, t.[:
180
+ // mem:]);
181
+ // } else if constexpr (std::same_as<[:type_of(mem):], std::string>) {
182
+ // std::format_to(
183
+ // std::back_inserter(out), [:refl:] ::withLevelKnown(), name,
184
+ // std::format("\"{}\"", t.[:mem:]));
185
+ // } else if constexpr (std::is_constructible_v<
186
+ // std::formatter<[:type_of(mem):]>>) {
187
+ // std::format_to(
188
+ // std::back_inserter(out), [:refl:] ::withLevelKnown(), name,
189
+ // std::format("{}", t.[:mem:]));
190
+ // } else {
191
+ // std::format_to(
192
+ // std::back_inserter(out), [:refl:] ::withLevelNested(), name, [&]() {
193
+ // [:refl:] ::increase_level();
194
+ // return format<refl>(t.[:mem:]);
195
+ // }());
196
+ // [:refl:] ::decrease_level();
197
+ // }
198
+ // });
199
+ // std::format_to(std::back_inserter(out), "{}", [:refl:] ::end());
201
200
202
201
return out;
203
202
}
204
203
205
204
template <typename T> void from_node (auto const &node, T &t) {
206
-
207
- util::for_range<0 , util::number_of_members<T>()>([&]<auto I>() {
208
- constexpr auto mem = util::member_info<T>(I);
209
- auto name = std::string{util::name_of (mem)};
210
- // std::println("get value of: {}", name_of(mem));
211
- if constexpr (std::is_arithmetic_v<[:type_of (mem):]> ||
212
- std::same_as<[:type_of (mem):], std::string>) {
213
- t.[:mem:] = node[name].template as <[:type_of (mem):]>();
214
- } else if constexpr (std::is_constructible_v<
215
- std::formatter<[:type_of (mem):]>>) {
216
- // std::println("get value from std::format {}", name);
217
- constexpr auto type_of_mem =
218
- util::template_arguments<[:type_of (mem):]>(0 );
219
- t.[:mem:] = util::construct_from<[:type_of (mem):]>(
220
- node[name].template as <[:type_of_mem:]>());
221
- } else {
222
- // std::println("diving into: {}", name);
223
- from_node (node[name], t.[:mem:]);
224
- }
225
- });
226
-
227
- util::for_range<0 , util::number_of_base<T>()>([&]<auto I>() {
228
- constexpr auto base = util::base_info<T>(I);
229
- util::for_range<0 , util::number_of_members<[:type_of (base):]>()>(
230
- [&]<auto II>() {
231
- constexpr auto mem = util::member_info<[:type_of (base):]>(II);
232
- if constexpr (std::is_arithmetic_v<[:type_of (mem):]> ||
233
- std::same_as<[:type_of (mem):], std::string>) {
234
- auto name = std::string{util::name_of (mem)};
235
- t.[:mem:] = node[name].template as <[:type_of (mem):]>();
236
- } else if constexpr (std::formattable<[:type_of (mem):], char >) {
237
- } else {
238
- from_node (node[util::name_of (mem)], t.[:mem:]);
239
- }
240
- });
241
- });
205
+ // util::for_range<0, util::number_of_members<T>()>([&]<auto I>() {
206
+ // constexpr auto mem = util::member_info<T>(I);
207
+ // auto name = std::string{util::name_of(mem)};
208
+ // // std::println("get value of: {}", name_of(mem));
209
+ // if constexpr (std::is_arithmetic_v<[:type_of(mem):]> ||
210
+ // std::same_as<[:type_of(mem):], std::string>) {
211
+ // t.[:mem:] = node[name].template as<[:type_of(mem):]>();
212
+ // } else if constexpr (std::is_constructible_v<
213
+ // std::formatter<[:type_of(mem):]>>) {
214
+ // // std::println("get value from std::format {}", name);
215
+ // constexpr auto type_of_mem =
216
+ // util::template_arguments<[:type_of(mem):]>(0);
217
+ // t.[:mem:] = util::construct_from<[:type_of(mem):]>(
218
+ // node[name].template as<[:type_of_mem:]>());
219
+ // } else {
220
+ // // std::println("diving into: {}", name);
221
+ // from_node(node[name], t.[:mem:]);
222
+ // }
223
+ // });
224
+
225
+ // util::for_range<0, util::number_of_base<T>()>([&]<auto I>() {
226
+ // constexpr auto base = util::base_info<T>(I);
227
+ // util::for_range<0, util::number_of_members<[:type_of(base):]>()>(
228
+ // [&]<auto II>() {
229
+ // constexpr auto mem = util::member_info<[:type_of(base):]>(II);
230
+ // if constexpr (std::is_arithmetic_v<[:type_of(mem):]> ||
231
+ // std::same_as<[:type_of(mem):], std::string>) {
232
+ // auto name = std::string{util::name_of(mem)};
233
+ // t.[:mem:] = node[name].template as<[:type_of(mem):]>();
234
+ // } else if constexpr (std::formattable<[:type_of(mem):], char>) {
235
+ // } else {
236
+ // from_node(node[util::name_of(mem)], t.[:mem:]);
237
+ // }
238
+ // });
239
+ // });
242
240
}
243
241
244
242
template <typename T> std::string format_yaml (T const &t) {
0 commit comments