From 9a98beab38c13bbc623bd1ee9b2c0387c92d3998 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Sun, 14 Sep 2008 19:39:26 -0400 Subject: Added 'code' value expression function for xacts and entries. --- src/entry.cc | 12 ++++++++++++ src/xact.cc | 9 +++++++++ 2 files changed, 21 insertions(+) (limited to 'src') 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': -- cgit v1.2.3