summaryrefslogtreecommitdiff
path: root/src/output.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-02-10 15:57:34 -0400
committerJohn Wiegley <johnw@newartisans.com>2009-02-10 15:57:34 -0400
commitaf3be5f96463bcba6ddf4cd26e2ead9d925287b1 (patch)
tree978fa8867503368a3e9072ec20fae48845328097 /src/output.cc
parentbedadd03a0a8ec4b84751104139cc49bede72cbe (diff)
downloadfork-ledger-af3be5f96463bcba6ddf4cd26e2ead9d925287b1.tar.gz
fork-ledger-af3be5f96463bcba6ddf4cd26e2ead9d925287b1.tar.bz2
fork-ledger-af3be5f96463bcba6ddf4cd26e2ead9d925287b1.zip
Wrote the beginnings of a new "stats" command.
Diffstat (limited to 'src/output.cc')
-rw-r--r--src/output.cc31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/output.cc b/src/output.cc
index 593ce909..752d6dd2 100644
--- a/src/output.cc
+++ b/src/output.cc
@@ -84,6 +84,37 @@ void format_xacts::operator()(xact_t& xact)
}
}
+void gather_statistics::flush()
+{
+ std::ostream& out(report.output_stream);
+
+ out << "Statistics gathered for this report:" << std::endl
+ << " Total entries: " ;
+
+ out << std::right;
+ out.width(6);
+ out << statistics.total_entries << std::endl
+ << " Total transactions: ";
+
+ out << std::right;
+ out.width(6);
+ out << statistics.total_xacts << std::endl;
+
+ out.flush();
+}
+
+void gather_statistics::operator()(xact_t& xact)
+{
+ if (last_entry != xact.entry) {
+ statistics.total_entries++;
+ last_entry = xact.entry;
+ }
+ if (last_xact != &xact) {
+ statistics.total_xacts++;
+ last_xact = &xact;
+ }
+}
+
void format_entries::format_last_entry()
{
bool first = true;