summaryrefslogtreecommitdiff
path: root/src/value.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/value.cc')
-rw-r--r--src/value.cc146
1 files changed, 0 insertions, 146 deletions
diff --git a/src/value.cc b/src/value.cc
index 9f14038f..13b90057 100644
--- a/src/value.cc
+++ b/src/value.cc
@@ -30,7 +30,6 @@
*/
#include "value.h"
-#include "binary.h"
namespace ledger {
@@ -1767,151 +1766,6 @@ void value_t::print(std::ostream& out, const bool relaxed) const
}
}
-void value_t::read(std::istream& in)
-{
- switch (static_cast<value_t::type_t>(binary::read_long<int>(in))) {
- case BOOLEAN:
- set_boolean(binary::read_bool(in));
- break;
- case INTEGER:
- set_long(binary::read_long<long>(in));
- break;
- case DATETIME:
- set_datetime(parse_datetime(binary::read_string(in)));
- break;
- case DATE:
- set_date(parse_date(binary::read_string(in)));
- break;
- case AMOUNT: {
- amount_t temp;
- temp.read(in);
- set_amount(temp);
- break;
- }
- default:
- break;
- }
-
- throw_(value_error, "Cannot read " << label() << " from a stream");
-}
-
-void value_t::read(const char *& data)
-{
- switch (static_cast<value_t::type_t>(binary::read_long<int>(data))) {
- case BOOLEAN:
- set_boolean(binary::read_bool(data));
- break;
- case INTEGER:
- set_long(binary::read_long<long>(data));
- break;
- case DATETIME:
- set_datetime(parse_datetime(binary::read_string(data)));
- break;
- case DATE:
- set_date(parse_date(binary::read_string(data)));
- break;
- case AMOUNT: {
- amount_t temp;
- temp.read(data);
- set_amount(temp);
- break;
- }
- default:
- break;
- }
-
- throw_(value_error, "Cannot read " << label() << " from a stream");
-}
-
-void value_t::write(std::ostream& out) const
-{
- binary::write_long(out, static_cast<int>(type()));
-
- switch (type()) {
- case BOOLEAN:
- binary::write_bool(out, as_boolean());
- break;
- case INTEGER:
- binary::write_long(out, as_long());
- break;
- case DATETIME:
- binary::write_string(out, format_datetime(as_datetime()));
- break;
- case DATE:
- binary::write_string(out, format_date(as_date()));
- break;
- case AMOUNT:
- as_amount().write(out);
- break;
- default:
- break;
- }
-
- throw_(value_error, "Cannot write " << label() << " to a stream");
-}
-
-void value_t::write_xml(std::ostream& out, const int depth) const
-{
- out << xml_str("<value>\n", depth);
-
- switch (type()) {
- case VOID:
- out << xml_str("<void />\n", depth + 1);
- break;
- case BOOLEAN:
- out << xml_str("<bool>", depth + 1)
- << (as_boolean() ? "true" : "false")
- << "</bool>\n";
- break;
- case DATETIME:
- out << xml_str("<datetime>", depth + 1)
- << format_datetime(as_datetime())
- << "</datetime>\n";
- break;
- case DATE:
- out << xml_str("<date>", depth + 1)
- << format_date(as_date())
- << "</date>\n";
- break;
- case INTEGER:
- out << xml_str("<integer>", depth + 1)
- << as_long()
- << "</integer>\n";
- break;
- case AMOUNT:
- as_amount().write_xml(out, depth + 1);
- break;
- case BALANCE:
- as_balance().write_xml(out, depth + 1);
- break;
- case BALANCE_PAIR:
- as_balance_pair().write_xml(out, depth + 1);
- break;
- case STRING:
- out << xml_str("<string>", depth + 1)
- << as_string()
- << "</string>\n";
- break;
- case MASK:
- out << xml_str("<mask>", depth + 1)
- << as_mask()
- << "</mask>\n";
- break;
- case SEQUENCE:
- out << xml_str("<sequence>\n", depth + 1);
- foreach (const value_t& v, as_sequence())
- v.write_xml(out, depth + 2);
- out << xml_str("</sequence>\n", depth + 1);
- break;
- case POINTER:
- default:
- throw_(value_error, "Cannot output " << label() << " as XML");
- break;
- }
-
- out << xml_str("</value>\n", depth);
-}
-
bool value_t::valid() const
{
switch (type()) {