mirror of
https://github.com/genodelabs/genode.git
synced 2025-05-28 13:14:26 +00:00
gems: use C++20 function template syntax
This commit is contained in:
parent
4dc1014bfb
commit
0cf12c6778
@ -256,8 +256,7 @@ class Depot_deploy::Child : public List_model<Child>::Element
|
||||
/*
|
||||
* \return true if condition changed
|
||||
*/
|
||||
template <typename COND_FN>
|
||||
bool apply_condition(COND_FN const &fn)
|
||||
bool apply_condition(auto const &cond_fn)
|
||||
{
|
||||
Condition const orig_condition = _condition;
|
||||
|
||||
@ -266,14 +265,13 @@ class Depot_deploy::Child : public List_model<Child>::Element
|
||||
: Xml_node("<empty/>");
|
||||
|
||||
if (_start_xml.constructed())
|
||||
_condition = fn(_start_xml->xml(), launcher_xml)
|
||||
_condition = cond_fn(_start_xml->xml(), launcher_xml)
|
||||
? SATISFIED : UNSATISFIED;
|
||||
|
||||
return _condition != orig_condition;
|
||||
}
|
||||
|
||||
template <typename FN>
|
||||
void apply_if_unsatisfied(FN const &fn) const
|
||||
void apply_if_unsatisfied(auto const &fn) const
|
||||
{
|
||||
Xml_node launcher_xml = _launcher_xml.constructed()
|
||||
? _launcher_xml->xml()
|
||||
@ -355,8 +353,7 @@ class Depot_deploy::Child : public List_model<Child>::Element
|
||||
|
||||
inline void gen_monitor_policy_node(Xml_generator&) const;
|
||||
|
||||
template <typename FN>
|
||||
void with_missing_pkg_path(FN const &fn) const
|
||||
void with_missing_pkg_path(auto const &fn) const
|
||||
{
|
||||
if (_state == State::PKG_INCOMPLETE)
|
||||
fn(_config_pkg_path());
|
||||
|
@ -103,12 +103,11 @@ class Depot_deploy::Children
|
||||
/*
|
||||
* \return true if the condition of any child changed
|
||||
*/
|
||||
template <typename COND_FN>
|
||||
bool apply_condition(COND_FN const &fn)
|
||||
bool apply_condition(auto const &cond_fn)
|
||||
{
|
||||
bool any_condition_changed = false;
|
||||
_children.for_each([&] (Child &child) {
|
||||
any_condition_changed |= child.apply_condition(fn); });
|
||||
any_condition_changed |= child.apply_condition(cond_fn); });
|
||||
return any_condition_changed;
|
||||
}
|
||||
|
||||
@ -116,8 +115,7 @@ class Depot_deploy::Children
|
||||
* Call 'fn' with start 'Xml_node' of each child that has an
|
||||
* unsatisfied start condition.
|
||||
*/
|
||||
template <typename FN>
|
||||
void for_each_unsatisfied_child(FN const &fn) const
|
||||
void for_each_unsatisfied_child(auto const &fn) const
|
||||
{
|
||||
_children.for_each([&] (Child const &child) {
|
||||
child.apply_if_unsatisfied(fn); });
|
||||
@ -158,8 +156,7 @@ class Depot_deploy::Children
|
||||
child.gen_installation_entry(xml); });
|
||||
}
|
||||
|
||||
template <typename FN>
|
||||
void for_each_missing_pkg_path(FN const &fn) const
|
||||
void for_each_missing_pkg_path(auto const &fn) const
|
||||
{
|
||||
_children.for_each([&] (Child const &child) {
|
||||
child.with_missing_pkg_path(fn); });
|
||||
|
@ -778,16 +778,12 @@ struct Sculpt::Main : Input_event_handler,
|
||||
{
|
||||
Hosted<Frame, Mmc_devices_widget> _mmc_devices;
|
||||
|
||||
template <typename... ARGS>
|
||||
Storage_widget(ARGS &&... args) : _mmc_devices(Id { "devices" }, args...) { }
|
||||
Storage_widget(auto &&... args) : _mmc_devices(Id { "devices" }, args...) { }
|
||||
|
||||
void view(Scope<Frame> &s) const { s.widget(_mmc_devices); }
|
||||
|
||||
template <typename... ARGS>
|
||||
void click(ARGS &&... args) { _mmc_devices.propagate(args...); }
|
||||
|
||||
template <typename... ARGS>
|
||||
void clack(ARGS &&... args) { _mmc_devices.propagate(args...); }
|
||||
void click(auto &&... args) { _mmc_devices.propagate(args...); }
|
||||
void clack(auto &&... args) { _mmc_devices.propagate(args...); }
|
||||
|
||||
void reset_operation() { _mmc_devices.reset_operation(); }
|
||||
};
|
||||
@ -1319,8 +1315,8 @@ struct Sculpt::Main : Input_event_handler,
|
||||
|
||||
void _handle_window_layout();
|
||||
|
||||
template <size_t N, typename FN>
|
||||
void _with_window(Xml_node window_list, String<N> const &match, FN const &fn)
|
||||
template <size_t N>
|
||||
void _with_window(Xml_node window_list, String<N> const &match, auto const &fn)
|
||||
{
|
||||
window_list.for_each_sub_node("window", [&] (Xml_node win) {
|
||||
if (win.attribute_value("label", String<N>()) == match)
|
||||
|
@ -42,8 +42,7 @@ struct Sculpt::Component_add_widget : Widget<Vbox>
|
||||
|
||||
Id _selected_route { };
|
||||
|
||||
template <typename FN>
|
||||
void _apply_to_selected_route(Action &action, FN const &fn)
|
||||
void _apply_to_selected_route(Action &action, auto const &fn)
|
||||
{
|
||||
unsigned count = 0;
|
||||
action.apply_to_construction([&] (Component &component) {
|
||||
|
@ -212,8 +212,7 @@ struct Sculpt::Deploy
|
||||
/**
|
||||
* Call 'fn' for each unsatisfied dependency of the child's 'start' node
|
||||
*/
|
||||
template <typename FN>
|
||||
void _for_each_missing_server(Xml_node start, FN const &fn) const
|
||||
void _for_each_missing_server(Xml_node start, auto const &fn) const
|
||||
{
|
||||
start.for_each_sub_node("route", [&] (Xml_node route) {
|
||||
route.for_each_sub_node("service", [&] (Xml_node service) {
|
||||
|
@ -22,16 +22,14 @@ namespace Dialog { struct Parent_node; }
|
||||
|
||||
struct Dialog::Parent_node : Sub_scope
|
||||
{
|
||||
template <typename SCOPE, typename TEXT>
|
||||
static void view_sub_scope(SCOPE &s, TEXT const &text)
|
||||
static void view_sub_scope(auto &s, auto const &text)
|
||||
{
|
||||
s.node("frame", [&] {
|
||||
s.sub_node("label", [&] {
|
||||
s.attribute("text", Sculpt::Start_name(" ", text, " ")); }); });
|
||||
}
|
||||
|
||||
template <typename AT, typename FN>
|
||||
static void with_narrowed_at(AT const &, FN const &) { }
|
||||
static void with_narrowed_at(auto const &, auto const &) { }
|
||||
};
|
||||
|
||||
|
||||
@ -47,9 +45,8 @@ struct Dialog::Selectable_node
|
||||
Start_name pretty_name;
|
||||
};
|
||||
|
||||
template <typename FN>
|
||||
static void view(Scope<Depgraph> &s, Id const &id,
|
||||
Attr const &attr, FN const &selected_fn)
|
||||
Attr const &attr, auto const &selected_fn)
|
||||
{
|
||||
s.sub_scope<Frame>(id, [&] (Scope<Depgraph, Frame> &s) {
|
||||
|
||||
|
@ -193,8 +193,7 @@ struct Sculpt::Main : Input_event_handler,
|
||||
template <typename TOP_LEVEL_DIALOG>
|
||||
struct Dialog_view : TOP_LEVEL_DIALOG, private Distant_runtime::View
|
||||
{
|
||||
template <typename... ARGS>
|
||||
Dialog_view(Distant_runtime &runtime, ARGS &&... args)
|
||||
Dialog_view(Distant_runtime &runtime, auto &&... args)
|
||||
: TOP_LEVEL_DIALOG(args...), Distant_runtime::View(runtime, *this) { }
|
||||
|
||||
using Distant_runtime::View::refresh;
|
||||
@ -1380,8 +1379,8 @@ struct Sculpt::Main : Input_event_handler,
|
||||
|
||||
void _handle_window_layout();
|
||||
|
||||
template <size_t N, typename FN>
|
||||
void _with_window(Xml_node window_list, String<N> const &match, FN const &fn)
|
||||
template <size_t N>
|
||||
void _with_window(Xml_node window_list, String<N> const &match, auto const &fn)
|
||||
{
|
||||
window_list.for_each_sub_node("window", [&] (Xml_node win) {
|
||||
if (win.attribute_value("label", String<N>()) == match)
|
||||
|
@ -69,8 +69,7 @@ struct Sculpt::Managed_config
|
||||
(_obj.*_handle)(_manual_config_rom.xml());
|
||||
}
|
||||
|
||||
template <typename FN>
|
||||
void with_manual_config(FN const &fn) const
|
||||
void with_manual_config(auto const &fn) const
|
||||
{
|
||||
fn(_manual_config_rom.xml());
|
||||
}
|
||||
@ -91,8 +90,7 @@ struct Sculpt::Managed_config
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename FN>
|
||||
void generate(FN const &fn)
|
||||
void generate(auto const &fn)
|
||||
{
|
||||
_config.generate([&] (Xml_generator &xml) { fn(xml); });
|
||||
}
|
||||
|
@ -95,8 +95,7 @@ struct Sculpt::Download_queue : Noncopyable
|
||||
new (_alloc) Registered<Download>(_downloads, path, verify);
|
||||
}
|
||||
|
||||
template <typename FN>
|
||||
void with_download(Path const &path, FN const &fn) const
|
||||
void with_download(Path const &path, auto const &fn) const
|
||||
{
|
||||
_downloads.for_each([&] (Download const &download) {
|
||||
if (download.path == path)
|
||||
@ -170,8 +169,7 @@ struct Sculpt::Download_queue : Noncopyable
|
||||
bool any_completed_download() const { return _state_present(Download::State::DONE); }
|
||||
bool any_failed_download() const { return _state_present(Download::State::FAILED); }
|
||||
|
||||
template <typename FN>
|
||||
void for_each_failed_download(FN const &fn) const
|
||||
void for_each_failed_download(auto const &fn) const
|
||||
{
|
||||
_downloads.for_each([&] (Download const &download) {
|
||||
if (download.state == Download::State::FAILED)
|
||||
|
@ -54,15 +54,13 @@ struct Sculpt::File_browser_state : Noncopyable
|
||||
query_result->update();
|
||||
}
|
||||
|
||||
template <typename FN>
|
||||
void with_query_result(FN const &fn) const
|
||||
void with_query_result(auto const &fn) const
|
||||
{
|
||||
if (query_result.constructed())
|
||||
fn(query_result->xml());
|
||||
}
|
||||
|
||||
template <typename FN>
|
||||
void with_entry_at_index(unsigned const index, FN const &fn) const
|
||||
void with_entry_at_index(unsigned const index, auto const &fn) const
|
||||
{
|
||||
unsigned count = 0;
|
||||
with_query_result([&] (Xml_node node) {
|
||||
|
@ -44,8 +44,7 @@ struct Sculpt::Index_menu
|
||||
}
|
||||
}
|
||||
|
||||
template <typename FN>
|
||||
void _for_each_item(Xml_node const &index, FN const &fn, unsigned level) const
|
||||
void _for_each_item(Xml_node const &index, auto const &fn, unsigned level) const
|
||||
{
|
||||
if (level == _level) {
|
||||
index.for_each_sub_node(fn);
|
||||
@ -57,8 +56,7 @@ struct Sculpt::Index_menu
|
||||
_for_each_item(index, fn, level + 1); });
|
||||
}
|
||||
|
||||
template <typename FN>
|
||||
void for_each_item(Xml_node const &index, User const &user, FN const &fn) const
|
||||
void for_each_item(Xml_node const &index, User const &user, auto const &fn) const
|
||||
{
|
||||
/*
|
||||
* The index may contain duplicates, evaluate only the first match.
|
||||
|
@ -116,8 +116,7 @@ struct Sculpt::Index_update_queue : Noncopyable
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename FN>
|
||||
void with_update(Path const &path, FN const &fn) const
|
||||
void with_update(Path const &path, auto const &fn) const
|
||||
{
|
||||
_updates.for_each([&] (Update const &update) {
|
||||
if (update.path == path)
|
||||
|
@ -84,8 +84,7 @@ class Sculpt::Launchers : public Noncopyable
|
||||
);
|
||||
}
|
||||
|
||||
template <typename FN>
|
||||
void for_each(FN const &fn) const
|
||||
void for_each(auto const &fn) const
|
||||
{
|
||||
_sorted.for_each([&] (Dict::Element const &e) { fn(Info(e.name)); });
|
||||
}
|
||||
|
@ -109,8 +109,7 @@ class Sculpt::Presets : public Noncopyable
|
||||
_presets.for_each([&] (Preset const &) { _count++; });
|
||||
}
|
||||
|
||||
template <typename FN>
|
||||
void for_each(FN const &fn) const
|
||||
void for_each(auto const &fn) const
|
||||
{
|
||||
_sorted.for_each([&] (Preset const &preset) { fn(preset.info); });
|
||||
}
|
||||
|
@ -230,8 +230,7 @@ class Sculpt::Runtime_config
|
||||
/* dependencies on other child components */
|
||||
List_model<Dep> deps { };
|
||||
|
||||
template <typename FN>
|
||||
void for_each_secondary_dep(FN const &fn) const
|
||||
void for_each_secondary_dep(auto const &fn) const
|
||||
{
|
||||
deps.for_each([&] (Dep const &dep) {
|
||||
if (dep.to_name != primary_dependency)
|
||||
@ -245,8 +244,7 @@ class Sculpt::Runtime_config
|
||||
name(name), graph_id(graph_ids, name, id)
|
||||
{ }
|
||||
|
||||
template <typename FN>
|
||||
void for_each_service(FN const &fn) const
|
||||
void for_each_service(auto const &fn) const
|
||||
{
|
||||
_child_services.for_each(fn);
|
||||
}
|
||||
@ -352,8 +350,7 @@ class Sculpt::Runtime_config
|
||||
_pd { _r, Type::PD, "system PD service" },
|
||||
_monitor { _r, Type::TERMINAL, "debug monitor" };
|
||||
|
||||
template <typename FN>
|
||||
void for_each(FN const &fn) const { _r.for_each(fn); }
|
||||
void for_each(auto const &fn) const { _r.for_each(fn); }
|
||||
|
||||
} _parent_services { };
|
||||
|
||||
@ -406,14 +403,12 @@ class Sculpt::Runtime_config
|
||||
[&] { });
|
||||
}
|
||||
|
||||
template <typename FN>
|
||||
void for_each_component(FN const &fn) const { _components.for_each(fn); }
|
||||
void for_each_component(auto const &fn) const { _components.for_each(fn); }
|
||||
|
||||
/**
|
||||
* Call 'fn' with the name of each dependency of component 'name'
|
||||
*/
|
||||
template <typename FN>
|
||||
void for_each_dependency(Start_name const &name, FN const &fn) const
|
||||
void for_each_dependency(Start_name const &name, auto const &fn) const
|
||||
{
|
||||
_components.for_each([&] (Component const &component) {
|
||||
if (component.name == name) {
|
||||
@ -421,8 +416,7 @@ class Sculpt::Runtime_config
|
||||
fn(dep.to_name); }); } });
|
||||
}
|
||||
|
||||
template <typename FN>
|
||||
void for_each_service(FN const &fn) const
|
||||
void for_each_service(auto const &fn) const
|
||||
{
|
||||
_parent_services.for_each(fn);
|
||||
|
||||
|
@ -468,15 +468,13 @@ class Sculpt::Runtime_state : public Runtime_info
|
||||
}
|
||||
}
|
||||
|
||||
template <typename FN>
|
||||
void apply_to_construction(FN const &fn)
|
||||
void apply_to_construction(auto const &fn)
|
||||
{
|
||||
if (_construction_in_progress())
|
||||
fn(*_currently_constructed->construction);
|
||||
}
|
||||
|
||||
template <typename FN>
|
||||
void with_construction(FN const &fn) const
|
||||
void with_construction(auto const &fn) const
|
||||
{
|
||||
if (_construction_in_progress())
|
||||
fn(*_currently_constructed->construction);
|
||||
|
@ -36,8 +36,7 @@ struct Sculpt::Settings
|
||||
Name name;
|
||||
Path chargen_file;
|
||||
|
||||
template <typename FN>
|
||||
static void for_each(FN const &fn)
|
||||
static void for_each(auto const &fn)
|
||||
{
|
||||
static Keyboard_layout layouts[] = {
|
||||
{ .name = "French", .chargen_file = "keyboard/fr_fr" },
|
||||
|
@ -173,15 +173,13 @@ struct Sculpt::Storage_device
|
||||
|
||||
inline void gen_part_block_start_content(Xml_generator &) const;
|
||||
|
||||
template <typename FN>
|
||||
void for_each_partition(FN const &fn) const
|
||||
void for_each_partition(auto const &fn) const
|
||||
{
|
||||
fn(*whole_device_partition);
|
||||
partitions.for_each([&] (Partition const &partition) { fn(partition); });
|
||||
}
|
||||
|
||||
template <typename FN>
|
||||
void for_each_partition(FN const &fn)
|
||||
void for_each_partition(auto const &fn)
|
||||
{
|
||||
fn(*whole_device_partition);
|
||||
partitions.for_each([&] (Partition &partition) { fn(partition); });
|
||||
|
@ -15,23 +15,20 @@
|
||||
|
||||
namespace Sculpt {
|
||||
|
||||
template <typename GEN_ARGS_FN>
|
||||
void gen_e2fs_start_content(Xml_generator &, Storage_target const &,
|
||||
Rom_name const &, GEN_ARGS_FN const &);
|
||||
Rom_name const &, auto const &);
|
||||
|
||||
template <typename ARG>
|
||||
void gen_arg(Xml_generator &xml, ARG const &arg)
|
||||
void gen_arg(Xml_generator &xml, auto const &arg)
|
||||
{
|
||||
xml.node("arg", [&] { xml.attribute("value", arg); });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template <typename GEN_ARGS_FN>
|
||||
void Sculpt::gen_e2fs_start_content(Xml_generator &xml,
|
||||
Storage_target const &target,
|
||||
Rom_name const &tool,
|
||||
GEN_ARGS_FN const &gen_args_fn)
|
||||
auto const &gen_args_fn)
|
||||
{
|
||||
gen_common_start_content(xml, String<64>(target.label(), ".", tool),
|
||||
Cap_quota{500}, Ram_quota{100*1024*1024},
|
||||
|
@ -15,17 +15,15 @@
|
||||
|
||||
namespace Sculpt {
|
||||
|
||||
template <typename GEN_ACTIONS_FN>
|
||||
void _gen_gpt_write_start_content(Xml_generator &, Storage_device const &,
|
||||
Start_name const &, GEN_ACTIONS_FN const &);
|
||||
Start_name const &, auto const &);
|
||||
}
|
||||
|
||||
|
||||
template <typename GEN_ACTIONS_FN>
|
||||
void Sculpt::_gen_gpt_write_start_content(Xml_generator &xml,
|
||||
Storage_device const &device,
|
||||
Start_name const &name,
|
||||
GEN_ACTIONS_FN const &fn)
|
||||
auto const &gen_actions_fn)
|
||||
{
|
||||
gen_common_start_content(xml, name, Cap_quota{100}, Ram_quota{2*1024*1024},
|
||||
Priority::STORAGE);
|
||||
@ -37,7 +35,7 @@ void Sculpt::_gen_gpt_write_start_content(Xml_generator &xml,
|
||||
xml.attribute("update_geometry", "yes");
|
||||
xml.attribute("preserve_hybrid", "yes");
|
||||
|
||||
xml.node("actions", [&] { fn(xml); });
|
||||
xml.node("actions", [&] { gen_actions_fn(xml); });
|
||||
});
|
||||
|
||||
xml.node("route", [&] {
|
||||
|
@ -16,8 +16,7 @@
|
||||
using namespace Sculpt;
|
||||
|
||||
|
||||
template <typename FN>
|
||||
static void for_each_inspected_storage_target(Storage_devices const &devices, FN const &fn)
|
||||
static void for_each_inspected_storage_target(Storage_devices const &devices, auto const &fn)
|
||||
{
|
||||
devices.for_each([&] (Storage_device const &device) {
|
||||
device.for_each_partition([&] (Partition const &partition) {
|
||||
|
@ -77,8 +77,7 @@ struct Sculpt::Storage : Storage_device_widget::Action, Ram_fs_widget::Action
|
||||
_storage_devices.gen_usb_storage_policies(xml);
|
||||
}
|
||||
|
||||
template <typename FN>
|
||||
void _apply_partition(Storage_target const &target, FN const &fn)
|
||||
void _apply_partition(Storage_target const &target, auto const &fn)
|
||||
{
|
||||
_storage_devices.for_each([&] (Storage_device &device) {
|
||||
|
||||
|
@ -412,8 +412,7 @@ struct Dialog::Operation_button : Widget<Button>
|
||||
view(s, selected, s.id.value);
|
||||
}
|
||||
|
||||
template <typename FN>
|
||||
void click(Clicked_at const &, FN const &fn) const { fn(); }
|
||||
void click(Clicked_at const &, auto const &fn) const { fn(); }
|
||||
};
|
||||
|
||||
|
||||
@ -516,8 +515,7 @@ struct Dialog::Choice : Widget<Hbox>
|
||||
bool const _unfolded;
|
||||
Id const _selected_item;
|
||||
|
||||
template <typename HOSTED, typename... ARGS>
|
||||
void widget(HOSTED const &hosted, ARGS &&... args)
|
||||
void widget(auto const &hosted, auto &&... args)
|
||||
{
|
||||
if (_unfolded || (hosted.id == _selected_item))
|
||||
hosted._view_hosted(_scope, args...);
|
||||
|
@ -46,8 +46,7 @@ struct Sculpt::File_browser_dialog : Top_level_dialog
|
||||
|
||||
Action &_action;
|
||||
|
||||
template <typename FN>
|
||||
static void _for_each_path_elem(Path const path, FN const &fn)
|
||||
static void _for_each_path_elem(Path const path, auto const &fn)
|
||||
{
|
||||
char const *curr = path.string();
|
||||
|
||||
|
@ -222,8 +222,7 @@ struct Sculpt::Popup_dialog : Dialog::Top_level_dialog
|
||||
return Path(user, "/index/", _sculpt_version);
|
||||
}
|
||||
|
||||
template <typename FN>
|
||||
void _for_each_menu_item(FN const &fn) const
|
||||
void _for_each_menu_item(auto const &fn) const
|
||||
{
|
||||
_menu.for_each_item(_index_rom.xml(), _selected_user, fn);
|
||||
}
|
||||
@ -312,8 +311,7 @@ struct Sculpt::Popup_dialog : Dialog::Top_level_dialog
|
||||
xml.attribute("pkg", component.path); }); });
|
||||
}
|
||||
|
||||
template <typename FN>
|
||||
void for_each_viewed_launcher(FN const &fn) const
|
||||
void for_each_viewed_launcher(auto const &fn) const
|
||||
{
|
||||
_launchers.for_each([&] (Launchers::Info const &info) {
|
||||
if (_runtime_info.present_in_runtime(info.path))
|
||||
|
@ -36,8 +36,7 @@ struct Sculpt::Storage_devices_widget_base : Widget<Vbox>
|
||||
_storage_devices(storage_devices), _used_target(used_target)
|
||||
{ }
|
||||
|
||||
template <typename DEVICE, typename BUTTON>
|
||||
void _view_device(Scope<Vbox> &s, DEVICE const &dev, BUTTON const &button) const
|
||||
void _view_device(Scope<Vbox> &s, auto const &dev, auto const &button) const
|
||||
{
|
||||
bool const selected = ( _selected_device == dev.name() );
|
||||
|
||||
|
@ -57,8 +57,7 @@ struct Sculpt::Text_entry_field
|
||||
}
|
||||
}
|
||||
|
||||
template <typename STRING>
|
||||
Text_entry_field(STRING const &s)
|
||||
Text_entry_field(auto const &s)
|
||||
{
|
||||
for (Utf8_ptr utf8 = s.string(); utf8.complete(); utf8 = utf8.next())
|
||||
apply(utf8.codepoint());
|
||||
|
@ -23,9 +23,8 @@
|
||||
|
||||
namespace Sculpt {
|
||||
|
||||
template <typename FN>
|
||||
static inline void gen_named_node(Xml_generator &xml,
|
||||
char const *type, char const *name, FN const &fn)
|
||||
char const *type, char const *name, auto const &fn)
|
||||
{
|
||||
xml.node(type, [&] {
|
||||
xml.attribute("name", name);
|
||||
@ -38,21 +37,19 @@ namespace Sculpt {
|
||||
xml.node(type, [&] { xml.attribute("name", name); });
|
||||
}
|
||||
|
||||
template <size_t N, typename FN>
|
||||
static inline void gen_named_node(Xml_generator &xml,
|
||||
char const *type, String<N> const &name, FN const &fn)
|
||||
char const *type, auto const &name, auto const &fn)
|
||||
{
|
||||
gen_named_node(xml, type, name.string(), fn);
|
||||
}
|
||||
|
||||
template <size_t N>
|
||||
static inline void gen_named_node(Xml_generator &xml, char const *type, String<N> const &name)
|
||||
static inline void gen_named_node(Xml_generator &xml, char const *type, auto const &name)
|
||||
{
|
||||
gen_named_node(xml, type, name.string());
|
||||
}
|
||||
|
||||
template <typename SESSION, typename FN>
|
||||
static inline void gen_service_node(Xml_generator &xml, FN const &fn)
|
||||
template <typename SESSION>
|
||||
static inline void gen_service_node(Xml_generator &xml, auto const &fn)
|
||||
{
|
||||
gen_named_node(xml, "service", SESSION::service_name(), fn);
|
||||
}
|
||||
@ -123,8 +120,8 @@ namespace Sculpt {
|
||||
return node.attribute_value(attr_name, T{});
|
||||
}
|
||||
|
||||
template <typename T, typename... ARGS>
|
||||
static T _attribute_value(Xml_node node, char const *sub_node_type, ARGS... args)
|
||||
template <typename T>
|
||||
static T _attribute_value(Xml_node node, char const *sub_node_type, auto &&... args)
|
||||
{
|
||||
if (!node.has_sub_node(sub_node_type))
|
||||
return T{};
|
||||
@ -138,8 +135,8 @@ namespace Sculpt {
|
||||
* The list of arguments except for the last one refer to XML path into the
|
||||
* XML structure. The last argument denotes the queried attribute name.
|
||||
*/
|
||||
template <typename T, typename... ARGS>
|
||||
static T query_attribute(Xml_node node, ARGS &&... args)
|
||||
template <typename T>
|
||||
static T query_attribute(Xml_node node, auto &&... args)
|
||||
{
|
||||
return _attribute_value<T>(node, args...);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user