summaryrefslogtreecommitdiff
path: root/src/report.h
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-11-12 05:09:39 -0500
committerJohn Wiegley <johnw@newartisans.com>2009-11-12 05:11:09 -0500
commit9858b4957fe40cba0a1f0a8ca1ba01feb148fb49 (patch)
tree2eef93d6236b7b5b404990937d760e92b051cc86 /src/report.h
parent48dc654eda27c01d0bad88674d21d0e33e5472f6 (diff)
downloadfork-ledger-9858b4957fe40cba0a1f0a8ca1ba01feb148fb49.tar.gz
fork-ledger-9858b4957fe40cba0a1f0a8ca1ba01feb148fb49.tar.bz2
fork-ledger-9858b4957fe40cba0a1f0a8ca1ba01feb148fb49.zip
Reorganized a bit of the reporting code
Diffstat (limited to 'src/report.h')
-rw-r--r--src/report.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/report.h b/src/report.h
index c31ffc32..c656829b 100644
--- a/src/report.h
+++ b/src/report.h
@@ -44,6 +44,7 @@
#include "interactive.h"
#include "expr.h"
+#include "query.h"
#include "chain.h"
#include "stream.h"
#include "option.h"
@@ -125,6 +126,7 @@ public:
}
void normalize_options(const string& verb);
+ void parse_query_args(const value_t& args, const string& whence);
void posts_report(post_handler_ptr handler);
void generate_report(post_handler_ptr handler);
@@ -909,6 +911,34 @@ public:
DO_(args) { value = args[1].to_long(); specified = true; });
};
+
+template <class Type = post_t,
+ class handler_ptr = post_handler_ptr,
+ void (report_t::*report_method)(handler_ptr) =
+ &report_t::posts_report>
+class reporter
+{
+ shared_ptr<item_handler<Type> > handler;
+
+ report_t& report;
+ string whence;
+
+public:
+ reporter(item_handler<Type> * _handler,
+ report_t& _report, const string& _whence)
+ : handler(_handler), report(_report), whence(_whence) {}
+
+ value_t operator()(call_scope_t& args)
+ {
+ if (args.size() > 0)
+ report.parse_query_args(args.value(), whence);
+
+ (report.*report_method)(handler_ptr(handler));
+
+ return true;
+ }
+};
+
} // namespace ledger
#endif // _REPORT_H