From f93341edfccba98c7c709dfd172467b37017cc3f Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Wed, 1 Oct 2003 04:42:13 +0000 Subject: *** empty log message *** --- amount.cc | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'amount.cc') diff --git a/amount.cc b/amount.cc index 2d8271be..4caac14d 100644 --- a/amount.cc +++ b/amount.cc @@ -51,6 +51,7 @@ class gmp_amount : public amount virtual amount * copy() const; virtual amount * value(amount *) const; + virtual amount * street() const; virtual operator bool() const; @@ -216,6 +217,25 @@ amount * gmp_amount::value(amount * pr) const } } +amount * gmp_amount::street() const +{ + amount * cost = NULL; + const amount * amt = this; + + for (int cycles = 0; cycles < 10; cycles++) { + totals::iterator pi = main_ledger.prices.amounts.find(amt->comm_symbol()); + if (pi == main_ledger.prices.amounts.end()) { + break; + } else { + amount * temp = cost; + amt = cost = amt->value((*pi).second); + if (temp) + delete temp; + } + } + return cost ? cost : copy(); +} + gmp_amount::operator bool() const { mpz_t copy; -- cgit v1.2.3