diff options
Diffstat (limited to 'src/expr.h')
-rw-r--r-- | src/expr.h | 20 |
1 files changed, 19 insertions, 1 deletions
@@ -58,7 +58,6 @@ public: class op_t; typedef intrusive_ptr<op_t> ptr_op_t; typedef intrusive_ptr<const op_t> const_ptr_op_t; - protected: ptr_op_t ptr; @@ -142,6 +141,25 @@ private: #endif // HAVE_BOOST_SERIALIZATION }; +/** + * Dealing with expr pointers tucked into value objects. + */ +inline bool is_expr(const value_t& val) { + return val.is_any() && val.as_any().type() == typeid(expr_t::ptr_op_t); +} +inline expr_t::ptr_op_t as_expr(const value_t& val) { + VERIFY(val.is_any()); + return val.as_any<expr_t::ptr_op_t>(); +} +inline void set_expr(value_t& val, expr_t::ptr_op_t op) { + val.set_any(op); +} +inline value_t expr_value(expr_t::ptr_op_t op) { + value_t temp; + temp.set_any(op); + return temp; +} + } // namespace ledger #endif // _EXPR_H |