diff options
author | John Wiegley <johnw@newartisans.com> | 2010-05-30 02:20:34 -0600 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2010-05-30 02:38:30 -0600 |
commit | 8f17d01f5e48ae5097f4cb38d481b00577329b8c (patch) | |
tree | 2db7a0f4b156ec88cf4d785b9d7a4ea2dae60a07 /src/temps.cc | |
parent | 7ec52d2b395bf4cfc656eef52d72b9d83c1c1523 (diff) | |
download | fork-ledger-8f17d01f5e48ae5097f4cb38d481b00577329b8c.tar.gz fork-ledger-8f17d01f5e48ae5097f4cb38d481b00577329b8c.tar.bz2 fork-ledger-8f17d01f5e48ae5097f4cb38d481b00577329b8c.zip |
Added new required item_handler_t::clear() method
Diffstat (limited to 'src/temps.cc')
-rw-r--r-- | src/temps.cc | 45 |
1 files changed, 25 insertions, 20 deletions
diff --git a/src/temps.cc b/src/temps.cc index dcaa9101..7a630176 100644 --- a/src/temps.cc +++ b/src/temps.cc @@ -38,26 +38,6 @@ namespace ledger { -temporaries_t::~temporaries_t() -{ - if (post_temps) { - foreach (post_t& post, *post_temps) { - if (! post.xact->has_flags(ITEM_TEMP)) - post.xact->remove_post(&post); - - if (post.account && ! post.account->has_flags(ACCOUNT_TEMP)) - post.account->remove_post(&post); - } - } - - if (acct_temps) { - foreach (account_t& acct, *acct_temps) { - if (acct.parent && ! acct.parent->has_flags(ACCOUNT_TEMP)) - acct.parent->remove_account(&acct); - } - } -} - xact_t& temporaries_t::copy_xact(xact_t& origin) { if (! xact_temps) @@ -134,4 +114,29 @@ account_t& temporaries_t::create_account(const string& name, return temp; } +void temporaries_t::clear() +{ + if (post_temps) { + foreach (post_t& post, *post_temps) { + if (! post.xact->has_flags(ITEM_TEMP)) + post.xact->remove_post(&post); + + if (post.account && ! post.account->has_flags(ACCOUNT_TEMP)) + post.account->remove_post(&post); + } + post_temps->clear(); + } + + if (xact_temps) + xact_temps->clear(); + + if (acct_temps) { + foreach (account_t& acct, *acct_temps) { + if (acct.parent && ! acct.parent->has_flags(ACCOUNT_TEMP)) + acct.parent->remove_account(&acct); + } + acct_temps->clear(); + } +} + } // namespace ledger |