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/value.cc | 38 +++++++++++++++----------------------- 1 file changed, 15 insertions(+), 23 deletions(-) (limited to 'src/value.cc') 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& 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 << ""; + 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; } -- cgit v1.2.3