item_predicate now operates on scope_t
This means item_predicate is no longer a template.
This commit is contained in:
parent
5d4ac67920
commit
78e57ac4cf
8 changed files with 35 additions and 38 deletions
24
src/chain.cc
24
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))
|
||||
|
|
|
|||
|
|
@ -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>&");
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue