From a38ed141c1f33ecdad99b322acb1ae07b30a5da2 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Fri, 18 May 2012 01:31:01 -0600 Subject: Switched to Boost.PropertyTree for XML generation --- src/account.cc | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'src/account.cc') diff --git a/src/account.cc b/src/account.cc index 1ea13330..11b918fa 100644 --- a/src/account.cc +++ b/src/account.cc @@ -690,4 +690,36 @@ void account_t::xdata_t::details_t::update(post_t& post, } } +void put_account(property_tree::ptree& pt, const account_t& acct, + function pred) +{ + if (pred(acct)) { + property_tree::ptree& st(pt.put("account", "")); + + std::ostringstream buf; + buf.width(sizeof(unsigned long) * 2); + buf.fill('0'); + buf << std::hex << reinterpret_cast(&acct); + + st.put(".id", buf.str()); + + st.put("name", acct.name); + st.put("fullname", acct.fullname()); + + value_t total = acct.amount(); + if (! total.is_null()) { + property_tree::ptree& t(st.put("account-amount", "")); + put_value(t, total); + } + total = acct.total(); + if (! total.is_null()) { + property_tree::ptree& t(st.put("account-total", "")); + put_value(t, total); + } + + foreach (const accounts_map::value_type& pair, acct.accounts) + put_account(st, *pair.second, pred); + } +} + } // namespace ledger -- cgit v1.2.3