*** empty log message ***

This commit is contained in:
John Wiegley 2003-10-01 23:06:13 +00:00
parent 637e28b5e7
commit 3afa81857a
5 changed files with 25 additions and 26 deletions

View file

@ -42,12 +42,12 @@ static bool account_matches(const account * acct,
} }
static void display_total(std::ostream& out, totals& balance, 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) const std::list<mask>& regexps)
{ {
bool displayed = false; bool displayed = false;
if (acct->display && (show_empty || acct->balance)) { if (acct->checked == 1 && (show_empty || acct->balance)) {
displayed = true; displayed = true;
out << acct->balance; out << acct->balance;
@ -65,7 +65,7 @@ static void display_total(std::ostream& out, totals& balance,
// Display balances for all child accounts // 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 != acct->children.end();
i++) i++)
display_total(out, balance, (*i).second, ! displayed, regexps); 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) else if (acct->checked == 3)
continue; continue;
acct->display = true; acct->checked = 1;
acct->balance.credit((*x)->cost->street()); acct->balance.credit((*x)->cost->street());
} }
} }

View file

@ -2,7 +2,7 @@
namespace ledger { 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) const std::list<mask>& regexps)
{ {
if (acct->balance && if (acct->balance &&
@ -37,7 +37,7 @@ static void equity_entry(std::ostream& out, const account * acct,
// Display balances for all child accounts // 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 != acct->children.end();
i++) i++)
equity_entry(out, (*i).second, regexps); equity_entry(out, (*i).second, regexps);

View file

@ -139,7 +139,7 @@ static void dataHandler(void *userData, const char *s, int len)
accounts_iterator i = accounts_by_id.find(std::string(s, len)); accounts_iterator i = accounts_by_id.find(std::string(s, len));
assert(i != accounts_by_id.end()); assert(i != accounts_by_id.end());
curr_account->parent = (*i).second; curr_account->parent = (*i).second;
(*i).second->children.insert(account::pair(curr_account->name, (*i).second->children.insert(accounts_entry(curr_account->name,
curr_account)); curr_account));
break; break;
} }
@ -239,12 +239,18 @@ bool parse_gnucash(std::istream& in, bool compute_balances)
{ {
char buf[BUFSIZ]; char buf[BUFSIZ];
action = NO_ACTION;
do_compute = compute_balances;
curr_account = NULL; curr_account = NULL;
curr_entry = NULL; curr_entry = NULL;
curr_value = NULL;
curr_comm = 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); XML_Parser parser = XML_ParserCreate(NULL);
current_parser = parser; current_parser = parser;

View file

@ -302,7 +302,7 @@ account * state::find_account(const char * name, bool create)
current = (*i).second; current = (*i).second;
} }
} else { } else {
account::iterator i = current->children.find(tok); accounts_iterator i = current->children.find(tok);
if (i == current->children.end()) { if (i == current->children.end()) {
if (! create) if (! create)
return NULL; return NULL;

View file

@ -1,5 +1,5 @@
#ifndef _LEDGER_H #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
{ {
struct account * parent; account * parent;
std::string name; std::string name;
commodity * comm; // default commodity for this account commodity * comm; // default commodity for this account
totals balance; totals balance;
bool display;
int checked; int checked;
#ifdef HUQUQULLAH #ifdef HUQUQULLAH
bool exempt_or_necessary; bool exempt_or_necessary;
#endif #endif
typedef std::map<const std::string, struct account *> map; accounts_t children;
typedef map::iterator iterator;
typedef map::const_iterator const_iterator;
typedef std::pair<const std::string, struct account *> pair;
map children;
account(const std::string& _name, struct account * _parent = NULL) 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 #ifdef HUQUQULLAH
exempt_or_necessary = false; exempt_or_necessary = false;
#endif #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 struct state
{ {
commodities_t commodities; commodities_t commodities;