summaryrefslogtreecommitdiff
path: root/src/commodity.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2012-05-18 01:31:01 -0600
committerJohn Wiegley <johnw@newartisans.com>2012-05-18 01:31:01 -0600
commita38ed141c1f33ecdad99b322acb1ae07b30a5da2 (patch)
treec6555946e2575a6bcb0ae7642673257954e38ac1 /src/commodity.cc
parent3c3bda19d62eed165b9191dbf1adcb3e7c975356 (diff)
downloadfork-ledger-a38ed141c1f33ecdad99b322acb1ae07b30a5da2.tar.gz
fork-ledger-a38ed141c1f33ecdad99b322acb1ae07b30a5da2.tar.bz2
fork-ledger-a38ed141c1f33ecdad99b322acb1ae07b30a5da2.zip
Switched to Boost.PropertyTree for XML generation
Diffstat (limited to 'src/commodity.cc')
-rw-r--r--src/commodity.cc31
1 files changed, 12 insertions, 19 deletions
diff --git a/src/commodity.cc b/src/commodity.cc
index a72d85c8..54459155 100644
--- a/src/commodity.cc
+++ b/src/commodity.cc
@@ -496,29 +496,22 @@ bool commodity_t::compare_by_commodity::operator()(const amount_t * left,
}
}
-void to_xml(std::ostream& out, const commodity_t& comm,
- bool commodity_details)
+void put_commodity(property_tree::ptree& pt, const commodity_t& comm,
+ bool commodity_details)
{
- push_xml x(out, "commodity", true);
+ property_tree::ptree& st(pt.put("commodity", ""));
- 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_DECIMAL_COMMA)) out << 'D';
- out << '"';
+ std::string flags;
+ if (! (comm.has_flags(COMMODITY_STYLE_SUFFIXED))) flags += 'P';
+ if (comm.has_flags(COMMODITY_STYLE_SEPARATED)) flags += 'S';
+ if (comm.has_flags(COMMODITY_STYLE_THOUSANDS)) flags += 'T';
+ if (comm.has_flags(COMMODITY_STYLE_DECIMAL_COMMA)) flags += 'D';
+ st.put("<xmlattr>.flags", flags);
- x.close_attrs();
+ st.put("symbol", comm.symbol());
- {
- push_xml y(out, "symbol");
- out << y.guard(comm.symbol());
- }
-
- if (commodity_details) {
- if (comm.has_annotation())
- to_xml(out, as_annotated_commodity(comm).details);
- }
+ if (commodity_details && comm.has_annotation())
+ put_annotation(st, as_annotated_commodity(comm).details);
}
} // namespace ledger