diff options
author | John Wiegley <johnw@newartisans.com> | 2004-08-21 15:55:03 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2004-08-21 15:55:03 -0400 |
commit | 000bfe1cece3ecbfee8f07a46d1f0b000dbbc983 (patch) | |
tree | 6d2c666097900fff421da6a57b41f0a7c43a39b7 /binary.cc | |
parent | 225acd14e57a0a476ce022a7c5703a8f1cee34ef (diff) | |
download | fork-ledger-000bfe1cece3ecbfee8f07a46d1f0b000dbbc983.tar.gz fork-ledger-000bfe1cece3ecbfee8f07a46d1f0b000dbbc983.tar.bz2 fork-ledger-000bfe1cece3ecbfee8f07a46d1f0b000dbbc983.zip |
only compute the cost when it differs from the amount
Diffstat (limited to 'binary.cc')
-rw-r--r-- | binary.cc | 14 |
1 files changed, 11 insertions, 3 deletions
@@ -9,7 +9,7 @@ namespace ledger { const unsigned long binary_magic_number = 0xFFEED765; -static const unsigned long format_version = 0x0002000e; +static const unsigned long format_version = 0x00020010; bool binary_parser_t::test(std::istream& in) const { @@ -102,7 +102,10 @@ transaction_t * read_binary_transaction(std::istream& in, entry_t * entry) xact->account->add_transaction(xact); read_binary_amount(in, xact->amount); - read_binary_amount(in, xact->cost); + if (read_binary_number<char>(in) == 1) { + xact->cost = new amount_t; + read_binary_amount(in, *xact->cost); + } read_binary_number(in, xact->flags); read_binary_string(in, xact->note); @@ -314,7 +317,12 @@ void write_binary_transaction(std::ostream& out, transaction_t * xact) { write_binary_number(out, xact->account->ident); write_binary_amount(out, xact->amount); - write_binary_amount(out, xact->cost); + if (xact->cost) { + write_binary_number<char>(out, 1); + write_binary_amount(out, *xact->cost); + } else { + write_binary_number<char>(out, 0); + } write_binary_number(out, xact->flags); write_binary_string(out, xact->note); } |