diff options
author | John Wiegley <johnw@newartisans.com> | 2003-10-01 04:42:13 +0000 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2003-10-01 04:42:13 +0000 |
commit | f93341edfccba98c7c709dfd172467b37017cc3f (patch) | |
tree | 38c18778b9a475b4b9b2c7feed3725ed3a67acf1 /amount.cc | |
parent | 16cb024a823112f4f2360f6123492bcefd8f74f8 (diff) | |
download | fork-ledger-f93341edfccba98c7c709dfd172467b37017cc3f.tar.gz fork-ledger-f93341edfccba98c7c709dfd172467b37017cc3f.tar.bz2 fork-ledger-f93341edfccba98c7c709dfd172467b37017cc3f.zip |
*** empty log message ***
Diffstat (limited to 'amount.cc')
-rw-r--r-- | amount.cc | 20 |
1 files changed, 20 insertions, 0 deletions
@@ -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; |