summaryrefslogtreecommitdiff
path: root/src/temps.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2010-06-02 01:55:55 -0400
committerJohn Wiegley <johnw@newartisans.com>2010-06-02 01:55:55 -0400
commitcda19829bd1100d6563b48ddb121f2afc1c55d95 (patch)
tree5b6ab0d1eb7ec1b0b3eccf817678d0aa9a3feb47 /src/temps.cc
parent017492ef5e80003073c5d053252d4a68a44260ae (diff)
parentfb7cafa8965c89bbd66b09f827bd5989a87c983b (diff)
downloadfork-ledger-cda19829bd1100d6563b48ddb121f2afc1c55d95.tar.gz
fork-ledger-cda19829bd1100d6563b48ddb121f2afc1c55d95.tar.bz2
fork-ledger-cda19829bd1100d6563b48ddb121f2afc1c55d95.zip
Merge branch 'next'
Diffstat (limited to 'src/temps.cc')
-rw-r--r--src/temps.cc51
1 files changed, 28 insertions, 23 deletions
diff --git a/src/temps.cc b/src/temps.cc
index 68b9ffa0..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)
@@ -91,9 +71,9 @@ post_t& temporaries_t::copy_post(post_t& origin, xact_t& xact,
post_temps->push_back(origin);
post_t& temp(post_temps->back());
+ temp.add_flags(ITEM_TEMP);
if (account)
temp.account = account;
- temp.add_flags(ITEM_TEMP);
temp.account->add_post(&temp);
xact.add_post(&temp);
@@ -109,8 +89,8 @@ post_t& temporaries_t::create_post(xact_t& xact, account_t * account)
post_temps->push_back(post_t(account));
post_t& temp(post_temps->back());
- temp.account = account;
temp.add_flags(ITEM_TEMP);
+ temp.account = account;
temp.account->add_post(&temp);
xact.add_post(&temp);
@@ -127,11 +107,36 @@ account_t& temporaries_t::create_account(const string& name,
acct_temps->push_back(account_t(parent, name));
account_t& temp(acct_temps->back());
+ temp.add_flags(ACCOUNT_TEMP);
if (parent)
parent->add_account(&temp);
- temp.add_flags(ACCOUNT_TEMP);
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