moved display only flags to dflags in both transactions and accounts

This commit is contained in:
John Wiegley 2004-08-07 23:20:10 -04:00
parent effa82793f
commit 59c0692233
5 changed files with 22 additions and 18 deletions

View file

@ -21,7 +21,7 @@ std::string partial_account_name(const account_t * account)
for (const account_t * acct = account;
acct && acct->parent;
acct = acct->parent) {
if (acct->flags & ACCOUNT_DISPLAYED)
if (acct->dflags & ACCOUNT_DISPLAYED)
break;
if (name.empty())
@ -289,7 +289,7 @@ void format_t::format_elements(std::ostream& out,
for (const account_t * acct = details.account;
acct;
acct = acct->parent)
if (acct->flags & ACCOUNT_DISPLAYED) {
if (acct->dflags & ACCOUNT_DISPLAYED) {
if (elem->min_width > 0 || elem->max_width > 0)
out.width(elem->min_width > elem->max_width ?
elem->min_width : elem->max_width);
@ -359,7 +359,7 @@ void format_transaction::operator()(transaction_t * xact) const
xact->index = last_xact ? last_xact->index + 1 : 0;
if (disp_pred_functor(xact)) {
xact->flags |= TRANSACTION_DISPLAYED;
xact->dflags |= TRANSACTION_DISPLAYED;
// This makes the assumption that transactions from a single entry
// are always grouped together.
@ -432,7 +432,7 @@ void format_account::operator()(account_t * account,
if (output && (max_depth == 0 || account->depth <= max_depth)) {
format.format_elements(output_stream, details_t(account));
account->flags |= ACCOUNT_DISPLAYED;
account->dflags |= ACCOUNT_DISPLAYED;
}
}
}

View file

@ -247,7 +247,7 @@ class format_equity
if ((report_top || account->parent != NULL) &&
disp_pred_functor(account)) {
next_lines_format.format_elements(output_stream, details_t(account));
account->flags |= ACCOUNT_DISPLAYED;
account->dflags |= ACCOUNT_DISPLAYED;
total += account->value.quantity;
}
}

View file

@ -25,10 +25,9 @@ namespace ledger {
#define TRANSACTION_VIRTUAL 0x01
#define TRANSACTION_BALANCE 0x02
#define TRANSACTION_AUTO 0x04
#define TRANSACTION_HANDLED 0x08
#define TRANSACTION_DISPLAYED 0x10
#define TRANSACTION_TRANSIENT (TRANSACTION_HANDLED | TRANSACTION_DISPLAYED)
#define TRANSACTION_HANDLED 0x10
#define TRANSACTION_DISPLAYED 0x20
class entry_t;
class account_t;
@ -44,10 +43,11 @@ class transaction_t
std::string note;
balance_pair_t total;
unsigned int index;
unsigned int dflags;
transaction_t(entry_t * _entry, account_t * _account)
: entry(_entry), account(_account), flags(TRANSACTION_NORMAL),
index(0) {}
index(0), dflags(0) {}
transaction_t(entry_t * _entry,
account_t * _account,
@ -56,7 +56,7 @@ class transaction_t
unsigned int _flags = TRANSACTION_NORMAL,
const std::string& _note = "")
: entry(_entry), account(_account), amount(_amount),
cost(_cost), flags(_flags), note(_note), index(0) {}
cost(_cost), flags(_flags), note(_note), index(0), dflags(0) {}
};
@ -111,7 +111,7 @@ class account_t
balance_pair_t value;
balance_pair_t total;
unsigned long ident;
unsigned long flags;
unsigned long dflags;
mutable std::string _fullname;
static unsigned long next_ident;
@ -120,7 +120,7 @@ class account_t
const std::string& _name = "",
const std::string& _note = "")
: parent(_parent), name(_name), note(_note),
depth(parent ? parent->depth + 1 : 0), flags(0) {}
depth(parent ? parent->depth + 1 : 0), dflags(0) {}
~account_t();

View file

@ -574,7 +574,9 @@ int main(int argc, char * argv[])
display_predicate_string = "T";
else if (command == "E")
display_predicate_string = "a";
} else {
}
if (! display_predicate_string.empty()) {
#ifdef DEBUG
if (debug)
std::cerr << "disp-pred = " << display_predicate_string << std::endl;
@ -712,8 +714,10 @@ int main(int argc, char * argv[])
if (const char * p = std::getenv("LEDGER_CACHE")) {
std::ofstream outstr(p);
assert(std::getenv("LEDGER"));
#if 0
clear_transaction_display_flags(journal->entries.begin(),
journal->entries.end());
#endif
write_binary_journal(outstr, journal.get(), std::getenv("LEDGER"));
}

10
walk.h
View file

@ -69,11 +69,11 @@ void handle_transaction(transaction_t * xact,
for (transactions_list::iterator i = xact->entry->transactions.begin();
i != xact->entry->transactions.end();
i++)
if (! ((*i)->flags & (TRANSACTION_AUTO | TRANSACTION_HANDLED)) &&
if (! ((*i)->flags & TRANSACTION_AUTO) &&
! ((*i)->dflags & TRANSACTION_HANDLED) &&
(*i == xact ?
(flags & MATCHING_TRANSACTIONS) :
(flags & OTHER_TRANSACTIONS))) {
(*i)->flags |= TRANSACTION_HANDLED;
(flags & MATCHING_TRANSACTIONS) : (flags & OTHER_TRANSACTIONS))) {
(*i)->dflags |= TRANSACTION_HANDLED;
functor(*i);
}
}
@ -110,7 +110,7 @@ class clear_flags
{
public:
void operator()(transaction_t * xact) const {
xact->flags &= ~TRANSACTION_TRANSIENT;
xact->dflags = 0;
}
};