summaryrefslogtreecommitdiff
path: root/binary.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2005-01-14 23:20:34 +0000
committerJohn Wiegley <johnw@newartisans.com>2008-04-13 02:40:49 -0400
commitc59a5c9f86c2eaaddf6d4cff5e1ae69721d8c709 (patch)
tree079a6e9ea4d18833e3f0522ef152bba18135541f /binary.cc
parentcb15e764eb1ba9064ef2c1f750735d47696d3fd0 (diff)
downloadfork-ledger-c59a5c9f86c2eaaddf6d4cff5e1ae69721d8c709.tar.gz
fork-ledger-c59a5c9f86c2eaaddf6d4cff5e1ae69721d8c709.tar.bz2
fork-ledger-c59a5c9f86c2eaaddf6d4cff5e1ae69721d8c709.zip
Updated binary file version. (read_binary_journal): Read in the
default commodity. (write_binary_journal): Write out the default commodity.
Diffstat (limited to 'binary.cc')
-rw-r--r--binary.cc14
1 files changed, 13 insertions, 1 deletions
diff --git a/binary.cc b/binary.cc
index 7b97a21c..6b38a2c5 100644
--- a/binary.cc
+++ b/binary.cc
@@ -11,7 +11,7 @@
namespace ledger {
static unsigned long binary_magic_number = 0xFFEED765;
-static unsigned long format_version = 0x00020027;
+static unsigned long format_version = 0x00020028;
static account_t ** accounts;
static account_t ** accounts_next;
@@ -414,6 +414,13 @@ unsigned int read_binary_journal(std::istream& in,
for (commodity_t::ident_t i = 0; i < c_count; i++)
read_binary_commodity_extra(data, i);
+ commodity_t::ident_t ident;
+ read_binary_number(data, ident);
+ if (ident == 0xffffffff || ident == 0)
+ commodity_t::default_commodity = NULL;
+ else
+ commodity_t::default_commodity = commodities[ident - 1];
+
// Read in the entries and transactions
for (unsigned long i = 0; i < count; i++) {
@@ -692,6 +699,11 @@ void write_binary_journal(std::ostream& out, journal_t * journal,
if (! (*i).first.empty())
write_binary_commodity_extra(out, (*i).second);
+ if (commodity_t::default_commodity)
+ write_binary_number(out, commodity_t::default_commodity->ident);
+ else
+ write_binary_number<commodity_t::ident_t>(out, 0xffffffff);
+
// Write out the entries and transactions
unsigned long xact_count = 0;