From 69c587681ab297141925d5a898b4d9b875516fd5 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Wed, 11 Aug 2004 23:03:54 -0400 Subject: more reorg --- walk.h | 61 ++++++++++++++++++++++--------------------------------------- 1 file changed, 22 insertions(+), 39 deletions(-) (limited to 'walk.h') diff --git a/walk.h b/walk.h index 862ffde0..c29e5f6d 100644 --- a/walk.h +++ b/walk.h @@ -472,10 +472,21 @@ class balance_accounts : public item_handler #endif -inline void sort_accounts(account_t * account, - accounts_deque& accounts, - const value_expr_t * sort_order) -{ +////////////////////////////////////////////////////////////////////// + +inline void sum_accounts(account_t * account) { + for (accounts_map::iterator i = account->accounts.begin(); + i != account->accounts.end(); + i++) { + sum_accounts((*i).second); + account->total += (*i).second->total; + } + account->total += account->value; +} + +inline void sort_accounts(account_t * account, + accounts_deque& accounts, + const value_expr_t * sort_order) { for (accounts_map::iterator i = account->accounts.begin(); i != account->accounts.end(); i++) @@ -485,55 +496,27 @@ inline void sort_accounts(account_t * account, compare_items(sort_order)); } -inline void walk__accounts_sorted(account_t * account, - item_handler& handler, - const value_expr_t * sort_order) -{ +inline void walk_accounts(account_t * account, + item_handler& handler, + const value_expr_t * sort_order) { handler(account); accounts_deque accounts; sort_accounts(account, accounts, sort_order); - for (accounts_deque::const_iterator i = accounts.begin(); i != accounts.end(); i++) - walk__accounts_sorted(*i, handler, sort_order); + walk_accounts(*i, handler, sort_order); } -inline void sum__accounts(account_t * account) -{ - for (accounts_map::iterator i = account->accounts.begin(); - i != account->accounts.end(); - i++) { - sum__accounts((*i).second); - account->total += (*i).second->total; - } - account->total += account->value; -} - -inline void walk__accounts(account_t * account, - item_handler& handler) -{ +inline void walk_accounts(account_t * account, + item_handler& handler) { handler(account); for (accounts_map::const_iterator i = account->accounts.begin(); i != account->accounts.end(); i++) - walk__accounts((*i).second, handler); -} - -inline void walk_accounts(account_t * account, - item_handler& handler, - const bool calc_subtotals, - const value_expr_t * sort_order = NULL) -{ - if (calc_subtotals) - sum__accounts(account); - - if (sort_order) - walk__accounts_sorted(account, handler, sort_order); - else - walk__accounts(account, handler); + walk_accounts((*i).second, handler); } } // namespace ledger -- cgit v1.2.3