summaryrefslogtreecommitdiff
path: root/src/value.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-11-11 03:39:53 -0500
committerJohn Wiegley <johnw@newartisans.com>2009-11-11 03:39:53 -0500
commitafe87280e091d4f094f068c5f21aecccd2d1831b (patch)
tree4be3e5c9bbcc9b450a6c0eea3f6b959daab22757 /src/value.cc
parent4a4ff9d4b21e7ed94524314ca496bd17c84fc4ed (diff)
downloadfork-ledger-afe87280e091d4f094f068c5f21aecccd2d1831b.tar.gz
fork-ledger-afe87280e091d4f094f068c5f21aecccd2d1831b.tar.bz2
fork-ledger-afe87280e091d4f094f068c5f21aecccd2d1831b.zip
Added floored() and in_place_floor() methods
Diffstat (limited to 'src/value.cc')
-rw-r--r--src/value.cc25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/value.cc b/src/value.cc
index 021bf957..ae86eb7c 100644
--- a/src/value.cc
+++ b/src/value.cc
@@ -1439,6 +1439,31 @@ void value_t::in_place_truncate()
throw_(value_error, _("Cannot truncate %1") << label());
}
+void value_t::in_place_floor()
+{
+ switch (type()) {
+ case INTEGER:
+ return;
+ case AMOUNT:
+ as_amount_lval().in_place_floor();
+ return;
+ case BALANCE:
+ as_balance_lval().in_place_floor();
+ return;
+ case SEQUENCE: {
+ value_t temp;
+ foreach (const value_t& value, as_sequence())
+ temp.push_back(value.floored());
+ *this = temp;
+ return;
+ }
+ default:
+ break;
+ }
+
+ throw_(value_error, _("Cannot floor %1") << label());
+}
+
void value_t::in_place_unround()
{
switch (type()) {