diff options
author | John Wiegley <johnw@newartisans.com> | 2004-08-07 21:49:28 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2004-08-07 21:49:28 -0400 |
commit | 2eccbc105ac9272876e453217e7ed5dc0cac04f6 (patch) | |
tree | 6cd92bfc75acc54fb2ce1bf69ba4d3a71212ed9f | |
parent | 38e9c6c76c486b95c1e29f61bdb4597ce3c544fd (diff) | |
download | fork-ledger-2eccbc105ac9272876e453217e7ed5dc0cac04f6.tar.gz fork-ledger-2eccbc105ac9272876e453217e7ed5dc0cac04f6.tar.bz2 fork-ledger-2eccbc105ac9272876e453217e7ed5dc0cac04f6.zip |
added walk.cc
-rw-r--r-- | walk.cc | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/walk.cc b/walk.cc new file mode 100644 index 00000000..5b923a86 --- /dev/null +++ b/walk.cc @@ -0,0 +1,31 @@ +#include "walk.h" + +namespace ledger { + +class sum_in_account +{ + public: + void operator()(transaction_t * xact) const { + xact->account->value += *xact; + } +}; + +void calc__accounts(account_t * account, + item_predicate<transaction_t>& pred_functor, + unsigned int flags) +{ + sum_in_account functor; + + for (transactions_list::iterator i = account->transactions.begin(); + i != account->transactions.end(); + i++) + if (pred_functor(*i)) + handle_transaction(*i, functor, flags); + + for (accounts_map::iterator i = account->accounts.begin(); + i != account->accounts.end(); + i++) + calc__accounts((*i).second, pred_functor, flags); +} + +} // namespace ledger |