summaryrefslogtreecommitdiff
path: root/src/account.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/account.cc')
-rw-r--r--src/account.cc32
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