lib/dbus/ReadIter: add ForEachRecurse()

This commit is contained in:
Max Kellermann 2018-06-03 20:18:08 +02:00
parent d4141bf7f1
commit fbfbc5682a
2 changed files with 13 additions and 2 deletions

View File

@ -70,8 +70,8 @@ template<typename F>
inline void
ForEachInterface(ReadMessageIter &&i, F &&f)
{
i.ForEach(DBUS_TYPE_DICT_ENTRY, [&f](auto &&j){
RecurseInterfaceDictEntry(j.Recurse(), f);
i.ForEachRecurse(DBUS_TYPE_DICT_ENTRY, [&f](auto &&j){
RecurseInterfaceDictEntry(std::move(j), f);
});
}

View File

@ -91,6 +91,17 @@ public:
for (; GetArgType() == arg_type; Next())
f(*this);
}
/**
* Wrapper for ForEach() which passes a recursed iterator for
* each element.
*/
template<typename F>
void ForEachRecurse(int arg_type, F &&f) {
ForEach(arg_type, [&f](auto &&i){
f(i.Recurse());
});
}
};
} /* namespace ODBus */