From 52fc9f2e4499e75d17e7f12d32a8391054d8634a Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Sun, 20 Jul 2008 05:03:54 -0400 Subject: Brought in the final round of 3.0 code, although it does not compile yet: report, session, parts of xpath, main, journal, option. --- walk.h | 50 ++++++++++++++++++++------------------------------ 1 file changed, 20 insertions(+), 30 deletions(-) (limited to 'walk.h') diff --git a/walk.h b/walk.h index 3abaac21..de98d071 100644 --- a/walk.h +++ b/walk.h @@ -38,12 +38,9 @@ struct item_handler { template class compare_items { - const value_expr_t * sort_order; + value_expr sort_order; public: - compare_items(const value_expr_t * _sort_order) - : sort_order(_sort_order) { - assert(sort_order); - } + compare_items(value_expr _sort_order) : sort_order(_sort_order) {} bool operator()(const T * left, const T * right); }; @@ -55,8 +52,8 @@ bool compare_items::operator()(const T * left, const T * right) value_t left_result; value_t right_result; - guarded_compute(sort_order, left_result, details_t(*left)); - guarded_compute(sort_order, right_result, details_t(*right)); + sort_order.compute(left_result, details_t(*left)); + sort_order.compute(right_result, details_t(*right)); return left_result < right_result; } @@ -244,26 +241,19 @@ class sort_transactions : public item_handler { typedef std::deque transactions_deque; - transactions_deque transactions; - const value_expr_t * sort_order; + transactions_deque transactions; + const value_expr sort_order; public: sort_transactions(item_handler * handler, - const value_expr_t * _sort_order) + const value_expr& _sort_order) : item_handler(handler), - sort_order(_sort_order->acquire()) {} + sort_order(_sort_order) {} sort_transactions(item_handler * handler, const string& _sort_order) - : item_handler(handler) { - assert(! _sort_order.empty()); - sort_order = parse_value_expr(_sort_order)->acquire(); - } - - virtual ~sort_transactions() { - assert(sort_order); - sort_order->release(); - } + : item_handler(handler), + sort_order(_sort_order) {} virtual void post_accumulated_xacts(); @@ -284,7 +274,7 @@ class sort_entries : public item_handler public: sort_entries(item_handler * handler, - const value_expr_t * _sort_order) + const value_expr& _sort_order) : sorter(handler, _sort_order) {} sort_entries(item_handler * handler, @@ -312,7 +302,7 @@ class filter_transactions : public item_handler public: filter_transactions(item_handler * handler, - const value_expr_t * predicate) + const value_expr& predicate) : item_handler(handler), pred(predicate) {} filter_transactions(item_handler * handler, @@ -392,7 +382,7 @@ class component_transactions : public item_handler public: component_transactions(item_handler * handler, - const value_expr_t * predicate) + const value_expr& predicate) : item_handler(handler), pred(predicate) {} component_transactions(item_handler * handler, @@ -656,7 +646,7 @@ class forecast_transactions : public generate_transactions public: forecast_transactions(item_handler * handler, - const value_expr_t * predicate) + const value_expr& predicate) : generate_transactions(handler), pred(predicate) {} forecast_transactions(item_handler * handler, @@ -720,12 +710,12 @@ void sum_accounts(account_t& account); typedef std::deque accounts_deque; -void sort_accounts(account_t& account, - const value_expr_t * sort_order, - accounts_deque& accounts); -void walk_accounts(account_t& account, - item_handler& handler, - const value_expr_t * sort_order = NULL); +void sort_accounts(account_t& account, + const value_expr& sort_order, + accounts_deque& accounts); +void walk_accounts(account_t& account, + item_handler& handler, + const optional& sort_order = none); void walk_accounts(account_t& account, item_handler& handler, const string& sort_string); -- cgit v1.2.3