summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2006-07-20 02:17:48 +0000
committerJohn Wiegley <johnw@newartisans.com>2008-04-13 02:41:32 -0400
commitbec5f1c07af7948eb26a7cbafc6d191cfbb77d97 (patch)
tree69a72226d27a962fddfeb6a2901c3cb2bf1009b9
parent1368952f4cf51a195e4432a68ece87cd90b38a8b (diff)
downloadfork-ledger-bec5f1c07af7948eb26a7cbafc6d191cfbb77d97.tar.gz
fork-ledger-bec5f1c07af7948eb26a7cbafc6d191cfbb77d97.tar.bz2
fork-ledger-bec5f1c07af7948eb26a7cbafc6d191cfbb77d97.zip
*** empty log message ***
-rw-r--r--error.cc123
-rw-r--r--xml.h4
2 files changed, 4 insertions, 123 deletions
diff --git a/error.cc b/error.cc
deleted file mode 100644
index 6659a7bd..00000000
--- a/error.cc
+++ /dev/null
@@ -1,123 +0,0 @@
-#include "error.h"
-#include "value.h"
-#include "valexpr.h"
-#include "format.h"
-#include "journal.h"
-
-value_context::value_context(const ledger::value_t& _bal,
- const std::string& desc) throw()
- : bal(new ledger::value_t(_bal)), error_context(desc) {}
-
-value_context::~value_context() throw()
-{
- delete bal;
-}
-
-void value_context::describe(std::ostream& out) const throw()
-{
- if (! desc.empty())
- out << desc << std::endl;
-
- ledger::balance_t * ptr = NULL;
-
- out << std::right;
- out.width(20);
-
- switch (bal->type) {
- case ledger::value_t::BOOLEAN:
- out << (*((bool *) bal->data) ? "true" : "false");
- break;
- case ledger::value_t::INTEGER:
- out << *((long *) bal->data);
- break;
- case ledger::value_t::DATETIME:
- out << *((datetime_t *) bal->data);
- break;
- case ledger::value_t::AMOUNT:
- out << *((ledger::amount_t *) bal->data);
- break;
- case ledger::value_t::BALANCE:
- ptr = (ledger::balance_t *) bal->data;
- // fall through...
-
- case ledger::value_t::BALANCE_PAIR:
- if (! ptr)
- ptr = &((ledger::balance_pair_t *) bal->data)->quantity;
-
- ptr->write(out, 20);
- break;
- default:
- assert(0);
- break;
- }
- out << std::endl;
-}
-
-valexpr_context::valexpr_context(const ledger::value_expr_t * _expr,
- const std::string& desc) throw()
- : expr(NULL), error_node(_expr), error_context(desc)
-{
- error_node->acquire();
-}
-
-valexpr_context::~valexpr_context() throw()
-{
- if (expr) expr->release();
- if (error_node) error_node->release();
-}
-
-void valexpr_context::describe(std::ostream& out) const throw()
-{
- if (! expr) {
- out << "Valexpr_context expr not set!" << std::endl;
- return;
- }
-
- if (! desc.empty())
- out << desc << std::endl;
-
- out << " ";
- unsigned long start = out.tellp();
- unsigned long pos = ledger::write_value_expr(out, expr,
- error_node, start);
- out << std::endl << " ";
- for (int i = 0; i < pos - start; i++)
- out << " ";
- out << "^" << std::endl;
-}
-
-void line_context::describe(std::ostream& out) const throw()
-{
- if (! desc.empty())
- out << desc << std::endl;
-
- out << " " << line << std::endl << " ";
- long idx = pos < 0 ? line.length() - 1 : pos;
- for (int i = 0; i < idx; i++)
- out << " ";
- out << "^" << std::endl;
-}
-
-void entry_context::describe(std::ostream& out) const throw()
-{
- if (! desc.empty())
- out << desc << std::endl;
-
- ledger::print_entry(out, entry, " ");
-}
-
-xact_context::xact_context(const ledger::transaction_t& _xact,
- const std::string& desc) throw()
- : xact(_xact), file_context("", 0, desc)
-{
- const ledger::strings_list& sources(xact.entry->journal->sources);
- int x = 0;
- for (ledger::strings_list::const_iterator i = sources.begin();
- i != sources.end();
- i++, x++)
- if (x == xact.entry->src_idx) {
- file = *i;
- break;
- }
- line = xact.beg_line;
-}
diff --git a/xml.h b/xml.h
index 17b01bb7..13bf317c 100644
--- a/xml.h
+++ b/xml.h
@@ -6,6 +6,8 @@
namespace ledger {
+#if defined(HAVE_EXPAT) || defined(HAVE_XMLPARSE)
+
class xml_parser_t : public parser_t
{
public:
@@ -18,6 +20,8 @@ class xml_parser_t : public parser_t
const std::string * original_file = NULL);
};
+#endif
+
class format_xml_entries : public format_entries
{
bool show_totals;