Added 'code' value expression function for xacts and entries.

This commit is contained in:
John Wiegley 2008-09-14 19:39:26 -04:00
parent 7d1809cb15
commit 9a98beab38
2 changed files with 21 additions and 0 deletions

View file

@ -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>);

View file

@ -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':