summaryrefslogtreecommitdiff
path: root/amount.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2003-10-01 04:42:13 +0000
committerJohn Wiegley <johnw@newartisans.com>2003-10-01 04:42:13 +0000
commitf93341edfccba98c7c709dfd172467b37017cc3f (patch)
tree38c18778b9a475b4b9b2c7feed3725ed3a67acf1 /amount.cc
parent16cb024a823112f4f2360f6123492bcefd8f74f8 (diff)
downloadfork-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.cc20
1 files changed, 20 insertions, 0 deletions
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;