summaryrefslogtreecommitdiff
path: root/amount.cc
diff options
context:
space:
mode:
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;