summaryrefslogtreecommitdiff
path: root/src/value.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/value.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/value.cc')
-rw-r--r--src/value.cc38
1 files changed, 15 insertions, 23 deletions
diff --git a/src/value.cc b/src/value.cc
index b475b6a2..832460ce 100644
--- a/src/value.cc
+++ b/src/value.cc
@@ -2014,49 +2014,41 @@ bool sort_value_is_less_than(const std::list<sort_value_t>& left_values,
return false;
}
-void to_xml(std::ostream& out, const value_t& value)
+void put_value(property_tree::ptree& pt, const value_t& value)
{
switch (value.type()) {
case value_t::VOID:
- out << "<void />";
+ pt.put("void", "");
break;
- case value_t::BOOLEAN: {
- push_xml y(out, "boolean");
- out << (value.as_boolean() ? "true" : "false");
+ case value_t::BOOLEAN:
+ pt.put("bool", value.as_boolean() ? "true" : "false");
break;
- }
- case value_t::INTEGER: {
- push_xml y(out, "integer");
- out << value.as_long();
+ case value_t::INTEGER:
+ pt.put("int", value.to_string());
break;
- }
-
case value_t::AMOUNT:
- to_xml(out, value.as_amount());
+ put_amount(pt, value.as_amount());
break;
case value_t::BALANCE:
- to_xml(out, value.as_balance());
+ put_balance(pt, value.as_balance());
break;
-
case value_t::DATETIME:
- to_xml(out, value.as_datetime());
+ put_datetime(pt, value.as_datetime());
break;
case value_t::DATE:
- to_xml(out, value.as_date());
+ put_date(pt, value.as_date());
break;
- case value_t::STRING: {
- push_xml y(out, "string");
- out << y.guard(value.as_string());
+ case value_t::STRING:
+ pt.put("string", value.as_string());
break;
- }
case value_t::MASK:
- to_xml(out, value.as_mask());
+ put_mask(pt, value.as_mask());
break;
case value_t::SEQUENCE: {
- push_xml y(out, "sequence");
+ property_tree::ptree& st(pt.put("sequence", ""));
foreach (const value_t& member, value.as_sequence())
- to_xml(out, member);
+ put_value(st, member);
break;
}