Added a "json" report command
This commit is contained in:
parent
a38ed141c1
commit
7e8ba51cd0
4 changed files with 27 additions and 6 deletions
|
|
@ -74,7 +74,14 @@ void format_ptree::flush()
|
||||||
put_post(pt, *post);
|
put_post(pt, *post);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch (format) {
|
||||||
|
case FORMAT_XML:
|
||||||
property_tree::write_xml(out, pt);
|
property_tree::write_xml(out, pt);
|
||||||
|
break;
|
||||||
|
case FORMAT_JSON:
|
||||||
|
property_tree::write_json(out, pt);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void format_ptree::operator()(post_t& post)
|
void format_ptree::operator()(post_t& post)
|
||||||
|
|
|
||||||
10
src/ptree.h
10
src/ptree.h
|
|
@ -74,8 +74,14 @@ protected:
|
||||||
std::deque<xact_t *> transactions;
|
std::deque<xact_t *> transactions;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
format_ptree(report_t& _report) : report(_report) {
|
enum format_t {
|
||||||
TRACE_CTOR(format_ptree, "report&");
|
FORMAT_XML,
|
||||||
|
FORMAT_JSON
|
||||||
|
} format;
|
||||||
|
|
||||||
|
format_ptree(report_t& _report, format_t _format = FORMAT_XML)
|
||||||
|
: report(_report), format(_format) {
|
||||||
|
TRACE_CTOR(format_ptree, "report&, format_t");
|
||||||
}
|
}
|
||||||
virtual ~format_ptree() {
|
virtual ~format_ptree() {
|
||||||
TRACE_DTOR(format_ptree);
|
TRACE_DTOR(format_ptree);
|
||||||
|
|
|
||||||
|
|
@ -1602,11 +1602,16 @@ expr_t::ptr_op_t report_t::lookup(const symbol_t::kind_t kind,
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'j':
|
||||||
|
if (is_eq(p, "json"))
|
||||||
|
return POSTS_REPORTER(new format_ptree(*this,
|
||||||
|
format_ptree::FORMAT_JSON));
|
||||||
|
break;
|
||||||
|
|
||||||
case 'o':
|
case 'o':
|
||||||
if (is_eq(p, "org")) {
|
if (is_eq(p, "org"))
|
||||||
return POSTS_REPORTER(new posts_to_org_table
|
return POSTS_REPORTER(new posts_to_org_table
|
||||||
(*this, maybe_format(HANDLER(prepend_format_))));
|
(*this, maybe_format(HANDLER(prepend_format_))));
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'p':
|
case 'p':
|
||||||
|
|
@ -1649,7 +1654,8 @@ expr_t::ptr_op_t report_t::lookup(const symbol_t::kind_t kind,
|
||||||
if (is_eq(p, "xact"))
|
if (is_eq(p, "xact"))
|
||||||
return WRAP_FUNCTOR(xact_command);
|
return WRAP_FUNCTOR(xact_command);
|
||||||
else if (is_eq(p, "xml"))
|
else if (is_eq(p, "xml"))
|
||||||
return POSTS_REPORTER(new format_ptree(*this));
|
return POSTS_REPORTER(new format_ptree(*this,
|
||||||
|
format_ptree::FORMAT_XML));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -419,6 +419,8 @@ value_t select_command(call_scope_t& args)
|
||||||
}
|
}
|
||||||
else if (arg == "xml") {
|
else if (arg == "xml") {
|
||||||
}
|
}
|
||||||
|
else if (arg == "json") {
|
||||||
|
}
|
||||||
else if (arg == "emacs") {
|
else if (arg == "emacs") {
|
||||||
}
|
}
|
||||||
else if (arg == "org") {
|
else if (arg == "org") {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue