diff options
author | John Wiegley <johnw@newartisans.com> | 2010-05-08 02:00:35 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2010-05-08 02:00:35 -0400 |
commit | 2d28b34ff35f78ace6e95a652c30c02be7ef5a06 (patch) | |
tree | c974e373ba0703f0fda521680a6f86bf39ef1509 /src/value.h | |
parent | 4028f0bcb455ce4ea23c355b6a43dc6122447a78 (diff) | |
download | fork-ledger-2d28b34ff35f78ace6e95a652c30c02be7ef5a06.tar.gz fork-ledger-2d28b34ff35f78ace6e95a652c30c02be7ef5a06.tar.bz2 fork-ledger-2d28b34ff35f78ace6e95a652c30c02be7ef5a06.zip |
Allow expr_t& to be passed in a value_t
Diffstat (limited to 'src/value.h')
-rw-r--r-- | src/value.h | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/src/value.h b/src/value.h index 1c1d8b6c..3252ed65 100644 --- a/src/value.h +++ b/src/value.h @@ -57,6 +57,7 @@ namespace ledger { DECLARE_EXCEPTION(value_error, std::runtime_error); class scope_t; +class expr_t; /** * @class value_t @@ -108,7 +109,8 @@ public: STRING, // a string object MASK, // a regular expression mask SEQUENCE, // a vector of value_t objects - SCOPE // a pointer to a scope + SCOPE, // a pointer to a scope + EXPR // a pointer to a value expression }; private: @@ -135,7 +137,8 @@ private: string, // STRING mask_t, // MASK sequence_t *, // SEQUENCE - scope_t * // SCOPE + scope_t *, // SCOPE + expr_t * // EXPR > data; type_t type; @@ -351,6 +354,10 @@ public: TRACE_CTOR(value_t, "scope_t *"); set_scope(item); } + explicit value_t(const expr_t& item) { + TRACE_CTOR(value_t, "const expr_t&"); + set_expr(item); + } /** * Destructor. This does not do anything, because the intrusive_ptr @@ -723,6 +730,22 @@ public: } /** + * Dealing with expr pointers. + */ + bool is_expr() const { + return is_type(EXPR); + } + expr_t& as_expr_lval() const { + VERIFY(is_expr()); + return *boost::get<expr_t *>(storage->data); + } + const expr_t& as_expr() const { + VERIFY(is_expr()); + return *boost::get<expr_t *>(storage->data); + } + void set_expr(const expr_t& val); + + /** * Data conversion methods. These methods convert a value object to * its underlying type, where possible. If not possible, an * exception is thrown. @@ -908,6 +931,8 @@ public: return _("a sequence"); case SCOPE: return _("a scope"); + case EXPR: + return _("a expr"); default: assert(false); break; |