[Account.cpp][api] gnc_account_foreach_split takes std::function<void(Split*)>

This commit is contained in:
Christopher Lam
2024-04-21 23:25:30 +08:00
parent 31e80a18a3
commit 0f791c474a
2 changed files with 16 additions and 0 deletions

View File

@@ -1137,6 +1137,20 @@ xaccInitAccount (Account * acc, QofBook *book)
/********************************************************************\
\********************************************************************/
void
gnc_account_foreach_split (const Account *acc, std::function<void(Split*)> func,
bool reverse)
{
if (!GNC_IS_ACCOUNT (acc))
return;
auto splits{GET_PRIVATE(acc)->splits};
if (reverse)
std::for_each(splits.rbegin(), splits.rend(), func);
else
std::for_each(splits.begin(), splits.end(), func);
}
Split*
gnc_account_find_split (const Account *acc, std::function<bool(const Split*)> predicate,
bool reverse)

View File

@@ -41,6 +41,8 @@ using SplitsVec = std::vector<Split*>;
const SplitsVec xaccAccountGetSplits (const Account*);
void gnc_account_foreach_split (const Account*, std::function<void(Split*)>, bool);
/** scans account split list (in forward or reverse order) until
* predicate split->bool returns true. Maybe return the split.
*