diff options
author | John Wiegley <johnw@newartisans.com> | 2009-02-27 02:15:27 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2009-02-27 02:15:27 -0400 |
commit | fbb0d2583173073e11976c7cd7e570d4829f0621 (patch) | |
tree | 7c83465d30bd45f89f82757d5f3041a9e3903f1f /src/value.cc | |
parent | ecb1ca71c12f7772d345f19b6df821da123d3b57 (diff) | |
download | fork-ledger-fbb0d2583173073e11976c7cd7e570d4829f0621.tar.gz fork-ledger-fbb0d2583173073e11976c7cd7e570d4829f0621.tar.bz2 fork-ledger-fbb0d2583173073e11976c7cd7e570d4829f0621.zip |
Gave round/unround/truncate all in_place_ variants
Diffstat (limited to 'src/value.cc')
-rw-r--r-- | src/value.cc | 42 |
1 files changed, 24 insertions, 18 deletions
diff --git a/src/value.cc b/src/value.cc index 755c18bb..556fc152 100644 --- a/src/value.cc +++ b/src/value.cc @@ -1280,73 +1280,79 @@ value_t value_t::abs() const return NULL_VALUE; } -value_t value_t::rounded() const +void value_t::in_place_round() { switch (type()) { case INTEGER: - return *this; + return; case AMOUNT: - return as_amount().rounded(); + as_amount_lval().in_place_round(); + return; case BALANCE: - return as_balance().rounded(); + as_balance_lval().in_place_round(); + return; case SEQUENCE: { value_t temp; foreach (const value_t& value, as_sequence()) temp.push_back(value.rounded()); - return temp; + *this = temp; + return; } default: break; } throw_(value_error, _("Cannot set rounding for %1") << label()); - return NULL_VALUE; } -value_t value_t::truncated() const +void value_t::in_place_truncate() { switch (type()) { case INTEGER: - return *this; + return; case AMOUNT: - return as_amount().truncated(); + as_amount_lval().in_place_truncate(); + return; case BALANCE: - return as_balance().truncated(); + as_balance_lval().in_place_truncate(); + return; case SEQUENCE: { value_t temp; foreach (const value_t& value, as_sequence()) temp.push_back(value.truncated()); - return temp; + *this = temp; + return; } default: break; } throw_(value_error, _("Cannot truncate %1") << label()); - return NULL_VALUE; } -value_t value_t::unrounded() const +void value_t::in_place_unround() { switch (type()) { case INTEGER: - return *this; + return; case AMOUNT: - return as_amount().unrounded(); + as_amount_lval().unrounded(); + return; case BALANCE: - return as_balance().unrounded(); + as_balance_lval().unrounded(); + return; case SEQUENCE: { value_t temp; foreach (const value_t& value, as_sequence()) temp.push_back(value.unrounded()); - return temp; + *this = temp; + return; } default: break; } throw_(value_error, _("Cannot unround %1") << label()); - return NULL_VALUE; } void value_t::annotate(const annotation_t& details) |