Re-enabled some code, and removed a bunch of deadwood.

This commit is contained in:
John Wiegley 2009-02-12 03:30:41 -04:00
parent bb243e2c5e
commit c8cd2c468e
10 changed files with 19 additions and 82 deletions

View file

@ -145,7 +145,6 @@ xact_handler_ptr chain_xact_handlers(report_t& report,
report.what_to_keep()))); report.what_to_keep())));
} }
#if 0
// budget_xacts takes a set of xacts from a data file and uses them to // budget_xacts takes a set of xacts from a data file and uses them to
// generate "budget xacts" which balance against the reported xacts. // generate "budget xacts" which balance against the reported xacts.
// //
@ -153,30 +152,35 @@ xact_handler_ptr chain_xact_handlers(report_t& report,
// only for the future, and does not balance them against anything but the // only for the future, and does not balance them against anything but the
// future balance. // future balance.
if (report.budget_flags) { if (report.budget_flags != BUDGET_NO_BUDGET) {
budget_xacts * budget_handler = new budget_xacts(handler, budget_xacts * budget_handler = new budget_xacts(handler,
report.budget_flags); report.budget_flags);
budget_handler->add_period_entries(journal->period_entries); budget_handler->add_period_entries(report.session.journal->period_entries);
handler.reset(budget_handler); handler.reset(budget_handler);
// Apply this before the budget handler, so that only matching xacts are // Apply this before the budget handler, so that only matching xacts are
// calculated toward the budget. The use of filter_xacts above will // calculated toward the budget. The use of filter_xacts above will
// further clean the results so that no automated xacts that don't match // further clean the results so that no automated xacts that don't match
// the filter get reported. // the filter get reported.
if (! report.predicate.empty()) if (report.HANDLED(limit_))
handler.reset(new filter_xacts(handler, report.predicate)); handler.reset(new filter_xacts
(handler, item_predicate<xact_t>
(report.HANDLER(limit_).str(), report.what_to_keep())));
} }
else if (! report.forecast_limit.empty()) { else if (report.HANDLED(forecast_)) {
forecast_xacts * forecast_handler forecast_xacts * forecast_handler
= new forecast_xacts(handler, report.forecast_limit); = new forecast_xacts(handler,
forecast_handler->add_period_entries(journal->period_entries); item_predicate<xact_t>
(report.HANDLER(forecast_).str(), report.what_to_keep()));
forecast_handler->add_period_entries(report.session.journal->period_entries);
handler.reset(forecast_handler); handler.reset(forecast_handler);
// See above, under budget_xacts. // See above, under budget_xacts.
if (! report.predicate.empty()) if (report.HANDLED(limit_))
handler.reset(new filter_xacts(handler, report.predicate)); handler.reset(new filter_xacts
(handler, item_predicate<xact_t>
(report.HANDLER(limit_).str(), report.what_to_keep())));
} }
#endif
if (report.HANDLED(comm_as_payee)) if (report.HANDLED(comm_as_payee))
handler.reset(new set_comm_as_payee(handler)); handler.reset(new set_comm_as_payee(handler));

View file

@ -40,9 +40,6 @@ entry_base_t::entry_base_t(const entry_base_t& e)
: item_t(), journal(NULL) : item_t(), journal(NULL)
{ {
TRACE_CTOR(entry_base_t, "copy"); TRACE_CTOR(entry_base_t, "copy");
#if 0
xacts.insert(xacts.end(), e.xacts.begin(), e.xacts.end());
#endif
} }
entry_base_t::~entry_base_t() entry_base_t::~entry_base_t()
@ -255,10 +252,6 @@ entry_t::entry_t(const entry_t& e)
: entry_base_t(e), code(e.code), payee(e.payee) : entry_base_t(e), code(e.code), payee(e.payee)
{ {
TRACE_CTOR(entry_t, "copy"); TRACE_CTOR(entry_t, "copy");
#if 0
foreach (xact_t * xact, xacts)
xact->entry = this;
#endif
} }
void entry_t::add_xact(xact_t * xact) void entry_t::add_xact(xact_t * xact)

View file

@ -267,7 +267,7 @@ namespace {
break; break;
default: default:
assert(false); // jww (2008-04-24): What to do here? assert(false);
break; break;
} }

View file

