summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2008-07-20 23:28:29 -0400
committerJohn Wiegley <johnw@newartisans.com>2008-07-20 23:28:29 -0400
commit0a1bce0f8073cb40c0ca51046173d98f267074ea (patch)
treefab0daf0a27c73b5becb59d05c6924db1b8214af
parentd86a91d45b837d1d32e943107c856497897cc85c (diff)
downloadfork-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.cc1
-rw-r--r--binary.h13
-rw-r--r--main.cc46
-rw-r--r--parser.h12
-rw-r--r--parsexp.cc1
-rw-r--r--utils.h2
6 files changed, 35 insertions, 40 deletions
diff --git a/amount.cc b/amount.cc
index 46b0fbb4..57f5942a 100644
--- a/amount.cc
+++ b/amount.cc
@@ -43,6 +43,7 @@
#include "amount.h"
#include "parser.h"
+#include "binary.h"
namespace ledger {
diff --git a/binary.h b/binary.h
index 852dfe56..6a9b73ac 100644
--- a/binary.h
+++ b/binary.h
@@ -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
diff --git a/main.cc b/main.cc
index cd22e58b..81567661 100644
--- a/main.cc
+++ b/main.cc
@@ -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;
diff --git a/parser.h b/parser.h
index d63ebcf0..edf0cdda 100644
--- a/parser.h
+++ b/parser.h
@@ -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);
diff --git a/parsexp.cc b/parsexp.cc
index e076c0b1..dc58c91f 100644
--- a/parsexp.cc
+++ b/parsexp.cc
@@ -30,6 +30,7 @@
*/
#include "parsexp.h"
+#include "parser.h"
namespace ledger {
namespace expr {
diff --git a/utils.h b/utils.h
index c0e880a2..124f9846 100644
--- a/utils.h
+++ b/utils.h
@@ -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"
/**********************************************************************