diff options
author | Johann Klähn <kljohann@gmail.com> | 2013-03-08 21:45:56 +0100 |
---|---|---|
committer | Johann Klähn <kljohann@gmail.com> | 2013-03-08 22:56:01 +0100 |
commit | a875940a93848d4b18b5bed45049edc901ad07a2 (patch) | |
tree | 33dcb08c5cb43ada33c4c4af9b11cb7c0bf6b3ef /src/post.cc | |
parent | 8f4b0e89627b082f9c5d4bd2b506661aab732b0b (diff) | |
download | fork-ledger-a875940a93848d4b18b5bed45049edc901ad07a2.tar.gz fork-ledger-a875940a93848d4b18b5bed45049edc901ad07a2.tar.bz2 fork-ledger-a875940a93848d4b18b5bed45049edc901ad07a2.zip |
fix ledger xml output, remove ledger json command
As the format used by property trees to represent valid JSON
and that for valid XML is too different and given that there are
more requests for valid XML output I decided to pursue a quick fix
and remove the json command in favor of a working xml command.
See bug #782, #909, recent discussion on mailing list.
JSON support is postponed until I or someone else finds time to work on
this or the python bindings are more stable.
Diffstat (limited to 'src/post.cc')
-rw-r--r-- | src/post.cc | 43 |
1 files changed, 15 insertions, 28 deletions
diff --git a/src/post.cc b/src/post.cc index c7435aec..1a24429b 100644 --- a/src/post.cc +++ b/src/post.cc @@ -696,10 +696,8 @@ void extend_post(post_t& post, journal_t& journal) } } -void put_post(property_tree::ptree& pt, const post_t& post) +void put_post(property_tree::ptree& st, const post_t& post) { - property_tree::ptree& st(pt.put("posting", "")); - if (post.state() == item_t::CLEARED) st.put("<xmlattr>.state", "cleared"); else if (post.state() == item_t::PENDING) @@ -710,14 +708,10 @@ void put_post(property_tree::ptree& pt, const post_t& post) if (post.has_flags(ITEM_GENERATED)) st.put("<xmlattr>.generated", "true"); - if (post._date) { - property_tree::ptree& t(st.put("date", "")); - put_date(t, *post._date, false); - } - if (post._date_aux) { - property_tree::ptree& t(st.put("aux-date", "")); - put_date(t, *post._date_aux, false); - } + if (post._date) + put_date(st.put("date", ""), *post._date); + if (post._date_aux) + put_date(st.put("aux-date", ""), *post._date_aux); if (post.account) { property_tree::ptree& t(st.put("account", "")); @@ -736,34 +730,27 @@ void put_post(property_tree::ptree& pt, const post_t& post) if (post.has_xdata() && post.xdata().has_flags(POST_EXT_COMPOUND)) put_value(t, post.xdata().compound_value); else - put_amount(t, post.amount); + put_amount(t.put("amount", ""), post.amount); } - if (post.cost) { - property_tree::ptree& t(st.put("cost", "")); - put_amount(t, *post.cost, false); - } + if (post.cost) + put_amount(st.put("cost", ""), *post.cost); if (post.assigned_amount) { - if (post.has_flags(POST_CALCULATED)) { - property_tree::ptree& t(st.put("balance-assertion", "")); - put_amount(t, *post.assigned_amount, false); - } else { - property_tree::ptree& t(st.put("balance-assignment", "")); - put_amount(t, *post.assigned_amount, false); - } + if (post.has_flags(POST_CALCULATED)) + put_amount(st.put("balance-assertion", ""), *post.assigned_amount); + else + put_amount(st.put("balance-assignment", ""), *post.assigned_amount); } if (post.note) st.put("note", *post.note); if (post.metadata) - put_metadata(st, *post.metadata); + put_metadata(st.put("metadata", ""), *post.metadata); - if (post.xdata_ && ! post.xdata_->total.is_null()) { - property_tree::ptree& t(st.put("total", "")); - put_value(t, post.xdata_->total); - } + if (post.xdata_ && ! post.xdata_->total.is_null()) + put_value(st.put("total", ""), post.xdata_->total); } } // namespace ledger |