From f7f2d22909c8a205018d07dcc944db242bcffd80 Mon Sep 17 00:00:00 2001 From: John Ralls Date: Sat, 20 Feb 2021 11:42:42 -0800 Subject: [PATCH] Implement gnc-optiondb-foreach. --- libgnucash/app-utils/gnc-optiondb.i | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/libgnucash/app-utils/gnc-optiondb.i b/libgnucash/app-utils/gnc-optiondb.i index 0380a597de..58019706a1 100644 --- a/libgnucash/app-utils/gnc-optiondb.i +++ b/libgnucash/app-utils/gnc-optiondb.i @@ -832,6 +832,23 @@ wrap_unique_ptr(GncOptionDBPtr, GncOptionDB); auto option{odb->find_option(section, name)}; option->set_ui_item_selectable(selectable); } + + void + gnc_optiondb_foreach(GncOptionDBPtr& odb, SCM thunk) + { + odb->foreach_section( + [&thunk](const GncOptionSectionPtr& section) + { + section->foreach_option( + [&thunk](auto& option) + { + auto optvoidptr{reinterpret_cast( + const_cast(&option))}; + auto scm_opt{scm_from_pointer(optvoidptr, nullptr)}; + scm_call_1(thunk, scm_opt); + }); + }); + } %} #endif //SWIGGUILE