diff options
author | John Wiegley <johnw@newartisans.com> | 2009-11-09 03:42:06 -0500 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2009-11-09 03:42:35 -0500 |
commit | 6cdb79e2a611d99fa6e13dd224a92dc8badaf2ac (patch) | |
tree | 967464fc8bda9543a108d83d3fc96ecdffb4e04c /src/commodity.cc | |
parent | 2c80227339538154ad0869e746f52db805325589 (diff) | |
download | fork-ledger-6cdb79e2a611d99fa6e13dd224a92dc8badaf2ac.tar.gz fork-ledger-6cdb79e2a611d99fa6e13dd224a92dc8badaf2ac.tar.bz2 fork-ledger-6cdb79e2a611d99fa6e13dd224a92dc8badaf2ac.zip |
XML reporting now works via the "xml" command
Diffstat (limited to 'src/commodity.cc')
-rw-r--r-- | src/commodity.cc | 44 |
1 files changed, 40 insertions, 4 deletions
diff --git a/src/commodity.cc b/src/commodity.cc index 7669b3db..49e82b53 100644 --- a/src/commodity.cc +++ b/src/commodity.cc @@ -654,15 +654,51 @@ bool compare_amount_commodities::operator()(const amount_t * left, } } -void to_xml(std::ostream& out, const commodity_t& comm) +void to_xml(std::ostream& out, const commodity_t& comm, + bool commodity_details) { - push_xml x(out, "commodity"); + push_xml x(out, "commodity", true); + + out << " flags=\""; + if (! (comm.has_flags(COMMODITY_STYLE_SUFFIXED))) out << 'P'; + if (comm.has_flags(COMMODITY_STYLE_SEPARATED)) out << 'S'; + if (comm.has_flags(COMMODITY_STYLE_THOUSANDS)) out << 'T'; + if (comm.has_flags(COMMODITY_STYLE_EUROPEAN)) out << 'E'; + out << '"'; + + x.close_attrs(); + { push_xml y(out, "symbol"); out << y.guard(comm.symbol()); } - if (comm.is_annotated()) - to_xml(out, as_annotated_commodity(comm).details); + + if (commodity_details) { + if (comm.is_annotated()) + to_xml(out, as_annotated_commodity(comm).details); + + if (comm.varied_history()) { + push_xml y(out, "varied-history"); + + foreach (const commodity_t::history_by_commodity_map::value_type& pair, + comm.varied_history()->histories) { + { + push_xml z(out, "symbol"); + out << y.guard(pair.first->symbol()); + } + { + push_xml z(out, "history"); + + foreach (const commodity_t::history_map::value_type& inner_pair, + pair.second.prices) { + push_xml w(out, "price-point"); + to_xml(out, inner_pair.first); + to_xml(out, inner_pair.second); + } + } + } + } + } } } // namespace ledger |