From 7901598f1d1e419e19c860e81749805371298030 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Mon, 27 Feb 2006 23:52:31 +0000 Subject: Checked in all major updates. --- value.cc | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'value.cc') diff --git a/value.cc b/value.cc index 2af9ecf6..1680ebd7 100644 --- a/value.cc +++ b/value.cc @@ -747,6 +747,38 @@ value_t value_t::cost() const return value_t(); } +value_t value_t::factor_price() const +{ + switch (type) { + case BOOLEAN: + case INTEGER: + return *this; + + case AMOUNT: { + commodity_t& comm = ((amount_t *) data)->commodity(); + if (comm.price != NULL) + return value_t(*comm.price * *((amount_t *) data)); + return *this; + } + + case BALANCE: + return ((balance_t *) data)->factor_price(); + + case BALANCE_PAIR: { + balance_pair_t temp(((balance_pair_t *) data)->quantity.factor_price()); + if (((balance_pair_t *) data)->cost) + temp.cost = new balance_t(((balance_pair_t *) data)->cost); + return temp; + } + + default: + assert(0); + break; + } + assert(0); + return value_t(); +} + value_t& value_t::add(const amount_t& amount, const amount_t * cost) { switch (type) { -- cgit v1.2.3