107 const string& name) = 0;
153 parent->define(kind, name, def);
157 const string& name) {
159 return parent->lookup(kind, name);
174 DEBUG(
"scope.symbols",
175 "Binding scope " << &_parent <<
" with " << &_grandchild);
176 TRACE_CTOR(bind_scope_t,
"scope_t&, scope_t&");
188 parent->define(kind, name, def);
193 const string& name) {
205 if (T * sought =
dynamic_cast<T *
>(ptr))
210 scope->parent : &scope->grandchild))
213 &scope->grandchild : scope->parent);
223 bool prefer_direct_parents =
false)
226 prefer_direct_parents))
229 throw_(std::runtime_error, _(
"Could not find scope"));
230 return reinterpret_cast<T&
>(scope);
239 throw_(std::runtime_error, _(
"Could not find scope"));
240 return reinterpret_cast<T&
>(scope);
245 typedef std::map<symbol_t, expr_t::ptr_op_t> symbol_map;
247 optional<symbol_map> symbols;
262 return parent->description();
283 const bool _required =
true)
285 required(_required) {
293 return parent->description();
297 return value_type_context;
312 const bool required =
false);
320 const int _depth = 0)
335 for (std::size_t index = 0; index <
args.size(); index++)
349 bool has(std::size_t index) {
350 return index <
args.size() && ! (*this)[index].is_null();
352 template <
typename T>
353 bool has(std::size_t index);
354 template <
typename T>
355 T
get(std::size_t index,
bool convert =
true);
357 template <
typename T>
362 return *
static_cast<T *
>(
ptr);
366 args.push_front(val);
377 value_t::sequence_t::iterator
begin() {
380 value_t::sequence_t::iterator
end() {
386 value_t::sequence_t::const_iterator
begin()
const {
389 value_t::sequence_t::const_iterator
end()
const {
397 return args.size() == 0;
403 if (index <
args.size()) {
405 return !
args[index].is_null();
411 if (index <
args.size()) {
413 return !
args[index].is_null();
419 if (index <
args.size()) {
421 return !
args[index].is_null();
427 if (index <
args.size()) {
429 return !
args[index].is_null();
435 if (index <
args.size()) {
437 return !
args[index].is_null();
443 if (index <
args.size()) {
445 return !
args[index].is_null();
451 if (index <
args.size()) {
453 return !
args[index].is_null();
459 if (index <
args.size()) {
461 return !
args[index].is_null();
467 if (index <
args.size()) {
469 return !
args[index].is_null();
475 if (index < args.size()) {
477 return ! args[index].is_null();
567 std::ostringstream buf;
570 for (std::size_t i = 0; i < args.
size(); i++) {
599 return parent->description();
#define TRACE_CTOR(cls, args)
boost::gregorian::date date_t
string join_args(call_scope_t &args)
T & find_scope(child_scope_t &scope, bool skip_this=true, bool prefer_direct_parents=false)
T * search_scope(scope_t *ptr, bool prefer_direct_parents=false)
boost::posix_time::ptime datetime_t
Encapsulate infinite-precision commoditized amounts.
A wrapper around amount_t allowing addition of multiple commodities.
intrusive_ptr< op_t > ptr_op_t
expr_t::ptr_op_t definition
bool operator==(const symbol_t &sym) const
symbol_t(kind_t _kind, string _name, expr_t::ptr_op_t _definition=NULL)
symbol_t(const symbol_t &sym)
bool operator<(const symbol_t &sym) const
static empty_scope_t * empty_scope
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, const string &name)=0
static scope_t * default_scope
virtual value_t::type_t type_context() const
virtual bool type_required() const
virtual string description()
virtual expr_t::ptr_op_t lookup(const symbol_t::kind_t, const string &)
child_scope_t(scope_t &_parent)
virtual expr_t::ptr_op_t lookup(const symbol_t::kind_t kind, const string &name)
virtual void define(const symbol_t::kind_t kind, const string &name, expr_t::ptr_op_t def)
virtual void define(const symbol_t::kind_t kind, const string &name, expr_t::ptr_op_t def)
virtual string description()
bind_scope_t(scope_t &_parent, scope_t &_grandchild)
virtual expr_t::ptr_op_t lookup(const symbol_t::kind_t kind, const string &name)
virtual ~symbol_scope_t()
virtual expr_t::ptr_op_t lookup(const symbol_t::kind_t kind, const string &name)
symbol_scope_t(scope_t &_parent)
virtual string description()
virtual void define(const symbol_t::kind_t kind, const string &name, expr_t::ptr_op_t def)
virtual string description()
context_scope_t(scope_t &_parent, value_t::type_t _type_context=value_t::VOID, const bool _required=true)
virtual ~context_scope_t()
virtual value_t::type_t type_context() const
virtual bool type_required() const
T get(std::size_t index, bool convert=true)
value_t::sequence_t::iterator iterator
value_t::sequence_t::const_iterator const_iterator
void push_back(const value_t &val)
value_t & resolve(const std::size_t index, value_t::type_t context=value_t::VOID, const bool required=false)
value_t::sequence_t::const_iterator end() const
value_t & operator[](const std::size_t index)
value_t::sequence_t::const_iterator begin() const
bool has(std::size_t index)
bool has(std::size_t index)
void set_args(const value_t &_args)
value_t::sequence_t::iterator begin()
call_scope_t(scope_t &_parent, expr_t::ptr_op_t *_locus=NULL, const int _depth=0)
value_t::sequence_t::iterator end()
void push_front(const value_t &val)
virtual string description()
value_scope_t(scope_t &_parent, const value_t &_value)
virtual expr_t::ptr_op_t lookup(const symbol_t::kind_t kind, const string &name)
Dynamic type representing various numeric types.
const datetime_t & as_datetime() const
const date_t & as_date() const
scope_t * as_scope() const
const long & as_long() const
const balance_t & as_balance() const
const mask_t & as_mask() const
const string & as_string() const
type_t
type_t gives the type of the data contained or referenced by a value_t object.
datetime_t to_datetime() const
const amount_t & as_amount() const
balance_t to_balance() const
amount_t to_amount() const
const bool & as_boolean() const
ptr_deque< value_t > sequence_t
The sequence_t member type abstracts the type used to represent a resizable "array" of value_t object...
bool to_boolean() const
Data conversion methods.