From ee7f5395e68f090a449f2ccbcaade3238df1d679 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Thu, 30 Jun 2011 09:25:35 -0500 Subject: Added two missing calls to clear() --- src/filters.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/filters.h') diff --git a/src/filters.h b/src/filters.h index 2916857d..227245fb 100644 --- a/src/filters.h +++ b/src/filters.h @@ -97,6 +97,7 @@ public: virtual void clear() { posts_map.clear(); post_chain->clear(); + item_handler::clear(); } }; @@ -365,6 +366,7 @@ public: virtual void clear() { temps.clear(); + comms.clear(); last_xact = NULL; item_handler::clear(); -- cgit v1.2.3 From d0dfff62a6a3a685f19a5bed8716f7b661dc8c60 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Sun, 17 Jul 2011 16:25:05 -0500 Subject: Changed how some of the filters are constructed --- src/filters.cc | 23 ++++++++++------------- src/filters.h | 4 ++-- 2 files changed, 12 insertions(+), 15 deletions(-) (limited to 'src/filters.h') diff --git a/src/filters.cc b/src/filters.cc index 686bef3f..27227ee9 100644 --- a/src/filters.cc +++ b/src/filters.cc @@ -524,14 +524,11 @@ display_filter_posts::display_filter_posts(post_handler_ptr handler, report_t& _report, bool _show_rounding) : item_handler(handler), report(_report), + display_amount_expr(report.HANDLER(display_amount_).expr), + display_total_expr(report.HANDLER(display_total_).expr), show_rounding(_show_rounding) { - TRACE_CTOR(display_filter_posts, - "post_handler_ptr, report_t&, account_t&, bool"); - - display_amount_expr = report.HANDLER(display_amount_).expr; - display_total_expr = report.HANDLER(display_total_).expr; - + TRACE_CTOR(display_filter_posts, "post_handler_ptr, report_t&, bool"); create_accounts(); } @@ -607,17 +604,17 @@ changed_value_posts::changed_value_posts bool _show_unrealized, display_filter_posts * _display_filter) : item_handler(handler), report(_report), + total_expr(report.HANDLED(revalued_total_) ? + report.HANDLER(revalued_total_).expr : + report.HANDLER(display_total_).expr), + display_total_expr(report.HANDLER(display_total_).expr), + changed_values_only(report.HANDLED(revalued_only)), for_accounts_report(_for_accounts_report), show_unrealized(_show_unrealized), last_post(NULL), display_filter(_display_filter) { - TRACE_CTOR(changed_value_posts, "post_handler_ptr, report_t&, bool"); - - total_expr = (report.HANDLED(revalued_total_) ? - report.HANDLER(revalued_total_).expr : - report.HANDLER(display_total_).expr); - display_total_expr = report.HANDLER(display_total_).expr; - changed_values_only = report.HANDLED(revalued_only); + TRACE_CTOR(changed_value_posts, + "post_handler_ptr, report_t&, bool, bool, display_filter_posts *"); string gains_equity_account_name; if (report.HANDLED(unrealized_gains_)) diff --git a/src/filters.h b/src/filters.h index 227245fb..2fcf0961 100644 --- a/src/filters.h +++ b/src/filters.h @@ -506,9 +506,9 @@ class display_filter_posts : public item_handler // This filter requires that calc_posts be used at some point // later in the chain. + report_t& report; expr_t display_amount_expr; expr_t display_total_expr; - report_t& report; bool show_rounding; value_t last_display_total; temporaries_t temps; @@ -554,9 +554,9 @@ class changed_value_posts : public item_handler // This filter requires that calc_posts be used at some point // later in the chain. + report_t& report; expr_t total_expr; expr_t display_total_expr; - report_t& report; bool changed_values_only; bool for_accounts_report; bool show_unrealized; -- cgit v1.2.3 From cf35984971341b8a8688eb02a22bcbc1772991d1 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Tue, 19 Jul 2011 23:29:41 -0500 Subject: Use Boost iterator_facade to create new iterators --- src/convert.cc | 6 +-- src/filters.cc | 40 -------------------- src/filters.h | 42 +++++++++++++++++---- src/generate.cc | 10 +++-- src/generate.h | 6 ++- src/iterators.cc | 111 +++++++++++++++++++++++++++--------------------------- src/iterators.h | 110 ++++++++++++++++++++++++++++++++++++----------------- src/py_journal.cc | 2 +- src/report.cc | 49 ++++++++++++++---------- src/system.hh.in | 1 + 10 files changed, 211 insertions(+), 166 deletions(-) (limited to 'src/filters.h') diff --git a/src/convert.cc b/src/convert.cc index 3a9a143d..5d4925c4 100644 --- a/src/convert.cc +++ b/src/convert.cc @@ -62,10 +62,10 @@ value_t convert_command(call_scope_t& args) post_map_t post_map; xacts_iterator journal_iter(journal); - while (xact_t * xact = journal_iter()) { + while (xact_t * xact = *journal_iter++) { post_t * post = NULL; xact_posts_iterator xact_iter(*xact); - while ((post = xact_iter()) != NULL) { + while ((post = *xact_iter++) != NULL) { if (post->account == bucket) break; } @@ -137,7 +137,7 @@ value_t convert_command(call_scope_t& args) } else { xact_posts_iterator xact_iter(*xact); - while (post_t * post = xact_iter()) + while (post_t * post = *xact_iter++) formatter(*post); } } diff --git a/src/filters.cc b/src/filters.cc index 27227ee9..b7e96366 100644 --- a/src/filters.cc +++ b/src/filters.cc @@ -83,25 +83,6 @@ void post_splitter::operator()(post_t& post) } } -pass_down_posts::pass_down_posts(post_handler_ptr handler, - posts_iterator& iter) - : item_handler(handler) -{ - TRACE_CTOR(pass_down_posts, "post_handler_ptr, posts_iterator"); - - for (post_t * post = iter(); post; post = iter()) { - try { - item_handler::operator()(*post); - } - catch (const std::exception&) { - add_error_context(item_context(*post, _("While handling posting"))); - throw; - } - } - - item_handler::flush(); -} - void truncate_xacts::flush() { if (! posts.size()) @@ -1419,25 +1400,4 @@ void inject_posts::operator()(post_t& post) item_handler::operator()(post); } -pass_down_accounts::pass_down_accounts(acct_handler_ptr handler, - accounts_iterator& iter, - const optional& _pred, - const optional& _context) - : item_handler(handler), pred(_pred), context(_context) -{ - TRACE_CTOR(pass_down_accounts, "acct_handler_ptr, accounts_iterator, ..."); - - for (account_t * account = iter(); account; account = iter()) { - if (! pred) { - item_handler::operator()(*account); - } else { - bind_scope_t bound_scope(*context, *account); - if ((*pred)(bound_scope)) - item_handler::operator()(*account); - } - } - - item_handler::flush(); -} - } // namespace ledger diff --git a/src/filters.h b/src/filters.h index 2fcf0961..4c096571 100644 --- a/src/filters.h +++ b/src/filters.h @@ -146,14 +146,28 @@ public: } }; -class posts_iterator; - +template class pass_down_posts : public item_handler { pass_down_posts(); public: - pass_down_posts(post_handler_ptr handler, posts_iterator& iter); + pass_down_posts(post_handler_ptr handler, Iterator& iter) + : item_handler(handler) { + TRACE_CTOR(pass_down_posts, "post_handler_ptr, posts_iterator"); + + while (post_t * post = *iter++) { + try { + item_handler::operator()(*post); + } + catch (const std::exception&) { + add_error_context(item_context(*post, _("While handling posting"))); + throw; + } + } + + item_handler::flush(); + } virtual ~pass_down_posts() { TRACE_DTOR(pass_down_posts); @@ -986,8 +1000,7 @@ class inject_posts : public item_handler // Account filters // -class accounts_iterator; - +template class pass_down_accounts : public item_handler { pass_down_accounts(); @@ -997,9 +1010,24 @@ class pass_down_accounts : public item_handler public: pass_down_accounts(acct_handler_ptr handler, - accounts_iterator& iter, + Iterator& iter, const optional& _pred = none, - const optional& _context = none); + const optional& _context = none) + : item_handler(handler), pred(_pred), context(_context) { + TRACE_CTOR(pass_down_accounts, "acct_handler_ptr, accounts_iterator, ..."); + + while (account_t * account = *iter++) { + if (! pred) { + item_handler::operator()(*account); + } else { + bind_scope_t bound_scope(*context, *account); + if ((*pred)(bound_scope)) + item_handler::operator()(*account); + } + } + + item_handler::flush(); + } virtual ~pass_down_accounts() { TRACE_DTOR(pass_down_accounts); diff --git a/src/generate.cc b/src/generate.cc index 05f754e6..60c6955e 100644 --- a/src/generate.cc +++ b/src/generate.cc @@ -350,9 +350,10 @@ void generate_posts_iterator::generate_xact(std::ostream& out) out << '\n'; } -post_t * generate_posts_iterator::operator()() +void generate_posts_iterator::increment() { - post_t * post = posts(); + post_t * post = *posts++; + if (post == NULL && quantity > 0) { std::ostringstream buf; generate_xact(buf); @@ -364,7 +365,7 @@ post_t * generate_posts_iterator::operator()() if (session.journal->parse(in, session) != 0) { VERIFY(session.journal->xacts.back()->valid()); posts.reset(*session.journal->xacts.back()); - post = posts(); + post = *posts++; } } catch (std::exception&) { @@ -382,7 +383,8 @@ post_t * generate_posts_iterator::operator()() quantity--; } - return post; + + m_node = post; } } // namespace ledger diff --git a/src/generate.h b/src/generate.h index 25ad41ea..f9207ff5 100644 --- a/src/generate.h +++ b/src/generate.h @@ -48,7 +48,9 @@ namespace ledger { class session_t; -class generate_posts_iterator : public posts_iterator +class generate_posts_iterator + : public iterator_facade_base { session_t& session; unsigned int seed; @@ -105,7 +107,7 @@ public: TRACE_DTOR(generate_posts_iterator); } - virtual post_t * operator()(); + virtual void increment(); protected: void generate_string(std::ostream& out, int len, bool only_alpha = false); diff --git a/src/iterators.cc b/src/iterators.cc index b63a10e9..bb7a587c 100644 --- a/src/iterators.cc +++ b/src/iterators.cc @@ -41,37 +41,38 @@ void xacts_iterator::reset(journal_t& journal) { xacts_i = journal.xacts.begin(); xacts_end = journal.xacts.end(); + xacts_uninitialized = false; + + increment(); } -xact_t * xacts_iterator::operator()() +void xacts_iterator::increment() { if (xacts_i != xacts_end) - return *xacts_i++; + m_node = *xacts_i++; else - return NULL; + m_node = NULL; } void journal_posts_iterator::reset(journal_t& journal) { xacts.reset(journal); - - xact_t * xact = xacts(); - if (xact != NULL) - posts.reset(*xact); + increment(); } -post_t * journal_posts_iterator::operator()() +void journal_posts_iterator::increment() { - post_t * post = posts(); - if (post == NULL) { - xact_t * xact = xacts(); - if (xact != NULL) { - posts.reset(*xact); - post = posts(); - } + if (post_t * post = *posts++) { + m_node = post; + } + else if (xact_t * xact = *xacts++) { + posts.reset(*xact); + m_node = *posts++; + } + else { + m_node = NULL; } - return post; } void posts_commodities_iterator::reset(journal_t& journal) @@ -80,7 +81,7 @@ void posts_commodities_iterator::reset(journal_t& journal) std::set commodities; - for (post_t * post = journal_posts(); post; post = journal_posts()) { + while (const post_t * post = *journal_posts++) { commodity_t& comm(post->amount.commodity()); if (comm.flags() & COMMODITY_NOMARKET) continue; @@ -136,47 +137,44 @@ void posts_commodities_iterator::reset(journal_t& journal) } } - xacts.xacts_i = xact_temps.begin(); - xacts.xacts_end = xact_temps.end(); + xacts.reset(xact_temps.begin(), xact_temps.end()); - xacts.xacts_uninitialized = false; - - xact_t * xact = xacts(); - if (xact != NULL) - posts.reset(*xact); + increment(); } -post_t * posts_commodities_iterator::operator()() +void posts_commodities_iterator::increment() { - post_t * post = posts(); - if (post == NULL) { - xact_t * xact = xacts(); - if (xact != NULL) { - posts.reset(*xact); - post = posts(); - } + if (post_t * post = *posts++) { + m_node = post; + } + else if (xact_t * xact = *xacts++) { + posts.reset(*xact); + m_node = *posts++; + } + else { + m_node = NULL; } - return post; } -account_t * basic_accounts_iterator::operator()() +void basic_accounts_iterator::increment() { - while (! accounts_i.empty() && - accounts_i.back() == accounts_end.back()) { + while (! accounts_i.empty() && accounts_i.back() == accounts_end.back()) { accounts_i.pop_back(); accounts_end.pop_back(); } - if (accounts_i.empty()) - return NULL; - account_t * account = (*(accounts_i.back()++)).second; - assert(account); + if (accounts_i.empty()) { + m_node = NULL; + } else { + account_t * account = (*(accounts_i.back()++)).second; + assert(account); - // If this account has children, queue them up to be iterated next. - if (! account->accounts.empty()) - push_back(*account); + // If this account has children, queue them up to be iterated next. + if (! account->accounts.empty()) + push_back(*account); - return account; + m_node = account; + } } void sorted_accounts_iterator::push_back(account_t& account) @@ -231,7 +229,7 @@ void sorted_accounts_iterator::sort_accounts(account_t& account, #endif } -account_t * sorted_accounts_iterator::operator()() +void sorted_accounts_iterator::increment() { while (! sorted_accounts_i.empty() && sorted_accounts_i.back() == sorted_accounts_end.back()) { @@ -240,19 +238,22 @@ account_t * sorted_accounts_iterator::operator()() assert(! accounts_list.empty()); accounts_list.pop_back(); } - if (sorted_accounts_i.empty()) - return NULL; - account_t * account = *sorted_accounts_i.back()++; - assert(account); + if (sorted_accounts_i.empty()) { + m_node = NULL; + } else { + account_t * account = *sorted_accounts_i.back()++; + assert(account); + + // If this account has children, queue them up to be iterated next. + if (! flatten_all && ! account->accounts.empty()) + push_back(*account); - // If this account has children, queue them up to be iterated next. - if (! flatten_all && ! account->accounts.empty()) - push_back(*account); + // Make sure the sorting value gets recalculated for this account + account->xdata().drop_flags(ACCOUNT_EXT_SORT_CALC); - // Make sure the sorting value gets recalculated for this account - account->xdata().drop_flags(ACCOUNT_EXT_SORT_CALC); - return account; + m_node = account; + } } } // namespace ledger diff --git a/src/iterators.h b/src/iterators.h index 5113d3b2..696b5911 100644 --- a/src/iterators.h +++ b/src/iterators.h @@ -51,14 +51,35 @@ namespace ledger { class journal_t; -class posts_iterator : public noncopyable +template +class iterator_facade_base + : public boost::iterator_facade { + typedef Value node_base; + public: - virtual ~posts_iterator() throw() {} - virtual post_t * operator()() = 0; + iterator_facade_base() : m_node(NULL) {} + + explicit iterator_facade_base(node_base p) : m_node(p) {} + + void increment(); + +private: + friend class boost::iterator_core_access; + + bool equal(iterator_facade_base const& other) const { + return this->m_node == other.m_node; + } + + node_base& dereference() const { return const_cast(m_node); } + +protected: + node_base m_node; }; -class xact_posts_iterator : public posts_iterator +class xact_posts_iterator + : public iterator_facade_base { posts_list::iterator posts_i; posts_list::iterator posts_end; @@ -74,7 +95,7 @@ public: TRACE_CTOR(xact_posts_iterator, "xact_t&"); reset(xact); } - virtual ~xact_posts_iterator() throw() { + ~xact_posts_iterator() throw() { TRACE_DTOR(xact_posts_iterator); } @@ -83,16 +104,21 @@ public: posts_end = xact.posts.end(); posts_uninitialized = false; + + increment(); } - virtual post_t * operator()() { + void increment() { if (posts_uninitialized || posts_i == posts_end) - return NULL; - return *posts_i++; + m_node = NULL; + else + m_node = *posts_i++; } }; -class xacts_iterator : public noncopyable +class xacts_iterator + : public iterator_facade_base { public: xacts_list::iterator xacts_i; @@ -103,22 +129,35 @@ public: xacts_iterator() : xacts_uninitialized(true) { TRACE_CTOR(xacts_iterator, ""); } - xacts_iterator(journal_t& journal) : xacts_uninitialized(true) { + xacts_iterator(journal_t& journal) : xacts_uninitialized(false) { TRACE_CTOR(xacts_iterator, "journal_t&"); reset(journal); } - virtual ~xacts_iterator() throw() { + xacts_iterator(xacts_list::iterator beg, + xacts_list::iterator end) : xacts_uninitialized(false) { + TRACE_CTOR(xacts_iterator, "xacts_list::iterator, xacts_list::iterator"); + reset(beg, end); + } + ~xacts_iterator() throw() { TRACE_DTOR(xacts_iterator); } void reset(journal_t& journal); - xact_t * operator()(); + void reset(xacts_list::iterator beg, xacts_list::iterator end) { + xacts_i = beg; + xacts_end = end; + increment(); + } + + void increment(); }; -class journal_posts_iterator : public posts_iterator +class journal_posts_iterator + : public iterator_facade_base { - xacts_iterator xacts; + xacts_iterator xacts; xact_posts_iterator posts; public: @@ -129,16 +168,18 @@ public: TRACE_CTOR(journal_posts_iterator, "journal_t&"); reset(journal); } - virtual ~journal_posts_iterator() throw() { + ~journal_posts_iterator() throw() { TRACE_DTOR(journal_posts_iterator); } void reset(journal_t& journal); - virtual post_t * operator()(); + void increment(); }; -class posts_commodities_iterator : public posts_iterator +class posts_commodities_iterator + : public iterator_facade_base { protected: journal_posts_iterator journal_posts; @@ -155,23 +196,18 @@ public: TRACE_CTOR(posts_commodities_iterator, "journal_t&"); reset(journal); } - virtual ~posts_commodities_iterator() throw() { + ~posts_commodities_iterator() throw() { TRACE_DTOR(posts_commodities_iterator); } void reset(journal_t& journal); - virtual post_t * operator()(); -}; - -class accounts_iterator : public noncopyable -{ -public: - virtual ~accounts_iterator() throw() {} - virtual account_t * operator()() = 0; + void increment(); }; -class basic_accounts_iterator : public accounts_iterator +class basic_accounts_iterator + : public iterator_facade_base { std::list accounts_i; std::list accounts_end; @@ -183,20 +219,24 @@ public: basic_accounts_iterator(account_t& account) { TRACE_CTOR(basic_accounts_iterator, "account_t&"); push_back(account); + increment(); } - virtual ~basic_accounts_iterator() throw() { + ~basic_accounts_iterator() throw() { TRACE_DTOR(basic_accounts_iterator); } + void increment(); + +private: void push_back(account_t& account) { accounts_i.push_back(account.accounts.begin()); accounts_end.push_back(account.accounts.end()); } - - virtual account_t * operator()(); }; -class sorted_accounts_iterator : public accounts_iterator +class sorted_accounts_iterator + : public iterator_facade_base { expr_t sort_cmp; bool flatten_all; @@ -213,16 +253,18 @@ public: : sort_cmp(_sort_cmp), flatten_all(_flatten_all) { TRACE_CTOR(sorted_accounts_iterator, "const expr_t&, bool, account_t&"); push_back(account); + increment(); } - virtual ~sorted_accounts_iterator() throw() { + ~sorted_accounts_iterator() throw() { TRACE_DTOR(sorted_accounts_iterator); } + void increment(); + +private: void push_back(account_t& account); void push_all(account_t& account, accounts_deque_t& deque); void sort_accounts(account_t& account, accounts_deque_t& deque); - - virtual account_t * operator()(); }; } // namespace ledger diff --git a/src/py_journal.cc b/src/py_journal.cc index a06ef8e2..cb629f62 100644 --- a/src/py_journal.cc +++ b/src/py_journal.cc @@ -191,7 +191,7 @@ namespace { coll->chain = chain_post_handlers(post_handler_ptr(coll->posts_collector), coll->report); - pass_down_posts(coll->chain, walker); + pass_down_posts(coll->chain, walker); } catch (...) { current_report.session.journal.release(); diff --git a/src/report.cc b/src/report.cc index 5fff77c7..91b9025d 100644 --- a/src/report.cc +++ b/src/report.cc @@ -318,7 +318,7 @@ void report_t::posts_report(post_handler_ptr handler) handler = chain_pre_post_handlers(handler, *this); journal_posts_iterator walker(*session.journal.get()); - pass_down_posts(handler, walker); + pass_down_posts(handler, walker); if (! HANDLED(group_by_)) posts_flusher(handler, *this)(value_t()); @@ -334,7 +334,7 @@ void report_t::generate_report(post_handler_ptr handler) HANDLED(head_) ? static_cast(HANDLER(head_).value.to_long()) : 50); - pass_down_posts(handler, walker); + pass_down_posts(handler, walker); } void report_t::xact_report(post_handler_ptr handler, xact_t& xact) @@ -342,7 +342,7 @@ void report_t::xact_report(post_handler_ptr handler, xact_t& xact) handler = chain_handlers(handler, *this); xact_posts_iterator walker(xact); - pass_down_posts(handler, walker); + pass_down_posts(handler, walker); xact.clear_xdata(); } @@ -382,25 +382,34 @@ namespace { report.HANDLER(display_total_).expr.mark_uncompiled(); report.HANDLER(revalued_total_).expr.mark_uncompiled(); - scoped_ptr iter; - if (! report.HANDLED(sort_)) { - iter.reset(new basic_accounts_iterator(*report.session.journal->master)); - } else { - expr_t sort_expr(report.HANDLER(sort_).str()); - sort_expr.set_context(&report); - iter.reset(new sorted_accounts_iterator(*report.session.journal->master, - sort_expr, report.HANDLED(flat))); - } - if (report.HANDLED(display_)) { DEBUG("report.predicate", "Display predicate = " << report.HANDLER(display_).str()); - pass_down_accounts(handler, *iter.get(), - predicate_t(report.HANDLER(display_).str(), - report.what_to_keep()), - report); + if (! report.HANDLED(sort_)) { + basic_accounts_iterator iter(*report.session.journal->master); + pass_down_accounts + (handler, iter, predicate_t(report.HANDLER(display_).str(), + report.what_to_keep()), report); + } else { + expr_t sort_expr(report.HANDLER(sort_).str()); + sort_expr.set_context(&report); + sorted_accounts_iterator iter(*report.session.journal->master, + sort_expr, report.HANDLED(flat)); + pass_down_accounts + (handler, iter, predicate_t(report.HANDLER(display_).str(), + report.what_to_keep()), report); + } } else { - pass_down_accounts(handler, *iter.get()); + if (! report.HANDLED(sort_)) { + basic_accounts_iterator iter(*report.session.journal->master); + pass_down_accounts(handler, iter); + } else { + expr_t sort_expr(report.HANDLER(sort_).str()); + sort_expr.set_context(&report); + sorted_accounts_iterator iter(*report.session.journal->master, + sort_expr, report.HANDLED(flat)); + pass_down_accounts(handler, iter); + } } report.session.journal->clear_xdata(); @@ -428,7 +437,7 @@ void report_t::accounts_report(acct_handler_ptr handler) // objects created within it during the call to pass_down_posts, which will // be needed later by the pass_down_accounts. journal_posts_iterator walker(*session.journal.get()); - pass_down_posts(chain, walker); + pass_down_posts(chain, walker); if (! HANDLED(group_by_)) accounts_flusher(handler, *this)(value_t()); @@ -439,7 +448,7 @@ void report_t::commodities_report(post_handler_ptr handler) handler = chain_handlers(handler, *this); posts_commodities_iterator walker(*session.journal.get()); - pass_down_posts(handler, walker); + pass_down_posts(handler, walker); session.journal->clear_xdata(); } diff --git a/src/system.hh.in b/src/system.hh.in index f71dce68..2077d3a8 100644 --- a/src/system.hh.in +++ b/src/system.hh.in @@ -158,6 +158,7 @@ typedef std::ostream::pos_type ostream_pos_type; #include #define BOOST_IOSTREAMS_USE_DEPRECATED 1 #include +#include #include #include #include -- cgit v1.2.3 From f0791bbd7297e737d9e13d0b0bb21473b173b2a7 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Thu, 18 Aug 2011 14:48:38 -0400 Subject: Cleanup whitespace --- src/account.cc | 2 +- src/amount.cc | 2 +- src/amount.h | 4 ++-- src/commodity.cc | 4 ++-- src/commodity.h | 2 +- src/compare.h | 2 +- src/convert.cc | 2 +- src/csv.cc | 2 +- src/error.cc | 4 ++-- src/exprbase.h | 2 +- src/filters.cc | 6 +++--- src/filters.h | 12 ++++++------ src/generate.cc | 4 ++-- src/generate.h | 2 +- src/item.cc | 2 +- src/journal.cc | 2 +- src/lookup.cc | 2 +- src/op.cc | 2 +- src/option.cc | 4 ++-- src/option.h | 2 +- src/pool.cc | 2 +- src/post.cc | 4 ++-- src/pstream.h | 2 +- src/py_balance.cc | 2 +- src/py_commodity.cc | 2 +- src/py_xact.cc | 2 +- src/pyinterp.cc | 10 +++++----- src/pyinterp.h | 2 +- src/pyutils.h | 2 +- src/query.cc | 4 ++-- src/report.cc | 2 +- src/report.h | 4 ++-- src/scope.h | 2 +- src/session.cc | 2 +- src/system.hh.in | 2 +- src/textual.cc | 10 +++++----- src/times.cc | 2 +- src/times.h | 4 ++-- src/value.cc | 2 +- src/value.h | 2 +- src/xact.cc | 6 +++--- src/xact.h | 2 +- tools/configure.ac | 4 ++-- 43 files changed, 70 insertions(+), 70 deletions(-) (limited to 'src/filters.h') diff --git a/src/account.cc b/src/account.cc index 3e0ad086..36070a52 100644 --- a/src/account.cc +++ b/src/account.cc @@ -45,7 +45,7 @@ account_t::~account_t() if (! pair.second->has_flags(ACCOUNT_TEMP) || has_flags(ACCOUNT_TEMP)) { checked_delete(pair.second); - } + } } } diff --git a/src/amount.cc b/src/amount.cc index bc7e9918..808f118d 100644 --- a/src/amount.cc +++ b/src/amount.cc @@ -152,7 +152,7 @@ namespace { if (mpfr_asprintf(&buf, "%.*RNf", precision, tempfb) < 0) throw_(amount_error, _("Cannot output amount to a floating-point representation")); - + DEBUG("amount.convert", "mpfr_print = " << buf << " (precision " << precision << ", zeros_prec " << zeros_prec << ")"); diff --git a/src/amount.h b/src/amount.h index 8a2ebf04..f7e877a7 100644 --- a/src/amount.h +++ b/src/amount.h @@ -349,7 +349,7 @@ public: return temp; } void in_place_truncate(); - + /** Yields an amount which has lost all of its extra precision, beyond what the display precision of the commodity would have printed. */ amount_t floored() const { @@ -358,7 +358,7 @@ public: return temp; } void in_place_floor(); - + /** Yields an amount whose display precision is never truncated, even though its commodity normally displays only rounded values. */ amount_t unrounded() const { diff --git a/src/commodity.cc b/src/commodity.cc index f8a4b364..5685059d 100644 --- a/src/commodity.cc +++ b/src/commodity.cc @@ -444,7 +444,7 @@ commodity_t::find_price(const optional& commodity, return point; } return none; -} +} optional commodity_t::check_for_updated_price(const optional& point, @@ -758,7 +758,7 @@ void to_xml(std::ostream& out, const commodity_t& comm, out << '"'; x.close_attrs(); - + { push_xml y(out, "symbol"); out << y.guard(comm.symbol()); diff --git a/src/commodity.h b/src/commodity.h index fcd26da0..d7747b2a 100644 --- a/src/commodity.h +++ b/src/commodity.h @@ -376,7 +376,7 @@ public: #if defined(DEBUG_ON) , const int indent = 0 #endif - ) const; + ) const; optional check_for_updated_price(const optional& point, diff --git a/src/compare.h b/src/compare.h index 0ba9d424..0e7bf5e5 100644 --- a/src/compare.h +++ b/src/compare.h @@ -58,7 +58,7 @@ class compare_items expr_t sort_order; compare_items(); - + public: compare_items(const compare_items& other) : sort_order(other.sort_order) { TRACE_CTOR(compare_items, "copy"); diff --git a/src/convert.cc b/src/convert.cc index 5d4925c4..493fbb7a 100644 --- a/src/convert.cc +++ b/src/convert.cc @@ -95,7 +95,7 @@ value_t convert_command(call_scope_t& args) foreach (post_t * post, xact->posts) post->amount.in_place_negate(); } - + bool matched = false; if (! xact->posts.front()->amount.is_null()) { post_map_t::iterator i = post_map.find(- xact->posts.front()->amount); diff --git a/src/csv.cc b/src/csv.cc index dd5ca935..f673033b 100644 --- a/src/csv.cc +++ b/src/csv.cc @@ -289,7 +289,7 @@ xact_t * csv_reader::read_xact(journal_t& journal, account_t * bucket) amt.set_commodity(*commodity_pool_t::current_pool->default_commodity); post->assigned_amount = amt; } - + xact->add_post(post.release()); return xact.release(); diff --git a/src/error.cc b/src/error.cc index 02413ef6..542d12b9 100644 --- a/src/error.cc +++ b/src/error.cc @@ -93,10 +93,10 @@ string source_context(const path& file, assert(len < 8192); std::ostringstream out; - + ifstream in(file); in.seekg(pos, std::ios::beg); - + scoped_array buf(new char[static_cast(len) + 1]); in.read(buf.get(), static_cast(len)); assert(in.gcount() == static_cast(len)); diff --git a/src/exprbase.h b/src/exprbase.h index 83ef34ff..d86ee14c 100644 --- a/src/exprbase.h +++ b/src/exprbase.h @@ -130,7 +130,7 @@ public: const optional& original_string = none) { set_text(original_string ? *original_string : ""); } - + virtual void mark_uncompiled() { compiled = false; } diff --git a/src/filters.cc b/src/filters.cc index a08e5d25..5bad0414 100644 --- a/src/filters.cc +++ b/src/filters.cc @@ -53,7 +53,7 @@ void post_splitter::flush() { foreach (value_to_posts_map::value_type& pair, posts_map) { preflush_func(pair.first); - + foreach (post_t * post, pair.second) (*post_chain)(*post); @@ -415,7 +415,7 @@ void collapse_posts::report_subtotal() bind_scope_t bound_scope(report, *post); if (only_predicate(bound_scope) && display_predicate(bound_scope)) displayed_count++; - } + } if (displayed_count == 1) { item_handler::operator()(*last_post); @@ -734,7 +734,7 @@ void changed_value_posts::output_intermediate_prices(post_t& post, case value_t::DATE: default: assert(false); - break; + break; } bind_scope_t inner_scope(report, temp); diff --git a/src/filters.h b/src/filters.h index 4c096571..e7a2eefa 100644 --- a/src/filters.h +++ b/src/filters.h @@ -73,10 +73,10 @@ public: post_splitter(post_handler_ptr _post_chain, report_t& _report, expr_t _group_by_expr) - : post_chain(_post_chain), report(_report), + : post_chain(_post_chain), report(_report), group_by_expr(_group_by_expr) { TRACE_CTOR(post_splitter, "scope_t&, post_handler_ptr, expr_t"); - preflush_func = bind(&post_splitter::print_title, this, _1); + preflush_func = bind(&post_splitter::print_title, this, _1); } virtual ~post_splitter() { TRACE_DTOR(post_splitter); @@ -310,7 +310,7 @@ public: virtual void clear() { sorter.clear(); last_xact = NULL; - + item_handler::clear(); } }; @@ -382,7 +382,7 @@ public: temps.clear(); comms.clear(); last_xact = NULL; - + item_handler::clear(); } }; @@ -458,7 +458,7 @@ public: } virtual void flush() { - report_subtotal(); + report_subtotal(); item_handler::flush(); } @@ -479,7 +479,7 @@ public: temps.clear(); create_accounts(); component_posts.clear(); - + item_handler::clear(); } }; diff --git a/src/generate.cc b/src/generate.cc index 60c6955e..185e23e7 100644 --- a/src/generate.cc +++ b/src/generate.cc @@ -271,14 +271,14 @@ void generate_posts_iterator::generate_date(std::ostream& out) out.width(4); out.fill('0'); out << year_gen(); - + out.width(1); out << '/'; out.width(2); out.fill('0'); out << mon_gen(); - + out.width(1); out << '/'; diff --git a/src/generate.h b/src/generate.h index f9207ff5..47abcd94 100644 --- a/src/generate.h +++ b/src/generate.h @@ -106,7 +106,7 @@ public: virtual ~generate_posts_iterator() throw() { TRACE_DTOR(generate_posts_iterator); } - + virtual void increment(); protected: diff --git a/src/item.cc b/src/item.cc index 9a9ab833..7e7cda0d 100644 --- a/src/item.cc +++ b/src/item.cc @@ -535,7 +535,7 @@ string item_context(const item_t& item, const string& desc) assert(len < 8192); std::ostringstream out; - + if (item.pos->pathname == path("/dev/stdin")) { out << desc << _(" from standard input:"); return out.str(); diff --git a/src/journal.cc b/src/journal.cc index fd6d3eac..2a9adeeb 100644 --- a/src/journal.cc +++ b/src/journal.cc @@ -74,7 +74,7 @@ journal_t::~journal_t() foreach (period_xact_t * xact, period_xacts) checked_delete(xact); - + checked_delete(master); } diff --git a/src/lookup.cc b/src/lookup.cc index 28007d9a..452727d6 100644 --- a/src/lookup.cc +++ b/src/lookup.cc @@ -92,7 +92,7 @@ lookup_probable_account(const string& ident, if ((CURRENT_DATE() - xact->date()).days() > 700) continue; #endif - + // An exact match is worth a score of 100 and terminates the search if (ident == xact->payee) { DEBUG("lookup", " we have an exact match, score = 100"); diff --git a/src/op.cc b/src/op.cc index 4baac811..893cd834 100644 --- a/src/op.cc +++ b/src/op.cc @@ -438,7 +438,7 @@ value_t expr_t::op_t::calc(scope_t& scope, ptr_op_t * locus, const int depth) return result; } - catch (const std::exception&) { + catch (const std::exception&) { if (locus && ! *locus) *locus = this; throw; diff --git a/src/option.cc b/src/option.cc index dae0f0af..f7008b47 100644 --- a/src/option.cc +++ b/src/option.cc @@ -89,7 +89,7 @@ namespace { catch (const std::exception&) { if (name[0] == '-') add_error_context(_("While parsing option '%1'") << name); - + else add_error_context(_("While parsing environent variable '%1'") << name); throw; @@ -156,7 +156,7 @@ namespace { op_bool_char_tuple(expr_t::ptr_op_t _op, bool _truth, char _ch) : op(_op), truth(_truth), ch(_ch) {} }; -} +} strings_list process_arguments(strings_list args, scope_t& scope) { diff --git a/src/option.h b/src/option.h index eacc65d1..8f89d081 100644 --- a/src/option.h +++ b/src/option.h @@ -214,7 +214,7 @@ public: #define DECL1(type, name, vartype, var, value) \ vartype var ; \ name ## option_t() : option_t(#name), var(value) - + #define DO() virtual void handler_thunk(call_scope_t&) #define DO_(var) virtual void handler_thunk(call_scope_t& var) diff --git a/src/pool.cc b/src/pool.cc index aa56efff..65edbd6a 100644 --- a/src/pool.cc +++ b/src/pool.cc @@ -298,7 +298,7 @@ commodity_pool_t::exchange(const amount_t& amount, annotation.add_flags(ANNOTATION_DATE_CALCULATED); if (tag) annotation.add_flags(ANNOTATION_TAG_CALCULATED); - + breakdown.amount = amount_t(amount, annotation); DEBUG("commodity.prices.add", diff --git a/src/post.cc b/src/post.cc index ca03a675..4178c8bc 100644 --- a/src/post.cc +++ b/src/post.cc @@ -115,7 +115,7 @@ date_t post_t::actual_date() const return xact->date(); } return *_date; -} +} optional post_t::effective_date() const { @@ -341,7 +341,7 @@ namespace { value_t get_value_date(post_t& post) { if (post.has_xdata()) { post_t::xdata_t& xdata(post.xdata()); - if (! xdata.value_date.is_not_a_date()) + if (! xdata.value_date.is_not_a_date()) return xdata.value_date; } return post.date(); diff --git a/src/pstream.h b/src/pstream.h index 5fac20bd..8134495d 100644 --- a/src/pstream.h +++ b/src/pstream.h @@ -99,7 +99,7 @@ class ptristream : public std::istream protected: ptrinbuf buf; -public: +public: ptristream(char * ptr, std::size_t len = 0) : std::istream(0), buf(ptr, len) { rdbuf(&buf); diff --git a/src/py_balance.cc b/src/py_balance.cc index eba5761d..540b3221 100644 --- a/src/py_balance.cc +++ b/src/py_balance.cc @@ -56,7 +56,7 @@ namespace { datetime_t& moment) { return balance.value(moment, in_terms_of); } - + boost::optional py_commodity_amount_0(const balance_t& balance) { return balance.commodity_amount(); diff --git a/src/py_commodity.cc b/src/py_commodity.cc index 783171dd..6d8a29b3 100644 --- a/src/py_commodity.cc +++ b/src/py_commodity.cc @@ -181,7 +181,7 @@ namespace { const datetime_t& date, const amount_t& price) { commodity.add_price(date, price); } - + void py_add_price_3(commodity_t& commodity, const datetime_t& date, const amount_t& price, const bool reflexive) { commodity.add_price(date, price, reflexive); diff --git a/src/py_xact.cc b/src/py_xact.cc index b7582854..adaf81a2 100644 --- a/src/py_xact.cc +++ b/src/py_xact.cc @@ -140,7 +140,7 @@ void export_xact() class_< period_xact_t, bases > ("PeriodicTransaction") .def(init()) - + .add_property("period", make_getter(&period_xact_t::period), make_setter(&period_xact_t::period)) diff --git a/src/pyinterp.cc b/src/pyinterp.cc index e0801604..e0fd2d59 100644 --- a/src/pyinterp.cc +++ b/src/pyinterp.cc @@ -126,7 +126,7 @@ void python_interpreter_t::initialize() void python_interpreter_t::hack_system_paths() { // Hack ledger.__path__ so it points to a real location - python::object sys_module = python::import("sys"); + python::object sys_module = python::import("sys"); python::object sys_dict = sys_module.attr("__dict__"); python::list paths(sys_dict["path"]); @@ -177,7 +177,7 @@ object python_interpreter_t::import_into_main(const string& str) if (! mod) throw_(std::runtime_error, _("Failed to import Python module %1") << str); - + // Import all top-level entries directly into the main namespace main_nspace.update(mod.attr("__dict__")); @@ -193,7 +193,7 @@ object python_interpreter_t::import_option(const string& str) { path file(str); - python::object sys_module = python::import("sys"); + python::object sys_module = python::import("sys"); python::object sys_dict = sys_module.attr("__dict__"); python::list paths(sys_dict["path"]); @@ -312,7 +312,7 @@ value_t python_interpreter_t::python_command(call_scope_t& args) delete[] argv; throw; } - + for (std::size_t i = 0; i < args.size() + 1; i++) delete[] argv[i]; delete[] argv; @@ -445,7 +445,7 @@ namespace { } } } - + value_t python_interpreter_t::functor_t::operator()(call_scope_t& args) { try { diff --git a/src/pyinterp.h b/src/pyinterp.h index 1dfd0747..ea947c5a 100644 --- a/src/pyinterp.h +++ b/src/pyinterp.h @@ -48,7 +48,7 @@ public: : session_t(), main_nspace(), is_initialized(false) { TRACE_CTOR(python_interpreter_t, ""); } - + virtual ~python_interpreter_t() { TRACE_DTOR(python_interpreter_t); diff --git a/src/pyutils.h b/src/pyutils.h index efb1b858..7e016502 100644 --- a/src/pyutils.h +++ b/src/pyutils.h @@ -173,7 +173,7 @@ namespace boost { namespace python { arg_to_python(T const& x) \ : python::handle<>(expr) {} \ }; \ - } + } // Specialize argument and return value converters for T using expr # define BOOST_PYTHON_TO_PYTHON_BY_VALUE(T, expr, pytype) \ diff --git a/src/query.cc b/src/query.cc index b93c6534..5c11add5 100644 --- a/src/query.cc +++ b/src/query.cc @@ -295,7 +295,7 @@ query_t::parser_t::parse_query_term(query_t::lexer_t::token_t::kind_t tok_contex if (tok.kind != lexer_t::token_t::TERM) throw_(parse_error, _("Metadata equality operator not followed by term")); - + expr_t::ptr_op_t arg2 = new expr_t::op_t(expr_t::op_t::VALUE); assert(tok.value); arg2->set_value(mask_t(*tok.value)); @@ -309,7 +309,7 @@ query_t::parser_t::parse_query_term(query_t::lexer_t::token_t::kind_t tok_contex } break; } - + default: { node = new expr_t::op_t(expr_t::op_t::O_MATCH); diff --git a/src/report.cc b/src/report.cc index 473308a0..d3a219a0 100644 --- a/src/report.cc +++ b/src/report.cc @@ -289,7 +289,7 @@ void report_t::parse_query_args(const value_t& args, const string& whence) normalize_period(); // it needs normalization } -} +} namespace { struct posts_flusher diff --git a/src/report.h b/src/report.h index d0a49476..e142b0dc 100644 --- a/src/report.h +++ b/src/report.h @@ -68,7 +68,7 @@ class xact_t; // --- The details of #1 and #2 together represent the ItemHandler. // // 3. Mode of the report. Currently there are four modes: -// +// // a. Posting or commodity iteration. In this mode, all the journal's // xacts, the postings of a specific xact, or all the journal's // commodities are walked. In the first two cases, it's the underlying @@ -86,7 +86,7 @@ class xact_t; // c. Write journal. In this mode, a single function is called that output // the journal object as a textual file. #2 is used to print out each // posting in the journal. -// +// // d. Dump binary file. This is just like 'c', except that it dumps out a // binary file and #2 is completely ignored. // diff --git a/src/scope.h b/src/scope.h index ea030b16..71894d00 100644 --- a/src/scope.h +++ b/src/scope.h @@ -646,7 +646,7 @@ class value_scope_t : public child_scope_t public: value_scope_t(scope_t& _parent, const value_t& _value) : child_scope_t(_parent), value(_value) {} - + virtual string description() { return parent->description(); } diff --git a/src/session.cc b/src/session.cc index fdb0ad1d..72e29895 100644 --- a/src/session.cc +++ b/src/session.cc @@ -178,7 +178,7 @@ void session_t::close_journal_files() { journal.reset(); amount_t::shutdown(); - + journal.reset(new journal_t); amount_t::initialize(); } diff --git a/src/system.hh.in b/src/system.hh.in index 2077d3a8..f063a761 100644 --- a/src/system.hh.in +++ b/src/system.hh.in @@ -205,7 +205,7 @@ namespace serialization { template void serialize(Archive& ar, boost::filesystem::path& p, const unsigned int) { - std::string s; + std::string s; if (Archive::is_saving::value) s = p.string(); diff --git a/src/textual.cc b/src/textual.cc index ecdf53d4..341271b6 100644 --- a/src/textual.cc +++ b/src/textual.cc @@ -129,7 +129,7 @@ namespace { (in.peek() == ' ' || in.peek() == '\t')); } - void read_next_directive(); + void read_next_directive(); #if defined(TIMELOG_SUPPORT) void clock_in_directive(char * line, bool capitalized); @@ -270,7 +270,7 @@ void instance_t::parse() string err_context = error_context(); if (! err_context.empty()) std::cerr << err_context << std::endl; - + if (! current_context.empty()) std::cerr << current_context << std::endl; @@ -442,7 +442,7 @@ void instance_t::clock_in_directive(char * line, bool /*capitalized*/) } void instance_t::clock_out_directive(char * line, bool /*capitalized*/) -{ +{ string datetime(line, 2, 19); char * p = skip_ws(line + 22); @@ -546,7 +546,7 @@ void instance_t::automated_xact_directive(char * line) try { query_t query; keep_details_t keeper(true, true, true); - expr_t::ptr_op_t expr = + expr_t::ptr_op_t expr = query.parse_args(string_value(skip_ws(line + 1)).to_sequence(), keeper, false, true); @@ -831,7 +831,7 @@ void instance_t::alias_directive(char * line) void instance_t::fixed_directive(char * line) { - if (optional > price_point = + if (optional > price_point = commodity_pool_t::current_pool->parse_price_directive(trim_ws(line), true)) { context.state_stack.push_front(fixed_rate_t(price_point->first, diff --git a/src/times.cc b/src/times.cc index 851da938..7fc9c21e 100644 --- a/src/times.cc +++ b/src/times.cc @@ -280,7 +280,7 @@ optional string_to_day_of_week(const std::string& str) else return none; } - + optional string_to_month_of_year(const std::string& str) { diff --git a/src/times.h b/src/times.h index 1ff08739..fed47ae3 100644 --- a/src/times.h +++ b/src/times.h @@ -203,7 +203,7 @@ struct date_duration_t } ~date_duration_t() throw() { TRACE_DTOR(date_duration_t); - } + } date_t add(const date_t& date) const { switch (quantum) { @@ -431,7 +431,7 @@ public: out << "from" << range_begin->to_string(); if (range_end) out << " to" << range_end->to_string(); - + return out.str(); } diff --git a/src/value.cc b/src/value.cc index 6de40d5b..1ecfffe7 100644 --- a/src/value.cc +++ b/src/value.cc @@ -760,7 +760,7 @@ bool value_t::is_equal_to(const value_t& val) const switch (type()) { case VOID: return val.type() == VOID; - + case BOOLEAN: if (val.is_boolean()) return as_boolean() == val.as_boolean(); diff --git a/src/value.h b/src/value.h index 1176ad09..7c507712 100644 --- a/src/value.h +++ b/src/value.h @@ -139,7 +139,7 @@ private: scope_t *, // SCOPE boost::any // ANY > data; - + type_t type; /** diff --git a/src/xact.cc b/src/xact.cc index 1acbd0a4..7f0b1afe 100644 --- a/src/xact.cc +++ b/src/xact.cc @@ -192,7 +192,7 @@ bool xact_base_t::finalize() DEBUG("xact.finalize", "there were no costs, and a valid top_post"); balance_t::amounts_map::const_iterator a = bal.amounts.begin(); - + const amount_t * x = &(*a++).second; const amount_t * y = &(*a++).second; @@ -418,7 +418,7 @@ bool xact_base_t::verify() amount_t& p(post->cost ? *post->cost : post->amount); assert(! p.is_null()); - + // If the amount was a cost, it very likely has the "keep_precision" flag // set, meaning commodity display precision is ignored when displaying the // amount. We never want this set for the balance, so we must clear the @@ -609,7 +609,7 @@ namespace { .match(post.reported_account()->fullname()); else break; - + case expr_t::op_t::O_NOT: return ! post_pred(op->left(), post); diff --git a/src/xact.h b/src/xact.h index 4879967f..5d7912fc 100644 --- a/src/xact.h +++ b/src/xact.h @@ -61,7 +61,7 @@ public: xact_base_t() : item_t(), journal(NULL) { TRACE_CTOR(xact_base_t, ""); } - xact_base_t(const xact_base_t& e); + xact_base_t(const xact_base_t& e); virtual ~xact_base_t(); diff --git a/tools/configure.ac b/tools/configure.ac index c3a913e6..e078ebc4 100644 --- a/tools/configure.ac +++ b/tools/configure.ac @@ -66,7 +66,7 @@ AC_ARG_ENABLE(doxygen, AM_CONDITIONAL(USE_DOXYGEN, test x$doxygen = xtrue) AC_ARG_ENABLE(cache, - [ --enable-cache Enable use of the --cache option], + [ --enable-cache Enable use of the --cache option], [case "${enableval}" in yes) cache=true ;; no) cache=false ;; @@ -76,7 +76,7 @@ AC_ARG_ENABLE(cache, AM_CONDITIONAL(USE_CACHE_OPTION, test x$cache = xtrue) AC_ARG_ENABLE(python, - [ --enable-python Turn on Python support (experimental)], + [ --enable-python Turn on Python support (experimental)], [case "${enableval}" in yes) python=true ;; no) python=false ;; -- cgit v1.2.3