diff options
author | Jakob Demler <jdemler@curry-software.com> | 2017-11-02 14:43:37 +0100 |
---|---|---|
committer | Jakob Demler <jdemler@curry-software.com> | 2017-11-02 14:44:58 +0100 |
commit | 31ef0ac9360e8d2a2c624892f02325c8a0aef603 (patch) | |
tree | 06ff0632b2b5455dfddce39ae727fa3739d36d70 /src/account.cc | |
parent | d19adce1ff4aae123028584d59acda92905a711c (diff) | |
download | fork-ledger-31ef0ac9360e8d2a2c624892f02325c8a0aef603.tar.gz fork-ledger-31ef0ac9360e8d2a2c624892f02325c8a0aef603.tar.bz2 fork-ledger-31ef0ac9360e8d2a2c624892f02325c8a0aef603.zip |
account to return the depth of its last displayed parent
Diffstat (limited to 'src/account.cc')
-rw-r--r-- | src/account.cc | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/account.cc b/src/account.cc index da8b0b8e..114c4cc5 100644 --- a/src/account.cc +++ b/src/account.cc @@ -309,6 +309,20 @@ namespace { return long(&account); } + value_t get_depth_parent(account_t& account) + { + std::size_t depth = 0; + for (const account_t * acct = account.parent; + acct && acct->parent; + acct = acct->parent) { + std::size_t count = acct->children_with_flags(ACCOUNT_EXT_TO_DISPLAY); + assert(count > 0); + if (count > 1 || acct->has_xflags(ACCOUNT_EXT_TO_DISPLAY)) + depth++; + } + return long(depth); + } + value_t get_depth_spacer(account_t& account) { std::size_t depth = 0; @@ -425,6 +439,8 @@ expr_t::ptr_op_t account_t::lookup(const symbol_t::kind_t kind, case 'd': if (fn_name == "depth") return WRAP_FUNCTOR(get_wrapper<&get_depth>); + else if (fn_name == "depth_parent") + return WRAP_FUNCTOR(get_wrapper<&get_depth_parent>); else if (fn_name == "depth_spacer") return WRAP_FUNCTOR(get_wrapper<&get_depth_spacer>); break; |