diff options
author | John Wiegley <johnw@newartisans.com> | 2009-11-09 13:25:45 -0500 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2009-11-09 13:25:45 -0500 |
commit | 865c0ff828f88ed1d00eea73a3fc55b3e57d21b3 (patch) | |
tree | 5acdfae32811b25fb46271bf349a216bea41fddb /src/value.cc | |
parent | 55c7792c9329f97dd19fc5aeca466cb2de4fbf9c (diff) | |
parent | 9b396b41220646cf73fcd2a8afebcee06dde2a29 (diff) | |
download | fork-ledger-865c0ff828f88ed1d00eea73a3fc55b3e57d21b3.tar.gz fork-ledger-865c0ff828f88ed1d00eea73a3fc55b3e57d21b3.tar.bz2 fork-ledger-865c0ff828f88ed1d00eea73a3fc55b3e57d21b3.zip |
Merge branch 'next'
Diffstat (limited to 'src/value.cc')
-rw-r--r-- | src/value.cc | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/src/value.cc b/src/value.cc index e2c9dc8b..b4060a1c 100644 --- a/src/value.cc +++ b/src/value.cc @@ -1746,4 +1746,57 @@ 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) +{ + switch (value.type()) { + case value_t::VOID: + out << "<void />"; + break; + case value_t::BOOLEAN: { + push_xml y(out, "boolean"); + out << (value.as_boolean() ? "true" : "false"); + break; + } + case value_t::INTEGER: { + push_xml y(out, "integer"); + out << value.as_long(); + break; + } + + case value_t::AMOUNT: + to_xml(out, value.as_amount()); + break; + case value_t::BALANCE: + to_xml(out, value.as_balance()); + break; + + case value_t::DATETIME: + to_xml(out, value.as_datetime()); + break; + case value_t::DATE: + to_xml(out, value.as_date()); + break; + case value_t::STRING: { + push_xml y(out, "string"); + out << y.guard(value.as_string()); + break; + } + case value_t::MASK: + to_xml(out, value.as_mask()); + break; + + case value_t::SEQUENCE: { + push_xml y(out, "sequence"); + foreach (const value_t& member, value.as_sequence()) + to_xml(out, member); + break; + } + + case value_t::SCOPE: + default: + assert(false); + break; + } +} + } // namespace ledger |