diff options
Diffstat (limited to 'src/filters.h')
-rw-r--r-- | src/filters.h | 168 |
1 files changed, 155 insertions, 13 deletions
diff --git a/src/filters.h b/src/filters.h index ced51f3f..3f3e3d34 100644 --- a/src/filters.h +++ b/src/filters.h @@ -88,6 +88,11 @@ public: virtual void operator()(post_t& post) { posts.push_back(&post); } + + virtual void clear() { + posts.clear(); + item_handler<post_t>::clear(); + } }; class posts_iterator; @@ -149,27 +154,34 @@ public: virtual void flush(); virtual void operator()(post_t& post); + + virtual void clear() { + completed = false; + posts.clear(); + xacts_seen = 0; + last_xact = NULL; + + item_handler<post_t>::clear(); + } }; class sort_posts : public item_handler<post_t> { typedef std::deque<post_t *> posts_deque; - posts_deque posts; - const expr_t sort_order; + posts_deque posts; + expr_t sort_order; sort_posts(); public: - sort_posts(post_handler_ptr handler, - const expr_t& _sort_order) + sort_posts(post_handler_ptr handler, const expr_t& _sort_order) : item_handler<post_t>(handler), sort_order(_sort_order) { TRACE_CTOR(sort_posts, "post_handler_ptr, const value_expr&"); } - sort_posts(post_handler_ptr handler, - const string& _sort_order) + sort_posts(post_handler_ptr handler, const string& _sort_order) : item_handler<post_t>(handler), sort_order(_sort_order) { TRACE_CTOR(sort_posts, @@ -189,6 +201,13 @@ public: virtual void operator()(post_t& post) { posts.push_back(&post); } + + virtual void clear() { + posts.clear(); + sort_order.mark_uncompiled(); + + item_handler<post_t>::clear(); + } }; class sort_xacts : public item_handler<post_t> @@ -199,14 +218,12 @@ class sort_xacts : public item_handler<post_t> sort_xacts(); public: - sort_xacts(post_handler_ptr handler, - const expr_t& _sort_order) + sort_xacts(post_handler_ptr handler, const expr_t& _sort_order) : sorter(handler, _sort_order) { TRACE_CTOR(sort_xacts, "post_handler_ptr, const value_expr&"); } - sort_xacts(post_handler_ptr handler, - const string& _sort_order) + sort_xacts(post_handler_ptr handler, const string& _sort_order) : sorter(handler, _sort_order) { TRACE_CTOR(sort_xacts, "post_handler_ptr, const string&"); @@ -228,6 +245,13 @@ public: last_xact = post.xact; } + + virtual void clear() { + sorter.clear(); + last_xact = NULL; + + item_handler<post_t>::clear(); + } }; class filter_posts : public item_handler<post_t> @@ -255,6 +279,11 @@ public: (*handler)(post); } } + + virtual void clear() { + pred.mark_uncompiled(); + item_handler<post_t>::clear(); + } }; class anonymize_posts : public item_handler<post_t> @@ -274,6 +303,13 @@ public: } virtual void operator()(post_t& post); + + virtual void clear() { + temps.clear(); + last_xact = NULL; + + item_handler<post_t>::clear(); + } }; class calc_posts : public item_handler<post_t> @@ -297,6 +333,13 @@ public: } virtual void operator()(post_t& post); + + virtual void clear() { + last_post = NULL; + amount_expr.mark_uncompiled(); + + item_handler<post_t>::clear(); + } }; class collapse_posts : public item_handler<post_t> @@ -334,13 +377,29 @@ public: } virtual void flush() { - report_subtotal(); + report_subtotal(); item_handler<post_t>::flush(); } void report_subtotal(); virtual void operator()(post_t& post); + + virtual void clear() { + amount_expr.mark_uncompiled(); + display_predicate.mark_uncompiled(); + only_predicate.mark_uncompiled(); + + subtotal = value_t(); + count = 0; + last_xact = NULL; + last_post = NULL; + + temps.clear(); + component_posts.clear(); + + item_handler<post_t>::clear(); + } }; class related_posts : public item_handler<post_t> @@ -367,6 +426,11 @@ public: post.xdata().add_flags(POST_EXT_RECEIVED); posts.push_back(&post); } + + virtual void clear() { + posts.clear(); + item_handler<post_t>::clear(); + } }; class changed_value_posts : public item_handler<post_t> @@ -410,6 +474,20 @@ public: void output_rounding(post_t& post); virtual void operator()(post_t& post); + + virtual void clear() { + display_amount_expr.mark_uncompiled(); + total_expr.mark_uncompiled(); + display_total_expr.mark_uncompiled(); + + last_post = NULL; + last_total = value_t(); + last_display_total = value_t(); + + temps.clear(); + + item_handler<post_t>::clear(); + } }; class subtotal_posts : public item_handler<post_t> @@ -471,10 +549,20 @@ public: item_handler<post_t>::flush(); } virtual void operator()(post_t& post); + + virtual void clear() { + amount_expr.mark_uncompiled(); + values.clear(); + temps.clear(); + component_posts.clear(); + + item_handler<post_t>::clear(); + } }; class interval_posts : public subtotal_posts { + date_interval_t start_interval; date_interval_t interval; date_interval_t last_interval; post_t * last_post; @@ -491,8 +579,9 @@ public: const date_interval_t& _interval, bool _exact_periods = false, bool _generate_empty_posts = false) - : subtotal_posts(_handler, amount_expr), interval(_interval), - last_post(NULL), empty_account(temps.create_account(_("<None>"))), + : subtotal_posts(_handler, amount_expr), start_interval(_interval), + interval(start_interval), last_post(NULL), + empty_account(temps.create_account(_("<None>"))), exact_periods(_exact_periods), generate_empty_posts(_generate_empty_posts) { TRACE_CTOR(interval_posts, @@ -512,6 +601,14 @@ public: } } virtual void operator()(post_t& post); + + virtual void clear() { + interval = start_interval; + last_interval = date_interval_t(); + last_post = NULL; + + item_handler<post_t>::clear(); + } }; class posts_as_equity : public subtotal_posts @@ -539,6 +636,11 @@ public: report_subtotal(); subtotal_posts::flush(); } + + virtual void clear() { + last_post = NULL; + item_handler<post_t>::clear(); + } }; class by_payee_posts : public item_handler<post_t> @@ -562,6 +664,13 @@ class by_payee_posts : public item_handler<post_t> virtual void flush(); virtual void operator()(post_t& post); + + virtual void clear() { + amount_expr.mark_uncompiled(); + payee_subtotals.clear(); + + item_handler<post_t>::clear(); + } }; class transfer_details : public item_handler<post_t> @@ -595,6 +704,13 @@ public: } virtual void operator()(post_t& post); + + virtual void clear() { + expr.mark_uncompiled(); + temps.clear(); + + item_handler<post_t>::clear(); + } }; class dow_posts : public subtotal_posts @@ -616,6 +732,13 @@ public: virtual void operator()(post_t& post) { days_of_the_week[post.date().day_of_week()].push_back(&post); } + + virtual void clear() { + for (int i = 0; i < 7; i++) + days_of_the_week[i].clear(); + + item_handler<post_t>::clear(); + } }; class generate_posts : public item_handler<post_t> @@ -642,6 +765,13 @@ public: void add_period_xacts(period_xacts_list& period_xacts); virtual void add_post(const date_interval_t& period, post_t& post); + + virtual void clear() { + pending_posts.clear(); + temps.clear(); + + item_handler<post_t>::clear(); + } }; class budget_posts : public generate_posts @@ -692,6 +822,11 @@ class forecast_posts : public generate_posts virtual void add_post(const date_interval_t& period, post_t& post); virtual void flush(); + + virtual void clear() { + pred.mark_uncompiled(); + item_handler<post_t>::clear(); + } }; ////////////////////////////////////////////////////////////////////// @@ -717,6 +852,13 @@ public: virtual ~pass_down_accounts() { TRACE_DTOR(pass_down_accounts); } + + virtual void clear() { + if (pred) + pred->mark_uncompiled(); + + item_handler<account_t>::clear(); + } }; } // namespace ledger |