Added account_id and xact_id valexpr vars for posts
account_id is the "whicheth" number for that posting within its account. The xact_id is within its transaction.
This commit is contained in:
parent
017492ef5e
commit
47bfe58ab3
2 changed files with 39 additions and 0 deletions
36
src/post.cc
36
src/post.cc
|
|
@ -142,6 +142,10 @@ namespace {
|
||||||
return value_t(static_cast<scope_t *>(post.xact));
|
return value_t(static_cast<scope_t *>(post.xact));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
value_t get_xact_id(post_t& post) {
|
||||||
|
return static_cast<long>(post.xact_id());
|
||||||
|
}
|
||||||
|
|
||||||
value_t get_code(post_t& post) {
|
value_t get_code(post_t& post) {
|
||||||
if (post.xact->code)
|
if (post.xact->code)
|
||||||
return string_value(*post.xact->code);
|
return string_value(*post.xact->code);
|
||||||
|
|
@ -275,6 +279,10 @@ namespace {
|
||||||
return string_value(name);
|
return string_value(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
value_t get_account_id(post_t& post) {
|
||||||
|
return static_cast<long>(post.account_id());
|
||||||
|
}
|
||||||
|
|
||||||
value_t get_account_base(post_t& post) {
|
value_t get_account_base(post_t& post) {
|
||||||
return string_value(post.reported_account()->name);
|
return string_value(post.reported_account()->name);
|
||||||
}
|
}
|
||||||
|
|
@ -351,6 +359,8 @@ expr_t::ptr_op_t post_t::lookup(const symbol_t::kind_t kind,
|
||||||
return WRAP_FUNCTOR(get_account);
|
return WRAP_FUNCTOR(get_account);
|
||||||
else if (name == "account_base")
|
else if (name == "account_base")
|
||||||
return WRAP_FUNCTOR(get_wrapper<&get_account_base>);
|
return WRAP_FUNCTOR(get_wrapper<&get_account_base>);
|
||||||
|
else if (name == "account_id")
|
||||||
|
return WRAP_FUNCTOR(get_wrapper<&get_account_id>);
|
||||||
else if (name == "any")
|
else if (name == "any")
|
||||||
return WRAP_FUNCTOR(&fn_any);
|
return WRAP_FUNCTOR(&fn_any);
|
||||||
else if (name == "all")
|
else if (name == "all")
|
||||||
|
|
@ -444,6 +454,8 @@ expr_t::ptr_op_t post_t::lookup(const symbol_t::kind_t kind,
|
||||||
case 'x':
|
case 'x':
|
||||||
if (name == "xact")
|
if (name == "xact")
|
||||||
return WRAP_FUNCTOR(get_wrapper<&get_xact>);
|
return WRAP_FUNCTOR(get_wrapper<&get_xact>);
|
||||||
|
else if (name == "xact_id")
|
||||||
|
return WRAP_FUNCTOR(get_wrapper<&get_xact_id>);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'N':
|
case 'N':
|
||||||
|
|
@ -479,6 +491,30 @@ amount_t post_t::resolve_expr(scope_t& scope, expr_t& expr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::size_t post_t::xact_id() const
|
||||||
|
{
|
||||||
|
std::size_t id = 1;
|
||||||
|
foreach (post_t * p, xact->posts) {
|
||||||
|
if (p == this)
|
||||||
|
return id;
|
||||||
|
id++;
|
||||||
|
}
|
||||||
|
assert(! "Failed to find posting within its transaction");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::size_t post_t::account_id() const
|
||||||
|
{
|
||||||
|
std::size_t id = 1;
|
||||||
|
foreach (post_t * p, account->posts) {
|
||||||
|
if (p == this)
|
||||||
|
return id;
|
||||||
|
id++;
|
||||||
|
}
|
||||||
|
assert(! "Failed to find posting within its transaction");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
bool post_t::valid() const
|
bool post_t::valid() const
|
||||||
{
|
{
|
||||||
if (! xact) {
|
if (! xact) {
|
||||||
|
|
|
||||||
|
|
@ -118,6 +118,9 @@ public:
|
||||||
|
|
||||||
amount_t resolve_expr(scope_t& scope, expr_t& expr);
|
amount_t resolve_expr(scope_t& scope, expr_t& expr);
|
||||||
|
|
||||||
|
std::size_t xact_id() const;
|
||||||
|
std::size_t account_id() const;
|
||||||
|
|
||||||
bool valid() const;
|
bool valid() const;
|
||||||
|
|
||||||
struct xdata_t : public supports_flags<uint_least16_t>
|
struct xdata_t : public supports_flags<uint_least16_t>
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue