diff options
author | John Wiegley <johnw@newartisans.com> | 2009-11-09 01:24:44 -0500 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2009-11-09 02:06:08 -0500 |
commit | fb8be53edb9d9fdd91fd906e9a4ce6c3e8e3adb3 (patch) | |
tree | e1e41cd4e926ad108743f29158b4ef8e451b90f5 /src/output.cc | |
parent | c3535d06c89732a0ba4c13274702b0f48198ae79 (diff) | |
download | fork-ledger-fb8be53edb9d9fdd91fd906e9a4ce6c3e8e3adb3.tar.gz fork-ledger-fb8be53edb9d9fdd91fd906e9a4ce6c3e8e3adb3.tar.bz2 fork-ledger-fb8be53edb9d9fdd91fd906e9a4ce6c3e8e3adb3.zip |
Redesigned the format_t class
Diffstat (limited to 'src/output.cc')
-rw-r--r-- | src/output.cc | 43 |
1 files changed, 23 insertions, 20 deletions
diff --git a/src/output.cc b/src/output.cc index eee84553..2a6f0c20 100644 --- a/src/output.cc +++ b/src/output.cc @@ -51,17 +51,19 @@ format_posts::format_posts(report_t& _report, const char * f = format.c_str(); if (const char * p = std::strstr(f, "%/")) { - first_line_format.parse(string(f, 0, p - f)); + first_line_format.parse_format(string(f, 0, p - f)); const char * n = p + 2; if (const char * p = std::strstr(n, "%/")) { - next_lines_format.parse(string(n, 0, p - n), first_line_format); - between_format.parse(string(p + 2), first_line_format); + next_lines_format.parse_format(string(n, 0, p - n), + first_line_format); + between_format.parse_format(string(p + 2), + first_line_format); } else { - next_lines_format.parse(n, first_line_format); + next_lines_format.parse_format(string(n), first_line_format); } } else { - first_line_format.parse(format); - next_lines_format.parse(format); + first_line_format.parse_format(format); + next_lines_format.parse_format(format); } } @@ -80,7 +82,7 @@ void format_posts::operator()(post_t& post) if (last_xact != post.xact) { if (last_xact) { bind_scope_t xact_scope(report, *last_xact); - between_format.format(out, xact_scope); + out << between_format(xact_scope); } print_item(out, *post.xact); out << '\n'; @@ -96,16 +98,16 @@ void format_posts::operator()(post_t& post) if (last_xact != post.xact) { if (last_xact) { bind_scope_t xact_scope(report, *last_xact); - between_format.format(out, xact_scope); + out << between_format(xact_scope); } - first_line_format.format(out, bound_scope); + out << first_line_format(bound_scope); last_xact = post.xact; } else if (last_post && last_post->date() != post.date()) { - first_line_format.format(out, bound_scope); + out << first_line_format(bound_scope); } else { - next_lines_format.format(out, bound_scope); + out << next_lines_format(bound_scope); } post.xdata().add_flags(POST_EXT_DISPLAYED); @@ -122,17 +124,17 @@ format_accounts::format_accounts(report_t& _report, const char * f = format.c_str(); if (const char * p = std::strstr(f, "%/")) { - account_line_format.parse(string(f, 0, p - f)); + account_line_format.parse_format(string(f, 0, p - f)); const char * n = p + 2; if (const char * p = std::strstr(n, "%/")) { - total_line_format.parse(string(n, 0, p - n), account_line_format); - separator_format.parse(string(p + 2), account_line_format); + total_line_format.parse_format(string(n, 0, p - n), account_line_format); + separator_format.parse_format(string(p + 2), account_line_format); } else { - total_line_format.parse(n, account_line_format); + total_line_format.parse_format(n, account_line_format); } } else { - account_line_format.parse(format); - total_line_format.parse(format, account_line_format); + account_line_format.parse_format(format); + total_line_format.parse_format(format, account_line_format); } } @@ -148,7 +150,8 @@ std::size_t format_accounts::post_account(account_t& account, const bool flat) account.xdata().add_flags(ACCOUNT_EXT_DISPLAYED); bind_scope_t bound_scope(report, account); - account_line_format.format(report.output_stream, bound_scope); + static_cast<std::ostream&>(report.output_stream) + << account_line_format(bound_scope); return 1; } @@ -213,8 +216,8 @@ void format_accounts::flush() if (displayed > 1 && ! report.HANDLED(no_total) && ! report.HANDLED(percent)) { bind_scope_t bound_scope(report, *report.session.journal->master); - separator_format.format(out, bound_scope); - total_line_format.format(out, bound_scope); + out << separator_format(bound_scope); + out << total_line_format(bound_scope); } out.flush(); |