diff options
author | John Wiegley <johnw@newartisans.com> | 2010-06-24 19:53:59 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2010-06-24 19:53:59 -0400 |
commit | 2f50e30b89a06e2f3c439f4a8440e4d35b4ebb27 (patch) | |
tree | 330f3ffd1e9ae74cebe642409ccc6c351efb8670 /src | |
parent | bc51cd4651225ad95190880c4d6f71e3a069ebbc (diff) | |
download | fork-ledger-2f50e30b89a06e2f3c439f4a8440e4d35b4ebb27.tar.gz fork-ledger-2f50e30b89a06e2f3c439f4a8440e4d35b4ebb27.tar.bz2 fork-ledger-2f50e30b89a06e2f3c439f4a8440e4d35b4ebb27.zip |
Scopes can now provide a description of themselves
This isn't being used yet, but it likely will to improve the information
presented to users if their value expressions fail to compile or
evaluate.
Diffstat (limited to 'src')
-rw-r--r-- | src/account.h | 4 | ||||
-rw-r--r-- | src/global.h | 4 | ||||
-rw-r--r-- | src/post.h | 10 | ||||
-rw-r--r-- | src/report.h | 4 | ||||
-rw-r--r-- | src/scope.h | 28 | ||||
-rw-r--r-- | src/session.h | 4 | ||||
-rw-r--r-- | src/textual.cc | 4 | ||||
-rw-r--r-- | src/xact.h | 30 |
8 files changed, 88 insertions, 0 deletions
diff --git a/src/account.h b/src/account.h index 26ebe261..7a632b35 100644 --- a/src/account.h +++ b/src/account.h @@ -89,6 +89,10 @@ public: } ~account_t(); + virtual string description() { + return string(_("account ")) + fullname(); + } + operator string() const { return fullname(); } diff --git a/src/global.h b/src/global.h index 115183a5..6504230d 100644 --- a/src/global.h +++ b/src/global.h @@ -55,6 +55,10 @@ public: global_scope_t(char ** envp); ~global_scope_t(); + virtual string description() { + return _("global scope"); + } + void read_init(); void read_environment_settings(char * envp[]); strings_list read_command_arguments(scope_t& scope, strings_list args); @@ -99,6 +99,16 @@ public: TRACE_DTOR(post_t); } + virtual string description() { + if (pos) { + std::ostringstream buf; + buf << _("posting at line %1") << pos->beg_line; + return buf.str(); + } else { + return string(_("generated posting")); + } + } + virtual bool has_tag(const string& tag, bool inherit = true) const; virtual bool has_tag(const mask_t& tag_mask, diff --git a/src/report.h b/src/report.h index 59a632e6..51e35dfa 100644 --- a/src/report.h +++ b/src/report.h @@ -125,6 +125,10 @@ public: output_stream.close(); } + virtual string description() { + return _("current report"); + } + void normalize_options(const string& verb); void normalize_period(); void parse_query_args(const value_t& args, const string& whence); diff --git a/src/scope.h b/src/scope.h index 8b4a9380..31b10f6b 100644 --- a/src/scope.h +++ b/src/scope.h @@ -109,6 +109,8 @@ public: TRACE_DTOR(scope_t); } + virtual string description() = 0; + virtual void define(const symbol_t::kind_t, const string&, expr_t::ptr_op_t) {} virtual expr_t::ptr_op_t lookup(const symbol_t::kind_t kind, @@ -191,6 +193,10 @@ public: TRACE_DTOR(bind_scope_t); } + virtual string description() { + return grandchild.description(); + } + virtual void define(const symbol_t::kind_t kind, const string& name, expr_t::ptr_op_t def) { parent->define(kind, name, def); @@ -262,6 +268,16 @@ public: TRACE_DTOR(symbol_scope_t); } + virtual string description() { + if (parent) + return parent->description(); +#if !defined(NO_ASSERTS) + else + assert(false); +#endif + return empty_string; + } + virtual void define(const symbol_t::kind_t kind, const string& name, expr_t::ptr_op_t def); @@ -299,6 +315,10 @@ public: TRACE_DTOR(context_scope_t); } + virtual string description() { + return parent->description(); + } + virtual value_t::type_t type_context() const { return value_type_context; } @@ -351,6 +371,10 @@ public: TRACE_DTOR(call_scope_t); } + virtual string description() { + return context_scope_t::description(); + } + void set_args(const value_t& _args) { args = _args; } @@ -617,6 +641,10 @@ public: value_scope_t(scope_t& _parent, const value_t& _value) : child_scope_t(_parent), value(_value) {} + virtual string description() { + return parent->description(); + } + virtual expr_t::ptr_op_t lookup(const symbol_t::kind_t kind, const string& name) { diff --git a/src/session.h b/src/session.h index 6de4b2dd..b8fd52f2 100644 --- a/src/session.h +++ b/src/session.h @@ -64,6 +64,10 @@ public: TRACE_DTOR(session_t); } + virtual string description() { + return _("current session"); + } + void set_flush_on_next_data_file(const bool truth) { flush_on_next_data_file = truth; } diff --git a/src/textual.cc b/src/textual.cc index 7ddb5251..3dbae9a1 100644 --- a/src/textual.cc +++ b/src/textual.cc @@ -112,6 +112,10 @@ namespace { ~instance_t(); + virtual string description() { + return _("textual parser"); + } + void parse(); std::streamsize read_line(char *& line); bool peek_whitespace_line() { @@ -117,6 +117,16 @@ public: TRACE_DTOR(xact_t); } + virtual string description() { + if (pos) { + std::ostringstream buf; + buf << _("transaction at line %1") << pos->beg_line; + return buf.str(); + } else { + return string(_("generated transaction")); + } + } + virtual void add_post(post_t * post); string idstring() const; @@ -194,6 +204,16 @@ public: TRACE_DTOR(auto_xact_t); } + virtual string description() { + if (pos) { + std::ostringstream buf; + buf << _("automated transaction at line %1") << pos->beg_line; + return buf.str(); + } else { + return string(_("generated automated transaction")); + } + } + virtual void parse_tags(const char * p, scope_t&, bool overwrite_existing = true) { @@ -242,6 +262,16 @@ class period_xact_t : public xact_base_t TRACE_DTOR(period_xact_t); } + virtual string description() { + if (pos) { + std::ostringstream buf; + buf << _("periodic transaction at line %1") << pos->beg_line; + return buf.str(); + } else { + return string(_("generated periodic transaction")); + } + } + #if defined(HAVE_BOOST_SERIALIZATION) private: /** Serialization. */ |