diff options
author | John Wiegley <johnw@newartisans.com> | 2008-09-14 19:39:26 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2008-09-14 19:39:26 -0400 |
commit | 9a98beab38c13bbc623bd1ee9b2c0387c92d3998 (patch) | |
tree | b69abc39772d1379e78018064b6b87d02c5799fa /src | |
parent | 7d1809cb15b1ebea4d96341ae0e5fc655487788a (diff) | |
download | fork-ledger-9a98beab38c13bbc623bd1ee9b2c0387c92d3998.tar.gz fork-ledger-9a98beab38c13bbc623bd1ee9b2c0387c92d3998.tar.bz2 fork-ledger-9a98beab38c13bbc623bd1ee9b2c0387c92d3998.zip |
Added 'code' value expression function for xacts and entries.
Diffstat (limited to 'src')
-rw-r--r-- | src/entry.cc | 12 | ||||
-rw-r--r-- | src/xact.cc | 9 |
2 files changed, 21 insertions, 0 deletions
diff --git a/src/entry.cc b/src/entry.cc index a1cfa702..4847e38c 100644 --- a/src/entry.cc +++ b/src/entry.cc @@ -380,6 +380,13 @@ namespace { return entry.date(); } + value_t get_code(entry_t& entry) { + if (entry.code) + return string_value(*entry.code); + else + return string_value(empty_string); + } + value_t get_payee(entry_t& entry) { return string_value(entry.payee); } @@ -393,6 +400,11 @@ namespace { expr_t::ptr_op_t entry_t::lookup(const string& name) { switch (name[0]) { + case 'c': + if (name == "code") + return WRAP_FUNCTOR(get_wrapper<&get_code>); + break; + case 'd': if (name[1] == '\0' || name == "date") return WRAP_FUNCTOR(get_wrapper<&get_date>); diff --git a/src/xact.cc b/src/xact.cc index 08089e5c..efb33444 100644 --- a/src/xact.cc +++ b/src/xact.cc @@ -78,6 +78,13 @@ namespace { return xact.date(); } + value_t get_code(xact_t& xact) { + if (xact.entry->code) + return string_value(*xact.entry->code); + else + return string_value(empty_string); + } + value_t get_payee(xact_t& xact) { return string_value(xact.entry->payee); } @@ -167,6 +174,8 @@ expr_t::ptr_op_t xact_t::lookup(const string& name) case 'c': if (name == "cleared") return expr_t::op_t::wrap_value(0L); + else if (name == "code") + return WRAP_FUNCTOR(get_wrapper<&get_code>); break; case 'd': |