From d8498372037a4d0c272547ae48046b2182bcd4b1 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Mon, 7 May 2007 10:27:21 +0000 Subject: Major restructuring of the value_t class. --- src/balance.cc | 58 ---------------------------------------------------------- 1 file changed, 58 deletions(-) (limited to 'src/balance.cc') diff --git a/src/balance.cc b/src/balance.cc index 9d5e57f4..6952b123 100644 --- a/src/balance.cc +++ b/src/balance.cc @@ -33,39 +33,6 @@ namespace ledger { -balance_t& balance_t::operator*=(const balance_t& bal) -{ - if (is_realzero()) { - return *this; - } - else if (bal.is_realzero()) { - return *this = bal; - } - else if (bal.amounts.size() == 1) { - return *this *= (*bal.amounts.begin()).second; - } - else if (amounts.size() == 1) { - return *this = bal * *this; - } - else { - // Since we would fail with an error at this point otherwise, try - // stripping annotations to see if we can come up with a - // reasonable result. The user will not notice any annotations - // missing (since they are viewing a stripped report anyway), only - // that some of their value expression may not see any pricing or - // date data because of this operation. - - balance_t temp(bal.strip_annotations()); - if (temp.amounts.size() == 1) - return *this *= temp; - temp = strip_annotations(); - if (temp.amounts.size() == 1) - return *this = bal * temp; - - throw_(amount_error, "Cannot multiply two balances: " << temp << " * " << bal); - } -} - balance_t& balance_t::operator*=(const amount_t& amt) { if (is_realzero()) { @@ -107,31 +74,6 @@ balance_t& balance_t::operator*=(const amount_t& amt) return *this; } -balance_t& balance_t::operator/=(const balance_t& bal) -{ - if (bal.is_realzero()) { - throw_(amount_error, "Divide by zero: " << *this << " / " << bal); - } - else if (is_realzero()) { - return *this; - } - else if (bal.amounts.size() == 1) { - return *this /= (*bal.amounts.begin()).second; - } - else if (*this == bal) { - return *this = amount_t(1L); - } - else { - // Try stripping annotations before giving an error. - balance_t temp(bal.strip_annotations()); - if (temp.amounts.size() == 1) - return *this /= temp; - - throw_(amount_error, - "Cannot divide two balances: " << temp << " / " << bal); - } -} - balance_t& balance_t::operator/=(const amount_t& amt) { if (amt.is_realzero()) { -- cgit v1.2.3