@ -196,9 +196,6 @@ void global_scope_t::execute_command(strings_list args, bool at_repl)
if (! is_precommand) { if (! is_precommand) {
if (! at_repl) if (! at_repl)
read_journal_files(); read_journal_files();
// jww (2009-02-02): This is a complete hack, and a leftover from long,
// long ago. The question is, how best to remove its necessity...
normalize_report_options(verb); normalize_report_options(verb);
} }
@ -387,7 +384,6 @@ void global_scope_t::normalize_report_options(const string& verb)
// jww (2008-08-14): This code really needs to be rationalized away // jww (2008-08-14): This code really needs to be rationalized away
// for 3.0. // for 3.0.
if (verb == "print" || verb == "entry" || verb == "dump") { if (verb == "print" || verb == "entry" || verb == "dump") {
rep.HANDLER(related).on(); rep.HANDLER(related).on();
rep.HANDLER(related_all).on(); rep.HANDLER(related_all).on();

View file

@ -146,40 +146,6 @@ void format_entries::operator()(xact_t& xact)
last_entry = xact.entry; last_entry = xact.entry;
} }
void print_entry(std::ostream& out, const entry_base_t& entry_base,
const string& prefix)
{
string print_format;
if (dynamic_cast<const entry_t *>(&entry_base)) {
print_format = (prefix + "%D %X%C%P\n" +
prefix + " %-34A %12o\n%/" +
prefix + " %-34A %12o\n");
}
else if (const auto_entry_t * entry =
dynamic_cast<const auto_entry_t *>(&entry_base)) {
out << "= " << entry->predicate.predicate.text() << '\n';
print_format = prefix + " %-34A %12o\n";
}
else if (const period_entry_t * entry =
dynamic_cast<const period_entry_t *>(&entry_base)) {
out << "~ " << entry->period_string << '\n';
print_format = prefix + " %-34A %12o\n";
}
else {
assert(false);
}
#if 0
format_entries formatter(out, print_format);
walk_xacts(const_cast<xacts_list&>(entry_base.xacts), formatter);
formatter.flush();
clear_xact_xdata cleaner;
walk_xacts(const_cast<xacts_list&>(entry_base.xacts), cleaner);
#endif
}
void format_accounts::flush() void format_accounts::flush()
{ {
std::ostream& out(report.output_stream); std::ostream& out(report.output_stream);

View file

@ -139,11 +139,6 @@ class format_entries : public format_xacts
format_xacts::flush(); format_xacts::flush();
} }
virtual void operator()(xact_t& xact); virtual void operator()(xact_t& xact);
private:
void print_entry(std::ostream& out,
const entry_base_t& entry,
const string& prefix = "");
}; };
/** /**

View file

@ -68,9 +68,7 @@ public:
const char * p = input.c_str(); const char * p = input.c_str();
std::size_t len = input.length(); std::size_t len = input.length();
#if 0 //assert(utf8::is_valid(p, p + len));
assert(utf8::is_valid(p, p + len));
#endif
utf8::utf8to32(p, p + len, std::back_inserter(utf32chars)); utf8::utf8to32(p, p + len, std::back_inserter(utf32chars));
} }
~unistring() { ~unistring() {

View file

@ -243,7 +243,7 @@ void value_t::in_place_simplify()
DEBUG("ledger.value.reduce", "as an amount it looks like: " << *this); DEBUG("ledger.value.reduce", "as an amount it looks like: " << *this);
} }
#if 0 #ifdef REDUCE_TO_INTEGER // this is off by default
if (is_amount() && ! as_amount().has_commodity() && if (is_amount() && ! as_amount().has_commodity() &&
as_amount().fits_in_long()) { as_amount().fits_in_long()) {
DEBUG_("Reducing amount to integer"); DEBUG_("Reducing amount to integer");

View file

@ -112,17 +112,6 @@ namespace {
} }
} }
#if 0
value_t get_price(xact_t& xact) {
if (xact.has_xdata() &&
xact.xdata().has_flags(XACT_EXT_COMPOUND)) {
return xact.xdata().value;
} else {
return xact.amount;
}
}
#endif
value_t get_total(xact_t& xact) { value_t get_total(xact_t& xact) {
if (xact.xdata_) if (xact.xdata_)
return xact.xdata_->total; return xact.xdata_->total;
@ -196,10 +185,6 @@ expr_t::ptr_op_t xact_t::lookup(const string& name)
case 'p': case 'p':
if (name == "payee") if (name == "payee")
return WRAP_FUNCTOR(get_wrapper<&get_payee>); return WRAP_FUNCTOR(get_wrapper<&get_payee>);
#if 0
else if (name == "price")
return WRAP_FUNCTOR(get_wrapper<&get_price>);
#endif
break; break;
case 't': case 't':

View file

@ -99,7 +99,7 @@ public:
amount(xact.amount), amount(xact.amount),
cost(xact.cost), cost(xact.cost),
assigned_amount(xact.assigned_amount), assigned_amount(xact.assigned_amount),
xdata_(xact.xdata_) // jww (2008-07-19): What are the copy semantics? xdata_(xact.xdata_)
{ {
TRACE_CTOR(xact_t, "copy"); TRACE_CTOR(xact_t, "copy");
} }