32 #ifndef GNC_ACCOUNT_HPP 33 #define GNC_ACCOUNT_HPP 42 #include <TransactionP.hpp> 44 using SplitsVec = std::vector<Split*>;
45 using AccountVec = std::vector<Account*>;
47 const SplitsVec& xaccAccountGetSplits (
const Account*);
49 void gnc_account_foreach_descendant (
const Account *, std::function<
void(
Account*)> func);
52 static inline SplitsVec::const_iterator
53 splits_start (
const SplitsVec& splits, std::optional<time64> start_date)
55 if (!start_date)
return splits.begin();
56 return std::lower_bound (splits.begin(), splits.end(), *start_date,
57 [](
auto s,
time64 t){
return s->parent->date_posted < t; });
60 static inline SplitsVec::const_iterator
61 splits_end (
const SplitsVec& splits, std::optional<time64> end_date)
63 if (!end_date)
return splits.end();
64 return std::upper_bound (splits.begin(), splits.end(), *end_date,
65 [](
time64 t,
auto s){
return t < s->parent->date_posted; });
68 template <
typename Fn>
69 void gnc_account_foreach_split_between_dates (
const Account* account,
70 std::optional<time64> start_date,
71 std::optional<time64> end_date,
72 bool include_descendants, Fn&& fn)
74 g_return_if_fail (GNC_IS_ACCOUNT (account));
75 auto scan_account = [&](
const Account* acc)
77 const auto& splits = xaccAccountGetSplits (acc);
78 std::for_each (splits_start (splits, start_date), splits_end (splits, end_date),
82 scan_account (account);
83 if (include_descendants)
84 gnc_account_foreach_descendant (account, scan_account);
87 void gnc_account_foreach_split (
const Account*, std::function<
void(Split*)>);
89 void gnc_account_foreach_split_until_date (
const Account *acc,
time64 end_date,
90 std::function<
void(Split*)> f);
104 std::vector<const Account*> gnc_account_get_all_parents (
const Account *account);
Account handling public routines.
Split * gnc_account_find_split(const Account *, std::function< bool(const Split *)>, bool)
scans account split list (in forward or reverse order) until predicate split->bool returns true...
gint64 time64
Most systems that are currently maintained, including Microsoft Windows, BSD-derived Unixes and Linux...