summaryrefslogtreecommitdiff
path: root/src/report.h
diff options
context:
space:
mode:
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