From 1f39d4148e588a5476e96550591131ae65ad0fe2 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Sat, 21 Feb 2009 18:49:43 -0400 Subject: Create a new interactive_t helper class The purpose of this class is much like Emacs' (interactive) form: it allows a value expression function to declare exactly how many arguments, and of what type, it intends to receive. It then offers type-safe access to theese arguments in a consistent manner. An example value expression function definition in C++: value_t fn_foo(call_scope_t& scope) { // We expect a string, an integer, and an optional date interactive_t args(scope, "sl&d"); std::cout << "String = " << args.get(0) << "Integer = " << args.get(1) << std::endl; if (args.has(2)) // was a date provided? std::cout << "Date = " << args.get(2) << std::endl; return NULL_VALUE; } There is also an in_context_t template, which finds the context type T in the current scope hierarchy. The in_context_t then also acts as a smart pointer to reference this context object, in addition to serving the same duty as interactive_t. This combination of intent is solely for the sake of brevity. value_t fn_bar(call_scope_t& scope) { in_context_t env(scope, "sl&d"); std::cout << "Account name = " << env->fullname() << "String arg = " << env.get(0) << std::endl; return NULL_VALUE; } As you can see here, 'env' acts as a smart pointer to the required context, and an object to extract the typed arguments. --- src/report.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/report.h') diff --git a/src/report.h b/src/report.h index a4020af8..f0408e89 100644 --- a/src/report.h +++ b/src/report.h @@ -502,13 +502,13 @@ public: "3 + date_width + payee_width + account_width + amount_width))" " %(print(strip(display_total), total_width, " "4 + date_width + payee_width + account_width + amount_width " - "+ total_width, true))\n%/" + "+ total_width))\n%/" "%(print(\" \", 2 + date_width + payee_width))" "%(print(truncate(account, account_width, abbrev_len), account_width))" " %(print(strip(display_amount), amount_width, 3 + date_width " "+ payee_width + account_width + amount_width))" " %(print(strip(display_total), total_width, 4 + date_width " - "+ payee_width + account_width + amount_width + total_width, true))\n"); + "+ payee_width + account_width + amount_width + total_width))\n"); }); OPTION(report_t, related); // -r -- cgit v1.2.3