diff options
author | John Wiegley <johnw@newartisans.com> | 2004-08-19 22:03:23 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2004-08-19 22:03:23 -0400 |
commit | a9b207205f5d117db4f6a5d503ba7289882dec2d (patch) | |
tree | 81935d2cfd538cf782638ffb7cbd36dc9033baed /binary.cc | |
parent | 9d4f8392632481ce5e174a4ebe52d4cb339b95dc (diff) | |
download | fork-ledger-a9b207205f5d117db4f6a5d503ba7289882dec2d.tar.gz fork-ledger-a9b207205f5d117db4f6a5d503ba7289882dec2d.tar.bz2 fork-ledger-a9b207205f5d117db4f6a5d503ba7289882dec2d.zip |
several fixes
Diffstat (limited to 'binary.cc')
-rw-r--r-- | binary.cc | 20 |
1 files changed, 19 insertions, 1 deletions
@@ -1,4 +1,5 @@ #include "ledger.h" +#include "binary.h" #include <vector> #include <fstream> @@ -16,6 +17,15 @@ namespace ledger { const unsigned long binary_magic_number = 0xFFEED765; static const unsigned long format_version = 0x0002000b; +bool binary_parser_t::test(std::istream& in) const +{ + unsigned long magic; + in.read((char *)&magic, sizeof(magic)); + in.seekg(0); + + return magic == binary_magic_number; +} + static std::vector<account_t *> accounts; static account_t::ident_t ident; static std::vector<commodity_t *> commodities; @@ -118,7 +128,7 @@ entry_t * read_binary_entry(std::istream& in, journal_t * journal) i < count; i++) { transaction_t * xact = read_binary_transaction(in, entry); - entry->transactions.push_back(xact); + entry->add_transaction(xact); } return entry; @@ -252,6 +262,14 @@ unsigned int read_binary_journal(std::istream& in, return count; } +unsigned int binary_parser_t::parse(std::istream& in, + journal_t * journal, + account_t * master, + const std::string * original_file) +{ + return read_binary_journal(in, original_file ? *original_file : "", + journal, master); +} #if RELEASE_LEVEL >= ALPHA #define write_binary_guard(in, id) { \ |