summaryrefslogtreecommitdiff
path: root/src/value.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-10-25 05:13:21 -0400
committerJohn Wiegley <johnw@newartisans.com>2009-11-09 02:17:26 -0500
commit2c80227339538154ad0869e746f52db805325589 (patch)
tree091188e3ad5c8cc41e3f94285969ef9849a97ac4 /src/value.cc
parent7411c74d6d5bea42cb9fa5b6b0ed90480c954a03 (diff)
downloadfork-ledger-2c80227339538154ad0869e746f52db805325589.tar.gz
fork-ledger-2c80227339538154ad0869e746f52db805325589.tar.bz2
fork-ledger-2c80227339538154ad0869e746f52db805325589.zip
Added basic foundation for XML reporting
Diffstat (limited to 'src/value.cc')
-rw-r--r--src/value.cc54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/value.cc b/src/value.cc
index e2c9dc8b..2029b9c5 100644
--- a/src/value.cc
+++ b/src/value.cc
@@ -1746,4 +1746,58 @@ 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)
+{
+ push_xml x(out, "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::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::AMOUNT:
+ to_xml(out, value.as_amount());
+ break;
+ case value_t::BALANCE:
+ to_xml(out, value.as_balance());
+ break;
+
+ case value_t::SCOPE:
+ default:
+ assert(false);
+ break;
+ }
+}
+
} // namespace ledger