summaryrefslogtreecommitdiff
path: root/src/post.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-10-27 04:00:59 -0400
committerJohn Wiegley <johnw@newartisans.com>2009-10-27 04:00:59 -0400
commitddfd00afe17393f5b33a9288990a649e3cfcc0ab (patch)
treed9562fba018f0a80809894e939b4026b235f4e37 /src/post.cc
parent5ddb0e9bfbf3432a1078adc550484e5b8a151f34 (diff)
downloadfork-ledger-ddfd00afe17393f5b33a9288990a649e3cfcc0ab.tar.gz
fork-ledger-ddfd00afe17393f5b33a9288990a649e3cfcc0ab.tar.bz2
fork-ledger-ddfd00afe17393f5b33a9288990a649e3cfcc0ab.zip
Made the id function available in post contexts
Diffstat (limited to 'src/post.cc')
-rw-r--r--src/post.cc22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/post.cc b/src/post.cc
index 90c10a3b..89d69ec1 100644
--- a/src/post.cc
+++ b/src/post.cc
@@ -141,6 +141,16 @@ namespace {
return string_value(post.xact->payee);
}
+ value_t get_magnitude(post_t& post) {
+ return post.xact->magnitude();
+ }
+ value_t get_idstring(post_t& post) {
+ return string_value(post.xact->idstring());
+ }
+ value_t get_id(post_t& post) {
+ return string_value(post.xact->id());
+ }
+
value_t get_amount(post_t& post) {
if (post.has_xdata() && post.xdata().has_flags(POST_EXT_COMPOUND))
return post.xdata().compound_value;
@@ -296,6 +306,18 @@ expr_t::ptr_op_t post_t::lookup(const string& name)
return WRAP_FUNCTOR(get_wrapper<&get_has_cost>);
break;
+ case 'i':
+ if (name == "id")
+ return WRAP_FUNCTOR(get_wrapper<&get_id>);
+ else if (name == "idstring")
+ return WRAP_FUNCTOR(get_wrapper<&get_idstring>);
+ break;
+
+ case 'm':
+ if (name == "magnitude")
+ return WRAP_FUNCTOR(get_wrapper<&get_magnitude>);
+ break;
+
case 'p':
if (name == "post")
return WRAP_FUNCTOR(get_wrapper<&get_this>);