diff options
author | John Wiegley <johnw@newartisans.com> | 2007-05-01 04:36:49 +0000 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2008-04-13 03:38:35 -0400 |
commit | e92bcf411d2e9a55969303ba3893a017152d7c18 (patch) | |
tree | e7b52d09751de39c86ede91f88a2fcf24facfb27 /src/xml.cc | |
parent | 50a9caf302936ba6f61bbe05b4718f199d0d584c (diff) | |
download | fork-ledger-e92bcf411d2e9a55969303ba3893a017152d7c18.tar.gz fork-ledger-e92bcf411d2e9a55969303ba3893a017152d7c18.tar.bz2 fork-ledger-e92bcf411d2e9a55969303ba3893a017152d7c18.zip |
Started using boost::optional<T>.
Diffstat (limited to 'src/xml.cc')
-rw-r--r-- | src/xml.cc | 20 |
1 files changed, 13 insertions, 7 deletions
@@ -29,13 +29,13 @@ document_t::~document_t() { TRACE_DTOR(xml::document_t); if (top && top != &stub) - delete top; + checked_delete(top); } void document_t::set_top(node_t * _top) { if (top && top != &stub) - delete top; + checked_delete(top); top = _top; } @@ -191,7 +191,7 @@ void parent_node_t::clear() node_t * child = _children; while (child) { node_t * tnext = child->next; - delete child; + checked_delete(child); child = tnext; } } @@ -443,7 +443,10 @@ node_t * transaction_node_t::lookup_child(int _name_id) const value_t transaction_node_t::to_value() const { - return transaction->amount; + if (transaction->amount) + return *transaction->amount; + else + return value_t(); } node_t * entry_node_t::children() const @@ -461,11 +464,14 @@ node_t * entry_node_t::lookup_child(int _name_id) const { switch (_name_id) { case document_t::CODE: + if (! entry->code) + return NULL; + // jww (2007-04-20): I have to save this and then delete it later terminal_node_t * code_node = new terminal_node_t(document, const_cast<entry_node_t *>(this)); code_node->set_name(document_t::CODE); - code_node->set_text(entry->code); + code_node->set_text(*entry->code); return code_node; case document_t::PAYEE: @@ -489,11 +495,11 @@ node_t * account_node_t::children() const name_node->set_text(account->name); } - if (! account->note.empty()) { + if (account->note) { terminal_node_t * note_node = new terminal_node_t(document, const_cast<account_node_t *>(this)); note_node->set_name(document_t::NOTE); - note_node->set_text(account->note); + note_node->set_text(*account->note); } for (accounts_map::iterator i = account->accounts.begin(); |