summaryrefslogtreecommitdiff
path: root/entry.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2008-07-29 21:05:08 -0400
committerJohn Wiegley <johnw@newartisans.com>2008-07-29 21:05:08 -0400
commit42e1d725aa9deb41396ba4c73c8499c7c3798508 (patch)
tree709aded6962addc668a127a0392aec739d74f750 /entry.cc
parentea27d1b45a5ff975a1e90e3e9f4b74ff8d34056e (diff)
downloadledger-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.cc36
1 files changed, 36 insertions, 0 deletions
diff --git a/entry.cc b/entry.cc
index 06e2a131..2feaa761 100644
--- a/entry.cc
+++ b/entry.cc
@@ -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) {