summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-02-15 20:56:48 -0400
committerJohn Wiegley <johnw@newartisans.com>2009-02-15 20:56:48 -0400
commit78e57ac4cfe60147051f0a04e82c19174a86f899 (patch)
tree804c42c86374dc4543872b9460886616498780dd
parent5d4ac679201fd45f7a780ca1b7920682db69d62e (diff)
downloadfork-ledger-78e57ac4cfe60147051f0a04e82c19174a86f899.tar.gz
fork-ledger-78e57ac4cfe60147051f0a04e82c19174a86f899.tar.bz2
fork-ledger-78e57ac4cfe60147051f0a04e82c19174a86f899.zip
item_predicate now operates on scope_t
This means item_predicate is no longer a template.
-rw-r--r--src/chain.cc24
-rw-r--r--src/entry.h4
-rw-r--r--src/filters.cc7
-rw-r--r--src/filters.h16
-rw-r--r--src/output.h8
-rw-r--r--src/predicate.h3
-rw-r--r--src/report.cc4
-rw-r--r--src/textual.cc7
8 files changed, 35 insertions, 38 deletions
diff --git a/src/chain.cc b/src/chain.cc
index 84f56761..baf92f64 100644
--- a/src/chain.cc
+++ b/src/chain.cc
@@ -51,8 +51,8 @@ xact_handler_ptr chain_xact_handlers(report_t& report,
// `display_predicate'.
if (report.HANDLED(display_))
handler.reset(new filter_xacts
- (handler, item_predicate<xact_t>(report.HANDLER(display_).str(),
- report.what_to_keep())));
+ (handler, item_predicate(report.HANDLER(display_).str(),
+ report.what_to_keep())));
// calc_xacts computes the running total. When this appears will
// determine, for example, whether filtered xacts are included or excluded
@@ -66,8 +66,8 @@ xact_handler_ptr chain_xact_handlers(report_t& report,
// `secondary_predicate'.
if (report.HANDLED(only_))
handler.reset(new filter_xacts
- (handler, item_predicate<xact_t>
- (report.HANDLER(only_).str(), report.what_to_keep())));
+ (handler, item_predicate(report.HANDLER(only_).str(),
+ report.what_to_keep())));
// sort_xacts will sort all the xacts it sees, based on the `sort_order'
// value expression.
@@ -138,8 +138,8 @@ xact_handler_ptr chain_xact_handlers(report_t& report,
DEBUG("report.predicate",
"Report predicate expression = " << report.HANDLER(limit_).str());
handler.reset(new filter_xacts
- (handler, item_predicate<xact_t>(report.HANDLER(limit_).str(),
- report.what_to_keep())));
+ (handler, item_predicate(report.HANDLER(limit_).str(),
+ report.what_to_keep())));
}
// budget_xacts takes a set of xacts from a data file and uses them to
@@ -161,22 +161,22 @@ xact_handler_ptr chain_xact_handlers(report_t& report,
// the filter get reported.
if (report.HANDLED(limit_))
handler.reset(new filter_xacts
- (handler, item_predicate<xact_t>
- (report.HANDLER(limit_).str(), report.what_to_keep())));
+ (handler, item_predicate(report.HANDLER(limit_).str(),
+ report.what_to_keep())));
}
else if (report.HANDLED(forecast_)) {
forecast_xacts * forecast_handler
= new forecast_xacts(handler,
- item_predicate<xact_t>
- (report.HANDLER(forecast_).str(), report.what_to_keep()));
+ item_predicate(report.HANDLER(forecast_).str(),
+ report.what_to_keep()));
forecast_handler->add_period_entries(report.session.journal->period_entries);
handler.reset(forecast_handler);
// See above, under budget_xacts.
if (report.HANDLED(limit_))
handler.reset(new filter_xacts
- (handler, item_predicate<xact_t>
- (report.HANDLER(limit_).str(), report.what_to_keep())));
+ (handler, item_predicate(report.HANDLER(limit_).str(),
+ report.what_to_keep())));
}
if (report.HANDLED(comm_as_payee))
diff --git a/src/entry.h b/src/entry.h
index ceea6aed..726b0c51 100644
--- a/src/entry.h
+++ b/src/entry.h
@@ -126,7 +126,7 @@ struct entry_finalizer_t {
class auto_entry_t : public entry_base_t
{
public:
- item_predicate<xact_t> predicate;
+ item_predicate predicate;
auto_entry_t() {
TRACE_CTOR(auto_entry_t, "");
@@ -135,7 +135,7 @@ public:
: entry_base_t(), predicate(other.predicate) {
TRACE_CTOR(auto_entry_t, "copy");
}
- auto_entry_t(const item_predicate<xact_t>& _predicate)
+ auto_entry_t(const item_predicate& _predicate)
: predicate(_predicate)
{
TRACE_CTOR(auto_entry_t, "const item_predicate<xact_t>&");
diff --git a/src/filters.cc b/src/filters.cc
index 8e8bf1ec..fc924065 100644
--- a/src/filters.cc
+++ b/src/filters.cc
@@ -787,10 +787,9 @@ void forecast_xacts::flush()
item_handler<xact_t>::flush();
}
-pass_down_accounts::pass_down_accounts
- (acct_handler_ptr handler,
- accounts_iterator& iter,
- const optional<item_predicate<account_t> >& predicate)
+pass_down_accounts::pass_down_accounts(acct_handler_ptr handler,
+ accounts_iterator& iter,
+ const optional<item_predicate>& predicate)
: item_handler<account_t>(handler), pred(predicate)
{
TRACE_CTOR(pass_down_accounts,
diff --git a/src/filters.h b/src/filters.h
index 2adfbbb7..f58080e1 100644
--- a/src/filters.h
+++ b/src/filters.h
@@ -272,13 +272,13 @@ public:
*/
class filter_xacts : public item_handler<xact_t>
{
- item_predicate<xact_t> pred;
+ item_predicate pred;
filter_xacts();
public:
- filter_xacts(xact_handler_ptr handler,
- const item_predicate<xact_t>& predicate)
+ filter_xacts(xact_handler_ptr handler,
+ const item_predicate& predicate)
: item_handler<xact_t>(handler), pred(predicate) {
TRACE_CTOR(filter_xacts,
"xact_handler_ptr, const item_predicate<xact_t>&");
@@ -770,11 +770,11 @@ public:
*/
class forecast_xacts : public generate_xacts
{
- item_predicate<xact_t> pred;
+ item_predicate pred;
public:
- forecast_xacts(xact_handler_ptr handler,
- const item_predicate<xact_t>& predicate)
+ forecast_xacts(xact_handler_ptr handler,
+ const item_predicate& predicate)
: generate_xacts(handler), pred(predicate) {
TRACE_CTOR(forecast_xacts,
"xact_handler_ptr, const item_predicate<xact_t>&");
@@ -817,12 +817,12 @@ class pass_down_accounts : public item_handler<account_t>
{
pass_down_accounts();
- optional<item_predicate<account_t> > pred;
+ optional<item_predicate> pred;
public:
pass_down_accounts(acct_handler_ptr handler,
accounts_iterator& iter,
- const optional<item_predicate<account_t> >& predicate = none);
+ const optional<item_predicate>& predicate = none);
virtual ~pass_down_accounts() {
TRACE_DTOR(pass_down_accounts);
diff --git a/src/output.h b/src/output.h
index f78d2df1..188013c3 100644
--- a/src/output.h
+++ b/src/output.h
@@ -149,10 +149,10 @@ class format_entries : public format_xacts
class format_accounts : public item_handler<account_t>
{
protected:
- report_t& report;
- format_t format;
- item_predicate<account_t> disp_pred;
- bool print_final_total;
+ report_t& report;
+ format_t format;
+ item_predicate disp_pred;
+ bool print_final_total;
bool disp_subaccounts_p(account_t& account, account_t *& to_show);
bool display_account(account_t& account);
diff --git a/src/predicate.h b/src/predicate.h
index dfdcd256..e4cc73a3 100644
--- a/src/predicate.h
+++ b/src/predicate.h
@@ -56,7 +56,6 @@ namespace ledger {
*
* Long.
*/
-template <typename T>
class item_predicate
{
public:
@@ -84,7 +83,7 @@ public:
TRACE_DTOR(item_predicate);
}
- bool operator()(T& item) {
+ bool operator()(scope_t& item) {
return ! predicate || predicate.calc(item).strip_annotations(what_to_keep);
}
};
diff --git a/src/report.cc b/src/report.cc
index 2f60a6ba..aea565ec 100644
--- a/src/report.cc
+++ b/src/report.cc
@@ -128,11 +128,11 @@ void report_t::accounts_report(acct_handler_ptr handler)
if (! HANDLED(sort_)) {
basic_accounts_iterator walker(*session.master);
pass_down_accounts(handler, walker,
- item_predicate<account_t>("total", what_to_keep()));
+ item_predicate("total", what_to_keep()));
} else {
sorted_accounts_iterator walker(*session.master, HANDLER(sort_).str());
pass_down_accounts(handler, walker,
- item_predicate<account_t>("total", what_to_keep()));
+ item_predicate("total", what_to_keep()));
}
session.clean_xacts();
diff --git a/src/textual.cc b/src/textual.cc
index 4c1ed8e8..51011aae 100644
--- a/src/textual.cc
+++ b/src/textual.cc
@@ -519,10 +519,9 @@ void instance_t::automated_entry_directive(char * line)
istream_pos_type pos = curr_pos;
std::size_t lnum = linenum;
- std::auto_ptr<auto_entry_t>
- ae(new auto_entry_t(item_predicate<xact_t>
- (skip_ws(line + 1),
- keep_details_t(true, true, true, true))));
+ std::auto_ptr<auto_entry_t> ae
+ (new auto_entry_t(item_predicate(skip_ws(line + 1),
+ keep_details_t(true, true, true, true))));
if (parse_xacts(account_stack.front(), *ae.get(), "automated")) {
journal.auto_entries.push_back(ae.get());