summaryrefslogtreecommitdiff
path: root/binary.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2006-03-04 18:34:29 +0000
committerJohn Wiegley <johnw@newartisans.com>2008-04-13 02:41:29 -0400
commitd02f74efea3e6b631810bfd3c3d8adcaa4299902 (patch)
treef8c8f5f62b4144d0af1ebc7321903736551ee21b /binary.cc
parent326235ffbe2fcaf3fe612b8852051f7dae08c47f (diff)
downloadfork-ledger-d02f74efea3e6b631810bfd3c3d8adcaa4299902.tar.gz
fork-ledger-d02f74efea3e6b631810bfd3c3d8adcaa4299902.tar.bz2
fork-ledger-d02f74efea3e6b631810bfd3c3d8adcaa4299902.zip
*** empty log message ***
Diffstat (limited to 'binary.cc')
-rw-r--r--binary.cc18
1 files changed, 14 insertions, 4 deletions
diff --git a/binary.cc b/binary.cc
index f5d9c467..8816078d 100644
--- a/binary.cc
+++ b/binary.cc
@@ -12,9 +12,9 @@ namespace ledger {
static unsigned long binary_magic_number = 0xFFEED765;
#ifdef DEBUG_ENABLED
-static unsigned long format_version = 0x00020605;
+static unsigned long format_version = 0x00020607;
#else
-static unsigned long format_version = 0x00020604;
+static unsigned long format_version = 0x00020606;
#endif
static account_t ** accounts;
@@ -475,6 +475,8 @@ inline commodity_t * read_binary_commodity_annotated(char *& data)
read_binary_string(data, commodity->qualified_symbol);
commodity->annotated = true;
+ commodity->base =
+ commodities[read_binary_long<commodity_t::ident_t>(data) - 1];
read_binary_amount(data, commodity->price);
read_binary_long(data, commodity->date);
read_binary_string(data, commodity->tag);
@@ -998,6 +1000,7 @@ void write_binary_commodity_annotated(std::ostream& out,
annotated_commodity_t * ann_comm =
static_cast<annotated_commodity_t *>(commodity);
+ write_binary_long(out, ann_comm->base->ident);
write_binary_amount(out, ann_comm->price);
write_binary_long(out, ann_comm->date);
write_binary_string(out, ann_comm->tag);
@@ -1116,10 +1119,17 @@ void write_binary_journal(std::ostream& out, journal_t * journal)
for (commodities_map::const_iterator i = commodity_t::commodities.begin();
i != commodity_t::commodities.end();
i++) {
- write_binary_number<char>(out, (*i).second->annotated ? 1 : 0);
if (! (*i).second->annotated) {
+ write_binary_number<char>(out, 0);
write_binary_commodity(out, (*i).second);
- } else {
+ }
+ }
+
+ for (commodities_map::const_iterator i = commodity_t::commodities.begin();
+ i != commodity_t::commodities.end();
+ i++) {
+ if ((*i).second->annotated) {
+ write_binary_number<char>(out, 1);
write_binary_string(out, (*i).first); // the mapping key
write_binary_commodity_annotated(out, (*i).second);
}