diff options
author | John Wiegley <johnw@newartisans.com> | 2008-07-29 21:05:08 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2008-07-29 21:05:08 -0400 |
commit | 42e1d725aa9deb41396ba4c73c8499c7c3798508 (patch) | |
tree | 709aded6962addc668a127a0392aec739d74f750 /entry.cc | |
parent | ea27d1b45a5ff975a1e90e3e9f4b74ff8d34056e (diff) | |
download | ledger-42e1d725aa9deb41396ba4c73c8499c7c3798508.tar.gz ledger-42e1d725aa9deb41396ba4c73c8499c7c3798508.tar.bz2 ledger-42e1d725aa9deb41396ba4c73c8499c7c3798508.zip |
The next value expression scheme is working, but the individual accessor
functions for each of the journal objects has yet to be ported.
Diffstat (limited to 'entry.cc')
-rw-r--r-- | entry.cc | 36 |
1 files changed, 36 insertions, 0 deletions
@@ -363,6 +363,42 @@ void entry_t::add_xact(xact_t * xact) entry_base_t::add_xact(xact); } +namespace { + value_t get_date(call_scope_t& scope) + { + entry_t& entry(downcast<entry_t>(*scope.parent)); + return entry.date(); + } + + value_t get_payee(call_scope_t& scope) + { + entry_t& entry(downcast<entry_t>(*scope.parent)); + return value_t(entry.payee, true); + } +} + +expr_t::ptr_op_t entry_t::lookup(const string& name) +{ + switch (name[0]) { + case 'd': + if (name[1] == '\0' || name == "date") + return WRAP_FUNCTOR(bind(get_date, _1)); + break; + case 'p': + if (name[1] == '\0' || name == "payee") + return WRAP_FUNCTOR(bind(get_payee, _1)); + break; + } + +#if 0 + // jww (2008-07-29): Should it go to the containing journal next, or to the + // session? + return entry->lookup(name); +#else + return expr_t::ptr_op_t(); +#endif +} + bool entry_t::valid() const { if (! is_valid(_date) || ! journal) { |