summaryrefslogtreecommitdiff
path: root/walk.h
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2008-08-02 06:42:36 -0400
committerJohn Wiegley <johnw@newartisans.com>2008-08-02 06:42:36 -0400
commit9a9e06554eb9f57be8c839fb0af49a0473614172 (patch)
treec31019afc5a482ff3daeb8cf672af22a0910d5a3 /walk.h
parent5bf3f536b37e77b5dd663fffbd32e71b403d2c7a (diff)
downloadfork-ledger-9a9e06554eb9f57be8c839fb0af49a0473614172.tar.gz
fork-ledger-9a9e06554eb9f57be8c839fb0af49a0473614172.tar.bz2
fork-ledger-9a9e06554eb9f57be8c839fb0af49a0473614172.zip
Formatting now relies exclusively on value expressions.
What this means is that the utility code, basic math, value expressions, string formatting and option handling are now entirely decoupled from the rest of the code. This decoupling not only greatly simplifies the more basic parts of Ledger, but makes it much easier to test and verify its completeness. For example, when the formatting code %X is seen by the format parser, it turns into a call to the expression function fmt_X, which must be defined when the format string is first compiled against an object. If that object is a transaction, the transaction's scope will be the first to have a chance at providing a definition. If an account is being reported, it will. If neither does, the next scope in sequence -- soon to be the current report -- will, and then the session object that "owns" the current Ledger session. In 2.6, the formatting code new everything about transaction and accounts, and relied on flags to communicate special details between them. Now the transaction will offer the details for its own reporting, while the formatter worries only about strings and how to output them.
Diffstat (limited to 'walk.h')
-rw-r--r--walk.h26
1 files changed, 3 insertions, 23 deletions
diff --git a/walk.h b/walk.h
index 9024a589..b3bf3098 100644
--- a/walk.h
+++ b/walk.h
@@ -59,15 +59,7 @@ bool compare_items<T>::operator()(const T * left, const T * right)
{
assert(left);
assert(right);
-
- value_t left_result;
- value_t right_result;
-#if 0
- sort_order.compute(left_result, details_t(*left));
- sort_order.compute(right_result, details_t(*right));
-#endif
-
- return left_result < right_result;
+ return sort_order.calc(*left) < sort_order.calc(*right);
}
template <>
@@ -434,14 +426,14 @@ class filter_xacts : public item_handler<xact_t>
public:
filter_xacts(xact_handler_ptr handler,
- const expr_t& predicate)
+ const expr_t& predicate)
: item_handler<xact_t>(handler), pred(predicate) {
TRACE_CTOR(filter_xacts,
"xact_handler_ptr, const value_expr&");
}
filter_xacts(xact_handler_ptr handler,
- const string& predicate)
+ const string& predicate)
: item_handler<xact_t>(handler), pred(predicate) {
TRACE_CTOR(filter_xacts,
"xact_handler_ptr, const string&");
@@ -1031,18 +1023,6 @@ public:
//////////////////////////////////////////////////////////////////////
-#if 0
-inline void clear_journal_xdata(journal_t& journal) {
- clear_xact_xdata xact_cleaner;
- walk_entries(journal.entries, xact_cleaner);
-
- clear_account_xdata acct_cleaner;
- walk_accounts(*journal.master, acct_cleaner);
-}
-#endif
-
-//////////////////////////////////////////////////////////////////////
-
class journals_iterator : public noncopyable
{
ptr_list<journal_t>::iterator journals_i;