diff options
author | John Wiegley <johnw@newartisans.com> | 2010-06-02 01:55:55 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2010-06-02 01:55:55 -0400 |
commit | cda19829bd1100d6563b48ddb121f2afc1c55d95 (patch) | |
tree | 5b6ab0d1eb7ec1b0b3eccf817678d0aa9a3feb47 /src/value.cc | |
parent | 017492ef5e80003073c5d053252d4a68a44260ae (diff) | |
parent | fb7cafa8965c89bbd66b09f827bd5989a87c983b (diff) | |
download | fork-ledger-cda19829bd1100d6563b48ddb121f2afc1c55d95.tar.gz fork-ledger-cda19829bd1100d6563b48ddb121f2afc1c55d95.tar.bz2 fork-ledger-cda19829bd1100d6563b48ddb121f2afc1c55d95.zip |
Merge branch 'next'
Diffstat (limited to 'src/value.cc')
-rw-r--r-- | src/value.cc | 54 |
1 files changed, 53 insertions, 1 deletions
diff --git a/src/value.cc b/src/value.cc index ce9b0e6a..a967eeb8 100644 --- a/src/value.cc +++ b/src/value.cc @@ -832,7 +832,7 @@ bool value_t::is_equal_to(const value_t& val) const break; } - throw_(value_error, _("Cannot compare %1 by %2") << label() << val.label()); + throw_(value_error, _("Cannot compare %1 to %2") << label() << val.label()); return *this; } @@ -840,6 +840,23 @@ bool value_t::is_equal_to(const value_t& val) const bool value_t::is_less_than(const value_t& val) const { switch (type()) { + case BOOLEAN: + if (val.is_boolean()) { + if (as_boolean()) { + if (! val.as_boolean()) + return false; + else + return false; + } + else if (! as_boolean()) { + if (! val.as_boolean()) + return false; + else + return true; + } + } + break; + case DATETIME: if (val.is_datetime()) return as_datetime() < val.as_datetime(); @@ -935,6 +952,22 @@ bool value_t::is_less_than(const value_t& val) const bool value_t::is_greater_than(const value_t& val) const { switch (type()) { + if (val.is_boolean()) { + if (as_boolean()) { + if (! val.as_boolean()) + return true; + else + return false; + } + else if (! as_boolean()) { + if (! val.as_boolean()) + return false; + else + return false; + } + } + break; + case DATETIME: if (val.is_datetime()) return as_datetime() > val.as_datetime(); @@ -1042,8 +1075,27 @@ void value_t::in_place_cast(type_t cast_type) } switch (type()) { + case VOID: + switch (cast_type) { + case INTEGER: + set_long(0L); + return; + case AMOUNT: + set_amount(0L); + return; + case STRING: + set_string(""); + return; + default: + break; + } + break; + case BOOLEAN: switch (cast_type) { + case INTEGER: + set_long(as_boolean() ? 1L : 0L); + return; case AMOUNT: set_amount(as_boolean() ? 1L : 0L); return; |