summaryrefslogtreecommitdiff
path: root/src/value.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2010-06-05 03:22:02 -0400
committerJohn Wiegley <johnw@newartisans.com>2010-06-05 03:26:43 -0400
commit16f799767ce86731f67735e9a59bde5faa4cf645 (patch)
treefdcf959c891d83b47261a3669d5f77623070484d /src/value.cc
parent63c7ba0322fc3d0082580e181cd341f32a23ee9e (diff)
downloadfork-ledger-16f799767ce86731f67735e9a59bde5faa4cf645.tar.gz
fork-ledger-16f799767ce86731f67735e9a59bde5faa4cf645.tar.bz2
fork-ledger-16f799767ce86731f67735e9a59bde5faa4cf645.zip
Value expression sequences are now comparable
Fixes #228 / ED9388D7-E523-40EB-841B-9AE9BAA70329
Diffstat (limited to 'src/value.cc')
-rw-r--r--src/value.cc28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/value.cc b/src/value.cc
index a967eeb8..e9313f0c 100644
--- a/src/value.cc
+++ b/src/value.cc
@@ -935,6 +935,20 @@ bool value_t::is_less_than(const value_t& val) const
}
return ! no_amounts;
}
+ case SEQUENCE: {
+ sequence_t::const_iterator i = as_sequence().begin();
+ sequence_t::const_iterator j = val.as_sequence().begin();
+ for (; (i != as_sequence().end() &&
+ j != val.as_sequence().end()); i++, j++) {
+ if (! ((*i) < (*j)))
+ return false;
+ }
+ if (i == as_sequence().end())
+ return true;
+ else
+ return false;
+ break;
+ }
default:
break;
}
@@ -1041,6 +1055,20 @@ bool value_t::is_greater_than(const value_t& val) const
}
return ! no_amounts;
}
+ case SEQUENCE: {
+ sequence_t::const_iterator i = as_sequence().begin();
+ sequence_t::const_iterator j = val.as_sequence().begin();
+ for (; (i != as_sequence().end() &&
+ j != val.as_sequence().end()); i++, j++) {
+ if (! ((*i) > (*j)))
+ return false;
+ }
+ if (i == as_sequence().end())
+ return false;
+ else
+ return true;
+ break;
+ }
default:
break;
}