diff options
author | John Wiegley <johnw@newartisans.com> | 2012-05-18 01:31:01 -0600 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2012-05-18 01:31:01 -0600 |
commit | a38ed141c1f33ecdad99b322acb1ae07b30a5da2 (patch) | |
tree | c6555946e2575a6bcb0ae7642673257954e38ac1 /src/account.cc | |
parent | 3c3bda19d62eed165b9191dbf1adcb3e7c975356 (diff) | |
download | fork-ledger-a38ed141c1f33ecdad99b322acb1ae07b30a5da2.tar.gz fork-ledger-a38ed141c1f33ecdad99b322acb1ae07b30a5da2.tar.bz2 fork-ledger-a38ed141c1f33ecdad99b322acb1ae07b30a5da2.zip |
Switched to Boost.PropertyTree for XML generation
Diffstat (limited to 'src/account.cc')
-rw-r--r-- | src/account.cc | 32 |
1 files changed, 32 insertions, 0 deletions
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<bool(const account_t&)> 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<unsigned long>(&acct); + + st.put("<xmlattr>.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 |