A little bit of code cleanup

This commit is contained in:
John Wiegley 2010-06-04 02:23:04 -04:00
parent 45451125e3
commit 946534b102
5 changed files with 29 additions and 20 deletions

View file

@ -62,7 +62,6 @@ namespace ledger {
class commodity_t; class commodity_t;
class annotation_t; class annotation_t;
class keep_details_t; class keep_details_t;
class commodity_pool_t;
DECLARE_EXCEPTION(amount_error, std::runtime_error); DECLARE_EXCEPTION(amount_error, std::runtime_error);
@ -514,7 +513,7 @@ public:
amount's commodity: amount's commodity:
commodity() returns an amount's commodity. If the amount has no commodity() returns an amount's commodity. If the amount has no
commodity, the value returned is `current_pool->null_commodity'. commodity, the value returned is the `null_commodity'.
has_commodity() returns true if the amount has a commodity. has_commodity() returns true if the amount has a commodity.

View file

@ -50,6 +50,7 @@
namespace ledger { namespace ledger {
class keep_details_t; class keep_details_t;
class commodity_pool_t;
DECLARE_EXCEPTION(commodity_error, std::runtime_error); DECLARE_EXCEPTION(commodity_error, std::runtime_error);

View file

@ -1318,9 +1318,10 @@ expr_t::ptr_op_t report_t::lookup(const symbol_t::kind_t kind,
case symbol_t::COMMAND: case symbol_t::COMMAND:
switch (*p) { switch (*p) {
case 'a': case 'a':
if (is_eq(p, "accounts")) if (is_eq(p, "accounts")) {
return WRAP_FUNCTOR(reporter<>(new report_accounts(*this), *this, return WRAP_FUNCTOR(reporter<>(new report_accounts(*this), *this,
"#accounts")); "#accounts"));
}
break; break;
case 'b': case 'b':
@ -1381,48 +1382,57 @@ expr_t::ptr_op_t report_t::lookup(const symbol_t::kind_t kind,
HANDLER(print_virtual).on_only(string("#equity")); HANDLER(print_virtual).on_only(string("#equity"));
return WRAP_FUNCTOR(reporter<>(new print_xacts(*this), *this, "#equity")); return WRAP_FUNCTOR(reporter<>(new print_xacts(*this), *this, "#equity"));
} }
else if (is_eq(p, "entry")) else if (is_eq(p, "entry")) {
return WRAP_FUNCTOR(xact_command); return WRAP_FUNCTOR(xact_command);
else if (is_eq(p, "emacs")) }
else if (is_eq(p, "emacs")) {
return WRAP_FUNCTOR return WRAP_FUNCTOR
(reporter<>(new format_emacs_posts(output_stream), *this, "#emacs")); (reporter<>(new format_emacs_posts(output_stream), *this, "#emacs"));
else if (is_eq(p, "echo")) }
else if (is_eq(p, "echo")) {
return MAKE_FUNCTOR(report_t::echo_command); return MAKE_FUNCTOR(report_t::echo_command);
}
break; break;
case 'p': case 'p':
if (*(p + 1) == '\0' || is_eq(p, "print")) if (*(p + 1) == '\0' || is_eq(p, "print")) {
return WRAP_FUNCTOR return WRAP_FUNCTOR
(reporter<>(new print_xacts(*this, HANDLED(raw)), *this, "#print")); (reporter<>(new print_xacts(*this, HANDLED(raw)), *this, "#print"));
else if (is_eq(p, "prices")) }
else if (is_eq(p, "prices")) {
return expr_t::op_t::wrap_functor return expr_t::op_t::wrap_functor
(reporter<post_t, post_handler_ptr, &report_t::commodities_report> (reporter<post_t, post_handler_ptr, &report_t::commodities_report>
(new format_posts(*this, report_format(HANDLER(prices_format_)), (new format_posts(*this, report_format(HANDLER(prices_format_)),
maybe_format(HANDLER(prepend_format_)), maybe_format(HANDLER(prepend_format_)),
HANDLER(prepend_width_).value.to_long()), HANDLER(prepend_width_).value.to_long()),
*this, "#prices")); *this, "#prices"));
else if (is_eq(p, "pricedb")) }
else if (is_eq(p, "pricedb")) {
return expr_t::op_t::wrap_functor return expr_t::op_t::wrap_functor
(reporter<post_t, post_handler_ptr, &report_t::commodities_report> (reporter<post_t, post_handler_ptr, &report_t::commodities_report>
(new format_posts(*this, report_format(HANDLER(pricedb_format_)), (new format_posts(*this, report_format(HANDLER(pricedb_format_)),
maybe_format(HANDLER(prepend_format_)), maybe_format(HANDLER(prepend_format_)),
HANDLER(prepend_width_).value.to_long()), HANDLER(prepend_width_).value.to_long()),
*this, "#pricedb")); *this, "#pricedb"));
else if (is_eq(p, "payees")) }
else if (is_eq(p, "payees")) {
return WRAP_FUNCTOR(reporter<>(new report_payees(*this), *this, return WRAP_FUNCTOR(reporter<>(new report_payees(*this), *this,
"#payees")); "#payees"));
}
break; break;
case 'r': case 'r':
if (*(p + 1) == '\0' || is_eq(p, "reg") || is_eq(p, "register")) if (*(p + 1) == '\0' || is_eq(p, "reg") || is_eq(p, "register")) {
return WRAP_FUNCTOR return WRAP_FUNCTOR
(reporter<> (reporter<>
(new format_posts(*this, report_format(HANDLER(register_format_)), (new format_posts(*this, report_format(HANDLER(register_format_)),
maybe_format(HANDLER(prepend_format_)), maybe_format(HANDLER(prepend_format_)),
HANDLER(prepend_width_).value.to_long()), HANDLER(prepend_width_).value.to_long()),
*this, "#register")); *this, "#register"));
else if (is_eq(p, "reload")) }
else if (is_eq(p, "reload")) {
return MAKE_FUNCTOR(report_t::reload_command); return MAKE_FUNCTOR(report_t::reload_command);
}
break; break;
case 's': case 's':

View file

@ -50,7 +50,6 @@
namespace ledger { namespace ledger {
class commodity_pool_t;
class xact_t; class xact_t;
class session_t : public symbol_scope_t class session_t : public symbol_scope_t

View file

@ -2,18 +2,18 @@
<<< <<<
>>>1 >>>1
>>>2 >>>2
While parsing file "$sourcepath/src/amount.h", line 67: While parsing file "$sourcepath/src/amount.h", line 66:
Error: No quantity specified for amount Error: No quantity specified for amount
While parsing file "$sourcepath/src/amount.h", line 721: While parsing file "$sourcepath/src/amount.h", line 720:
Error: Invalid date/time: line amount_t amoun Error: Invalid date/time: line amount_t amoun
While parsing file "$sourcepath/src/amount.h", line 727: While parsing file "$sourcepath/src/amount.h", line 726:
Error: Invalid date/time: line string amount_ Error: Invalid date/time: line string amount_
While parsing file "$sourcepath/src/amount.h", line 733: While parsing file "$sourcepath/src/amount.h", line 732:
Error: Invalid date/time: line string amount_ Error: Invalid date/time: line string amount_
While parsing file "$sourcepath/src/amount.h", line 739: While parsing file "$sourcepath/src/amount.h", line 738:
Error: Invalid date/time: line string amount_ Error: Invalid date/time: line string amount_
While parsing file "$sourcepath/src/amount.h", line 745: While parsing file "$sourcepath/src/amount.h", line 744:
Error: Invalid date/time: line std::ostream& Error: Invalid date/time: line std::ostream&
While parsing file "$sourcepath/src/amount.h", line 752: While parsing file "$sourcepath/src/amount.h", line 751:
Error: Invalid date/time: line std::istream& Error: Invalid date/time: line std::istream&
=== 7 === 7