summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-11-14 03:11:48 -0500
committerJohn Wiegley <johnw@newartisans.com>2009-11-14 03:11:48 -0500
commita461e17eee16ec51d2f074a0f46cb552edaa3ffd (patch)
tree6d9bbf95b19108ee0672812ec1373889c5646262
parent7a447912216e467a402e48be49f143f1b4be8261 (diff)
downloadfork-ledger-a461e17eee16ec51d2f074a0f46cb552edaa3ffd.tar.gz
fork-ledger-a461e17eee16ec51d2f074a0f46cb552edaa3ffd.tar.bz2
fork-ledger-a461e17eee16ec51d2f074a0f46cb552edaa3ffd.zip
Added historical support for single-letter valexprs
-rw-r--r--src/account.cc21
-rw-r--r--src/item.cc5
-rw-r--r--src/post.cc28
-rw-r--r--src/report.cc39
4 files changed, 90 insertions, 3 deletions
diff --git a/src/account.cc b/src/account.cc
index da43745a..e6c7af56 100644
--- a/src/account.cc
+++ b/src/account.cc
@@ -249,7 +249,7 @@ expr_t::ptr_op_t account_t::lookup(const symbol_t::kind_t kind,
switch (name[0]) {
case 'a':
- if (name == "amount")
+ if (name[1] == '\0' || name == "amount")
return WRAP_FUNCTOR(get_wrapper<&get_amount>);
else if (name == "account")
return WRAP_FUNCTOR(get_wrapper<&get_account>);
@@ -272,11 +272,20 @@ expr_t::ptr_op_t account_t::lookup(const symbol_t::kind_t kind,
case 'i':
if (name == "is_account")
return WRAP_FUNCTOR(get_wrapper<&get_true>);
+ else if (name == "is_index")
+ return WRAP_FUNCTOR(get_wrapper<&get_subcount>);
break;
case 'l':
if (name == "latest_cleared")
return WRAP_FUNCTOR(get_wrapper<&get_latest_cleared>);
+ else if (name[1] == '\0')
+ return WRAP_FUNCTOR(get_wrapper<&get_depth>);
+ break;
+
+ case 'n':
+ if (name[1] == '\0')
+ return WRAP_FUNCTOR(get_wrapper<&get_subcount>);
break;
case 'p':
@@ -300,6 +309,16 @@ expr_t::ptr_op_t account_t::lookup(const symbol_t::kind_t kind,
if (name == "use_direct_amount")
return WRAP_FUNCTOR(get_wrapper<&ignore>);
break;
+
+ case 'N':
+ if (name[1] == '\0')
+ return WRAP_FUNCTOR(get_wrapper<&get_count>);
+ break;
+
+ case 'O':
+ if (name[1] == '\0')
+ return WRAP_FUNCTOR(get_wrapper<&get_total>);
+ break;
}
return NULL;
diff --git a/src/item.cc b/src/item.cc
index f60db226..43274cfd 100644
--- a/src/item.cc
+++ b/src/item.cc
@@ -395,6 +395,11 @@ expr_t::ptr_op_t item_t::lookup(const symbol_t::kind_t kind,
return WRAP_FUNCTOR(get_wrapper<&get_uncleared>);
break;
+ case 'L':
+ if (name[1] == '\0')
+ return WRAP_FUNCTOR(get_wrapper<&get_actual>);
+ break;
+
case 'X':
if (name[1] == '\0')
return WRAP_FUNCTOR(get_wrapper<&get_cleared>);
diff --git a/src/post.cc b/src/post.cc
index 7c27b6c4..34284e1b 100644
--- a/src/post.cc
+++ b/src/post.cc
@@ -297,6 +297,11 @@ expr_t::ptr_op_t post_t::lookup(const symbol_t::kind_t kind,
return WRAP_FUNCTOR(get_wrapper<&get_account_base>);
break;
+ case 'b':
+ if (name[1] == '\0')
+ return WRAP_FUNCTOR(get_wrapper<&get_cost>);
+ break;
+
case 'c':
if (name == "code")
return WRAP_FUNCTOR(get_wrapper<&get_code>);
@@ -325,7 +330,9 @@ expr_t::ptr_op_t post_t::lookup(const symbol_t::kind_t kind,
break;
case 'i':
- if (name == "id")
+ if (name == "index")
+ return WRAP_FUNCTOR(get_wrapper<&get_count>);
+ else if (name == "id")
return WRAP_FUNCTOR(get_wrapper<&get_id>);
else if (name == "idstring")
return WRAP_FUNCTOR(get_wrapper<&get_idstring>);
@@ -339,6 +346,8 @@ expr_t::ptr_op_t post_t::lookup(const symbol_t::kind_t kind,
case 'n':
if (name == "note")
return WRAP_FUNCTOR(get_wrapper<&get_note>);
+ else if (name[1] == '\0')
+ return WRAP_FUNCTOR(get_wrapper<&get_count>);
break;
case 'p':
@@ -358,7 +367,7 @@ expr_t::ptr_op_t post_t::lookup(const symbol_t::kind_t kind,
break;
case 't':
- if (name[1] == '\0' || name == "total")
+ if (name == "total")
return WRAP_FUNCTOR(get_wrapper<&get_total>);
break;
@@ -376,6 +385,21 @@ expr_t::ptr_op_t post_t::lookup(const symbol_t::kind_t kind,
if (name == "xact")
return WRAP_FUNCTOR(get_wrapper<&get_xact>);
break;
+
+ case 'N':
+ if (name[1] == '\0')
+ return WRAP_FUNCTOR(get_wrapper<&get_count>);
+ break;
+
+ case 'O':
+ if (name[1] == '\0')
+ return WRAP_FUNCTOR(get_wrapper<&get_total>);
+ break;
+
+ case 'R':
+ if (name[1] == '\0')
+ return WRAP_FUNCTOR(get_wrapper<&get_real>);
+ break;
}
return item_t::lookup(kind, name);
diff --git a/src/report.cc b/src/report.cc
index 49633350..267a4a3d 100644
--- a/src/report.cc
+++ b/src/report.cc
@@ -915,6 +915,45 @@ expr_t::ptr_op_t report_t::lookup(const symbol_t::kind_t kind,
switch (kind) {
case symbol_t::FUNCTION:
+ // Support 2.x's single-letter value expression names.
+ if (*(p + 1) == '\0') {
+ switch (*p) {
+ case 'd':
+ case 'm':
+ return MAKE_FUNCTOR(report_t::fn_now);
+ case 'P':
+ return MAKE_FUNCTOR(report_t::fn_market);
+ case 't':
+ return MAKE_FUNCTOR(report_t::fn_display_amount);
+ case 'T':
+ return MAKE_FUNCTOR(report_t::fn_display_total);
+ case 'U':
+ return MAKE_FUNCTOR(report_t::fn_abs);
+ case 'S':
+ return MAKE_FUNCTOR(report_t::fn_strip);
+ case 'i':
+ throw_(std::runtime_error,
+ _("The i value expression variable is no longer supported"));
+ case 'A':
+ throw_(std::runtime_error,
+ _("The A value expression variable is no longer supported"));
+ case 'v':
+ case 'V':
+ throw_(std::runtime_error,
+ _("The V and v value expression variables are no longer supported"));
+ case 'I':
+ case 'B':
+ throw_(std::runtime_error,
+ _("The I and B value expression variables are no longer supported"));
+ case 'g':
+ case 'G':
+ throw_(std::runtime_error,
+ _("The G and g value expression variables are no longer supported"));
+ default:
+ return NULL;
+ }
+ }
+
switch (*p) {
case 'a':
if (is_eq(p, "amount_expr"))