summaryrefslogtreecommitdiff
path: root/src/iterators.h
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-02-19 16:53:25 -0400
committerJohn Wiegley <johnw@newartisans.com>2009-02-19 16:53:25 -0400
commit9805abbf2b38d64308bac536eea40e544e8f7cfe (patch)
tree32f6b6ae629409a118efdbc99f377fa86640e33d /src/iterators.h
parentd67c9fee0f0f576481065c7d50182a04bf5df37e (diff)
downloadfork-ledger-9805abbf2b38d64308bac536eea40e544e8f7cfe.tar.gz
fork-ledger-9805abbf2b38d64308bac536eea40e544e8f7cfe.tar.bz2
fork-ledger-9805abbf2b38d64308bac536eea40e544e8f7cfe.zip
Allow for sorting of the balance report
Sorting is repeated at each level of the hierarchy, unless --flat was specified in which case it applies to the entire applicable accounts list.
Diffstat (limited to 'src/iterators.h')
-rw-r--r--src/iterators.h24
1 files changed, 10 insertions, 14 deletions
diff --git a/src/iterators.h b/src/iterators.h
index 8bf05986..92f887d0 100644
--- a/src/iterators.h
+++ b/src/iterators.h
@@ -244,6 +244,7 @@ public:
class sorted_accounts_iterator : public accounts_iterator
{
expr_t sort_cmp;
+ bool flatten_all;
typedef std::deque<account_t *> accounts_deque_t;
@@ -252,13 +253,14 @@ class sorted_accounts_iterator : public accounts_iterator
std::list<accounts_deque_t::const_iterator> sorted_accounts_end;
public:
- sorted_accounts_iterator(const string& sort_order) {
- TRACE_CTOR(sorted_accounts_iterator, "const string&");
- sort_cmp = expr_t(sort_order);
+ sorted_accounts_iterator(const expr_t& _sort_cmp, bool _flatten_all)
+ : sort_cmp(_sort_cmp), flatten_all(_flatten_all) {
+ TRACE_CTOR(sorted_accounts_iterator, "const expr_t&, bool");
}
- sorted_accounts_iterator(account_t& account, const string& sort_order) {
- TRACE_CTOR(sorted_accounts_iterator, "account_t&, const string&");
- sort_cmp = expr_t(sort_order);
+ sorted_accounts_iterator(const expr_t& _sort_cmp, bool _flatten_all,
+ account_t& account)
+ : sort_cmp(_sort_cmp), flatten_all(_flatten_all) {
+ TRACE_CTOR(sorted_accounts_iterator, "const expr_t&, bool, account_t&");
push_back(account);
}
virtual ~sorted_accounts_iterator() throw() {
@@ -266,14 +268,8 @@ public:
}
void sort_accounts(account_t& account, accounts_deque_t& deque);
-
- void push_back(account_t& account) {
- accounts_list.push_back(accounts_deque_t());
- sort_accounts(account, accounts_list.back());
-
- sorted_accounts_i.push_back(accounts_list.back().begin());
- sorted_accounts_end.push_back(accounts_list.back().end());
- }
+ void push_all(account_t& account);
+ void push_back(account_t& account);
virtual account_t * operator()();
};