From 3231e380bbe6ebd5641a24a493078e8aee0fdfe3 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Wed, 13 Aug 2008 05:48:32 -0400 Subject: The balance output now includes the final total. --- src/main.cc | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) (limited to 'src/main.cc') diff --git a/src/main.cc b/src/main.cc index eeff5bb7..8790fb17 100644 --- a/src/main.cc +++ b/src/main.cc @@ -150,32 +150,28 @@ namespace ledger { return final_value_expr; } - template class reporter { - string format_name; + shared_ptr > handler; public: - reporter(const string& _format_name) - : format_name(_format_name) {} + reporter(item_handler * _handler) + : handler(_handler) {} value_t operator()(call_scope_t& args) { - report_t& report(find_scope(args)); - var_t format(args, format_name); - - if (! report.format_string.empty()) - *format = report.format_string; + report_t& report(find_scope(args)); if (args.value().size() > 0) report.append_predicate (args_to_predicate(args.value().as_sequence().begin(), args.value().as_sequence().end())); - (report.*report_method)(handler_ptr(new Formatter(report, *format))); + (report.*report_method)(handler_ptr(handler)); return true; } @@ -403,15 +399,17 @@ namespace ledger { function_t command; if (verb == "register" || verb == "reg" || verb == "r") - command = reporter<>("register_format"); + command = reporter<>(new format_xacts(report, session.register_format)); else if (verb == "print" || verb == "p") - command = reporter<>("print_format"); + command = reporter<>(new format_xacts(report, session.print_format)); else if (verb == "balance" || verb == "bal" || verb == "b") - command = reporter("balance_format"); + command = reporter + (new format_accounts(report, session.balance_format)); else if (verb == "equity") - command = reporter("print_format"); + command = reporter + (new format_equity(report, session.print_format)); #if 0 else if (verb == "entry") command = entry_command(); -- cgit v1.2.3