diff options
author | John Wiegley <johnw@newartisans.com> | 2010-06-05 03:22:02 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2010-06-05 03:26:43 -0400 |
commit | 16f799767ce86731f67735e9a59bde5faa4cf645 (patch) | |
tree | fdcf959c891d83b47261a3669d5f77623070484d /src | |
parent | 63c7ba0322fc3d0082580e181cd341f32a23ee9e (diff) | |
download | fork-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')
-rw-r--r-- | src/filters.h | 12 | ||||
-rw-r--r-- | src/value.cc | 28 | ||||
-rw-r--r-- | src/value.h | 2 |
3 files changed, 32 insertions, 10 deletions
diff --git a/src/filters.h b/src/filters.h index a66d8c47..327499fb 100644 --- a/src/filters.h +++ b/src/filters.h @@ -226,16 +226,12 @@ class sort_posts : public item_handler<post_t> public: sort_posts(post_handler_ptr handler, const expr_t& _sort_order) - : item_handler<post_t>(handler), - sort_order(_sort_order) { - TRACE_CTOR(sort_posts, - "post_handler_ptr, const value_expr&"); + : item_handler<post_t>(handler), sort_order(_sort_order) { + TRACE_CTOR(sort_posts, "post_handler_ptr, const value_expr&"); } sort_posts(post_handler_ptr handler, const string& _sort_order) - : item_handler<post_t>(handler), - sort_order(_sort_order) { - TRACE_CTOR(sort_posts, - "post_handler_ptr, const string&"); + : item_handler<post_t>(handler), sort_order(_sort_order) { + TRACE_CTOR(sort_posts, "post_handler_ptr, const string&"); } virtual ~sort_posts() { TRACE_DTOR(sort_posts); 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; } diff --git a/src/value.h b/src/value.h index 3252ed65..2e3998f3 100644 --- a/src/value.h +++ b/src/value.h @@ -878,7 +878,6 @@ public: sequence_t::iterator begin() { return as_sequence_lval().begin(); } - sequence_t::iterator end() { return as_sequence_lval().end(); } @@ -886,7 +885,6 @@ public: sequence_t::const_iterator begin() const { return as_sequence().begin(); } - sequence_t::const_iterator end() const { return as_sequence().end(); } |