diff options
Diffstat (limited to 'src/session.cc')
-rw-r--r-- | src/session.cc | 99 |
1 files changed, 41 insertions, 58 deletions
diff --git a/src/session.cc b/src/session.cc index b0d31be9..b4fb4eb8 100644 --- a/src/session.cc +++ b/src/session.cc @@ -37,7 +37,6 @@ #include "journal.h" #include "iterators.h" #include "filters.h" -#include "archive.h" namespace ledger { @@ -129,56 +128,13 @@ std::size_t session_t::read_data(const string& master_account) if (HANDLED(value_expr_)) journal->value_expr = HANDLER(value_expr_).str(); -#if HAVE_BOOST_SERIALIZATION - optional<archive_t> cache; - if (HANDLED(cache_) && master_account.empty()) - cache = archive_t(HANDLED(cache_).str()); - - if (! (cache && - cache->should_load(HANDLER(file_).data_files) && - cache->load(*journal.get()))) { -#endif // HAVE_BOOST_SERIALIZATION - if (price_db_path) { - if (exists(*price_db_path)) { - parsing_context.push(*price_db_path); - parsing_context.get_current().journal = journal.get(); - try { - if (journal->read(parsing_context) > 0) - throw_(parse_error, _("Transactions not allowed in price history file")); - } - catch (...) { - parsing_context.pop(); - throw; - } - parsing_context.pop(); - } - } - - foreach (const path& pathname, HANDLER(file_).data_files) { - if (pathname == "-" || pathname == "/dev/stdin") { - // To avoid problems with stdin and pipes, etc., we read the entire - // file in beforehand into a memory buffer, and then parcel it out - // from there. - std::ostringstream buffer; - - while (std::cin.good() && ! std::cin.eof()) { - char line[8192]; - std::cin.read(line, 8192); - std::streamsize count = std::cin.gcount(); - buffer.write(line, count); - } - buffer.flush(); - - shared_ptr<std::istream> stream(new std::istringstream(buffer.str())); - parsing_context.push(stream); - } else { - parsing_context.push(pathname); - } - + if (price_db_path) { + if (exists(*price_db_path)) { + parsing_context.push(*price_db_path); parsing_context.get_current().journal = journal.get(); - parsing_context.get_current().master = acct; try { - xact_count += journal->read(parsing_context); + if (journal->read(parsing_context) > 0) + throw_(parse_error, _("Transactions not allowed in price history file")); } catch (...) { parsing_context.pop(); @@ -186,16 +142,44 @@ std::size_t session_t::read_data(const string& master_account) } parsing_context.pop(); } + } + + foreach (const path& pathname, HANDLER(file_).data_files) { + if (pathname == "-" || pathname == "/dev/stdin") { + // To avoid problems with stdin and pipes, etc., we read the entire + // file in beforehand into a memory buffer, and then parcel it out + // from there. + std::ostringstream buffer; + + while (std::cin.good() && ! std::cin.eof()) { + char line[8192]; + std::cin.read(line, 8192); + std::streamsize count = std::cin.gcount(); + buffer.write(line, count); + } + buffer.flush(); - DEBUG("ledger.read", "xact_count [" << xact_count - << "] == journal->xacts.size() [" << journal->xacts.size() << "]"); - assert(xact_count == journal->xacts.size()); + shared_ptr<std::istream> stream(new std::istringstream(buffer.str())); + parsing_context.push(stream); + } else { + parsing_context.push(pathname); + } -#if HAVE_BOOST_SERIALIZATION - if (cache && cache->should_save(*journal.get())) - cache->save(*journal.get()); + parsing_context.get_current().journal = journal.get(); + parsing_context.get_current().master = acct; + try { + xact_count += journal->read(parsing_context); + } + catch (...) { + parsing_context.pop(); + throw; + } + parsing_context.pop(); } -#endif // HAVE_BOOST_SERIALIZATION + + DEBUG("ledger.read", "xact_count [" << xact_count + << "] == journal->xacts.size() [" << journal->xacts.size() << "]"); + assert(xact_count == journal->xacts.size()); if (populated_data_files) HANDLER(file_).data_files.clear(); @@ -333,8 +317,7 @@ option_t<session_t> * session_t::lookup_option(const char * p) OPT_CH(price_exp_); break; case 'c': - OPT(cache_); - else OPT(check_payees); + OPT(check_payees); break; case 'd': OPT(download); // -Q |