summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2003-10-01 23:06:13 +0000
committerJohn Wiegley <johnw@newartisans.com>2003-10-01 23:06:13 +0000
commit3afa81857a688cb2eca56945dc5c40b9825b2e69 (patch)
tree5baba699ae1cd1cfc143163fd14914f453533e01
parent637e28b5e7479a8f2b9c9f4350119ff663267aaf (diff)
downloadfork-ledger-3afa81857a688cb2eca56945dc5c40b9825b2e69.tar.gz
fork-ledger-3afa81857a688cb2eca56945dc5c40b9825b2e69.tar.bz2
fork-ledger-3afa81857a688cb2eca56945dc5c40b9825b2e69.zip
*** empty log message ***
-rw-r--r--balance.cc8
-rw-r--r--equity.cc4
-rw-r--r--gnucash.cc14
-rw-r--r--ledger.cc2
-rw-r--r--ledger.h23
5 files changed, 25 insertions, 26 deletions
diff --git a/balance.cc b/balance.cc
index 53f3ecf6..df8e2172 100644
--- a/balance.cc
+++ b/balance.cc
@@ -42,12 +42,12 @@ static bool account_matches(const account * acct,
}
static void display_total(std::ostream& out, totals& balance,
- const account * acct, bool top_level,
+ account * acct, bool top_level,
const std::list<mask>& regexps)
{
bool displayed = false;
- if (acct->display && (show_empty || acct->balance)) {
+ if (acct->checked == 1 && (show_empty || acct->balance)) {
displayed = true;
out << acct->balance;
@@ -65,7 +65,7 @@ static void display_total(std::ostream& out, totals& balance,
// Display balances for all child accounts
- for (account::const_iterator i = acct->children.begin();
+ for (accounts_iterator i = acct->children.begin();
i != acct->children.end();
i++)
display_total(out, balance, (*i).second, ! displayed, regexps);
@@ -134,7 +134,7 @@ void report_balances(int argc, char **argv, std::ostream& out)
else if (acct->checked == 3)
continue;
- acct->display = true;
+ acct->checked = 1;
acct->balance.credit((*x)->cost->street());
}
}
diff --git a/equity.cc b/equity.cc
index 3b80f166..16502ad1 100644
--- a/equity.cc
+++ b/equity.cc
@@ -2,7 +2,7 @@
namespace ledger {
-static void equity_entry(std::ostream& out, const account * acct,
+static void equity_entry(std::ostream& out, account * acct,
const std::list<mask>& regexps)
{
if (acct->balance &&
@@ -37,7 +37,7 @@ static void equity_entry(std::ostream& out, const account * acct,
// Display balances for all child accounts
- for (account::const_iterator i = acct->children.begin();
+ for (accounts_iterator i = acct->children.begin();
i != acct->children.end();
i++)
equity_entry(out, (*i).second, regexps);
diff --git a/gnucash.cc b/gnucash.cc
index 7400bdbe..357ba97d 100644
--- a/gnucash.cc
+++ b/gnucash.cc
@@ -139,8 +139,8 @@ static void dataHandler(void *userData, const char *s, int len)
accounts_iterator i = accounts_by_id.find(std::string(s, len));
assert(i != accounts_by_id.end());
curr_account->parent = (*i).second;
- (*i).second->children.insert(account::pair(curr_account->name,
- curr_account));
+ (*i).second->children.insert(accounts_entry(curr_account->name,
+ curr_account));
break;
}
@@ -239,12 +239,18 @@ bool parse_gnucash(std::istream& in, bool compute_balances)
{
char buf[BUFSIZ];
+ action = NO_ACTION;
+ do_compute = compute_balances;
curr_account = NULL;
curr_entry = NULL;
+ curr_value = NULL;
curr_comm = NULL;
- do_compute = compute_balances;
+ entry_comm = NULL;
- action = NO_ACTION;
+ // GnuCash uses the USD commodity without defining it, which really
+ // means to use $.
+ commodity * usd = new commodity("$", true, false, true, false, 2);
+ main_ledger.commodities.insert(commodities_entry("USD", usd));
XML_Parser parser = XML_ParserCreate(NULL);
current_parser = parser;
diff --git a/ledger.cc b/ledger.cc
index 7f4f161d..91f2a273 100644
--- a/ledger.cc
+++ b/ledger.cc
@@ -302,7 +302,7 @@ account * state::find_account(const char * name, bool create)
current = (*i).second;
}
} else {
- account::iterator i = current->children.find(tok);
+ accounts_iterator i = current->children.find(tok);
if (i == current->children.end()) {
if (! create)
return NULL;
diff --git a/ledger.h b/ledger.h
index 3c5badb5..5cb5e3f7 100644
--- a/ledger.h
+++ b/ledger.h
@@ -1,5 +1,5 @@
#ifndef _LEDGER_H
-#define _LEDGER_H "$Revision: 1.14 $"
+#define _LEDGER_H "$Revision: 1.15 $"
//////////////////////////////////////////////////////////////////////
//
@@ -275,29 +275,27 @@ operator<<(std::basic_ostream<char, Traits>& out, const totals& t) {
}
+typedef std::map<const std::string, account *> accounts_t;
+typedef accounts_t::iterator accounts_iterator;
+typedef std::pair<const std::string, account *> accounts_entry;
+
struct account
{
- struct account * parent;
+ account * parent;
std::string name;
commodity * comm; // default commodity for this account
totals balance;
- bool display;
int checked;
#ifdef HUQUQULLAH
bool exempt_or_necessary;
#endif
- typedef std::map<const std::string, struct account *> map;
- typedef map::iterator iterator;
- typedef map::const_iterator const_iterator;
- typedef std::pair<const std::string, struct account *> pair;
-
- map children;
+ accounts_t children;
account(const std::string& _name, struct account * _parent = NULL)
- : parent(_parent), name(_name), display(false), checked(0) {
+ : parent(_parent), name(_name), checked(0) {
#ifdef HUQUQULLAH
exempt_or_necessary = false;
#endif
@@ -318,11 +316,6 @@ operator<<(std::basic_ostream<char, Traits>& out, const account& a) {
}
-typedef std::map<const std::string, account *> accounts_t;
-typedef accounts_t::iterator accounts_iterator;
-typedef std::pair<const std::string, account *> accounts_entry;
-
-
struct state
{
commodities_t commodities;