Commit 5634c340 authored by Dominik Charousset's avatar Dominik Charousset

Add for_each_option to config class, relates #619

parent d86049a4
...@@ -332,6 +332,16 @@ public: ...@@ -332,6 +332,16 @@ public:
error_renderer_map error_renderers; error_renderer_map error_renderers;
// -- convenience functions --------------------------------------------------
template <class F>
void for_each_option(F f) const {
const option_vector* all_options[] = { &options_, &custom_options_ };
for (auto& opt_vec : all_options)
for (auto& opt : *opt_vec)
f(*opt);
}
// -- utility for caf-run ---------------------------------------------------- // -- utility for caf-run ----------------------------------------------------
// Config parameter for individual actor types. // Config parameter for individual actor types.
......
...@@ -438,16 +438,13 @@ actor_system_config& actor_system_config::parse(message& args, ...@@ -438,16 +438,13 @@ actor_system_config& actor_system_config::parse(message& args,
if (res.opts.count("caf#dump-config") != 0u) { if (res.opts.count("caf#dump-config") != 0u) {
cli_helptext_printed = true; cli_helptext_printed = true;
std::string category; std::string category;
option_vector* all_options[] = { &options_, &custom_options_ }; for_each_option([&](const config_option& x) {
for (auto& opt_vec : all_options) { if (category != x.category()) {
for (auto& opt : *opt_vec) { category = x.category();
if (category != opt->category()) { cout << "[" << category << "]" << endl;
category = opt->category();
cout << "[" << category << "]" << endl;
}
cout << opt->name() << "=" << opt->to_string() << endl;
} }
} cout << x.name() << "=" << x.to_string() << endl;
});
} }
return *this; return *this;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment