diff options
author | John Wiegley <johnw@newartisans.com> | 2008-07-20 23:28:29 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2008-07-20 23:28:29 -0400 |
commit | 0a1bce0f8073cb40c0ca51046173d98f267074ea (patch) | |
tree | fab0daf0a27c73b5becb59d05c6924db1b8214af | |
parent | d86a91d45b837d1d32e943107c856497897cc85c (diff) | |
download | fork-ledger-0a1bce0f8073cb40c0ca51046173d98f267074ea.tar.gz fork-ledger-0a1bce0f8073cb40c0ca51046173d98f267074ea.tar.bz2 fork-ledger-0a1bce0f8073cb40c0ca51046173d98f267074ea.zip |
Re-enabled almost all of the code in main.cc.
-rw-r--r-- | amount.cc | 1 | ||||
-rw-r--r-- | binary.h | 13 | ||||
-rw-r--r-- | main.cc | 46 | ||||
-rw-r--r-- | parser.h | 12 | ||||
-rw-r--r-- | parsexp.cc | 1 | ||||
-rw-r--r-- | utils.h | 2 |
6 files changed, 35 insertions, 40 deletions
@@ -43,6 +43,7 @@ #include "amount.h" #include "parser.h" +#include "binary.h" namespace ledger { @@ -275,6 +275,19 @@ inline void write_object(std::ostream& out, const T& journal) { void write_journal(std::ostream& out, journal_t * journal); } // namespace binary + +class binary_parser_t : public parser_t +{ + public: + virtual bool test(std::istream& in) const; + + virtual unsigned int parse(std::istream& in, + config_t& config, + journal_t * journal, + account_t * master = NULL, + const path * original_file = NULL); +}; + } // namespace ledger #endif // BINARY_H @@ -31,11 +31,11 @@ #include "utils.h" #include "option.h" -//#if defined(HAVE_EXPAT) || defined(HAVE_XMLPARSE) -//#include "gnucash.h" -//#endif -//#include "qif.h" -//#include "ofx.h" +#if defined(HAVE_EXPAT) || defined(HAVE_XMLPARSE) +#include "gnucash.h" +#endif +#include "qif.h" +#include "ofx.h" #include <ledger.h> @@ -313,10 +313,8 @@ static int read_and_report(ledger::report_t& report, int argc, char * argv[], if (session.use_cache && session.cache_dirty && session.cache_file) { TRACE_START(binary_cache, 1, "Wrote binary journal file"); -#if 0 ofstream stream(*session.cache_file); - write_binary_journal(stream, journal); -#endif + binary::write_journal(stream, journal); TRACE_FINISH(binary_cache, 1); } @@ -389,17 +387,15 @@ int main(int argc, char * argv[], char * envp[]) ledger::set_session_context(session.get()); -#if 0 - session->register_parser(new binary_parser_t); + session->register_parser(new ledger::binary_parser_t); #if defined(HAVE_EXPAT) || defined(HAVE_XMLPARSE) - session->register_parser(new xml::xml_parser_t); - session->register_parser(new gnucash_parser_t); + session->register_parser(new ledger::xml_parser_t); + session->register_parser(new ledger::gnucash_parser_t); #endif #ifdef HAVE_LIBOFX - session->register_parser(new ofx_parser_t); -#endif - session->register_parser(new qif_parser_t); + session->register_parser(new ledger::ofx_parser_t); #endif + session->register_parser(new ledger::qif_parser_t); session->register_parser(new ledger::textual_parser_t); std::auto_ptr<ledger::report_t> report(new ledger::report_t(*session.get())); @@ -413,31 +409,29 @@ int main(int argc, char * argv[], char * envp[]) session.release(); } } -#if 0 - catch (error * err) { + catch (ledger::error * err) { std::cout.flush(); // Push a null here since there's no file context if (err->context.empty() || - ! dynamic_cast<xact_context *>(err->context.front())) - err->context.push_front(new error_context("")); + ! dynamic_cast<ledger::xact_context *>(err->context.front())) + err->context.push_front(new ledger::error_context("")); err->reveal_context(std::cerr, "Error"); std::cerr << err->what() << std::endl; - checked_delete(err); + ledger::checked_delete(err); } - catch (fatal * err) { + catch (ledger::fatal * err) { std::cout.flush(); // Push a null here since there's no file context if (err->context.empty() || - ! dynamic_cast<xact_context *>(err->context.front())) - err->context.push_front(new error_context("")); + ! dynamic_cast<ledger::xact_context *>(err->context.front())) + err->context.push_front(new ledger::error_context("")); err->reveal_context(std::cerr, "Fatal"); std::cerr << err->what() << std::endl; - checked_delete(err); + ledger::checked_delete(err); } -#endif catch (const std::exception& err) { std::cout.flush(); - std::cerr << "Error: " << err.what() << std::endl; + std::cerr << "Exception: " << err.what() << std::endl; } catch (int _status) { status = _status; @@ -23,18 +23,6 @@ class parser_t const path * original_file = NULL) = 0; }; -class binary_parser_t : public parser_t -{ -public: - virtual bool test(std::istream& in) const; - - virtual unsigned int parse(std::istream& in, - config_t& config, - journal_t * journal, - account_t * master = NULL, - const path * original_file = NULL); -}; - bool register_parser(parser_t * parser); bool unregister_parser(parser_t * parser); @@ -30,6 +30,7 @@ */ #include "parsexp.h" +#include "parser.h" namespace ledger { namespace expr { @@ -503,13 +503,11 @@ inline void throw_unexpected_error(char, char) { * * Date/time support classes * General support for objects with "flags" - * Support for object serialization (binary read/write) * Support for scoped execution and variable restoration */ #include "times.h" #include "flags.h" -#include "binary.h" #include "pushvar.h" /********************************************************************** |