summaryrefslogtreecommitdiff
path: root/src/xml.h
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2007-05-01 04:36:49 +0000
committerJohn Wiegley <johnw@newartisans.com>2008-04-13 03:38:35 -0400
commite92bcf411d2e9a55969303ba3893a017152d7c18 (patch)
treee7b52d09751de39c86ede91f88a2fcf24facfb27 /src/xml.h
parent50a9caf302936ba6f61bbe05b4718f199d0d584c (diff)
downloadfork-ledger-e92bcf411d2e9a55969303ba3893a017152d7c18.tar.gz
fork-ledger-e92bcf411d2e9a55969303ba3893a017152d7c18.tar.bz2
fork-ledger-e92bcf411d2e9a55969303ba3893a017152d7c18.zip
Started using boost::optional<T>.
Diffstat (limited to 'src/xml.h')
-rw-r--r--src/xml.h35
1 files changed, 18 insertions, 17 deletions
diff --git a/src/xml.h b/src/xml.h
index cf80455d..87f2c802 100644
--- a/src/xml.h
+++ b/src/xml.h
@@ -1,6 +1,7 @@
#ifndef _XML_H
#define _XML_H
+#include "journal.h"
#include "value.h"
#include "parser.h"
@@ -45,7 +46,7 @@ public:
virtual ~node_t() {
TRACE_DTOR(node_t);
if (parent) extract();
- if (attrs) delete attrs;
+ if (attrs) checked_delete(attrs);
}
void extract(); // extract this node from its parent's child list
@@ -249,10 +250,10 @@ class xml_parser_t : public parser_t
public:
virtual bool test(std::istream& in) const;
- virtual unsigned int parse(std::istream& in,
- journal_t * journal,
- account_t * master = NULL,
- const string * original_file = NULL);
+ virtual unsigned int parse(std::istream& in,
+ journal_t * journal,
+ account_t * master = NULL,
+ const optional<path>& original = optional<path>());
};
DECLARE_EXCEPTION(parse_error);
@@ -319,7 +320,7 @@ public:
virtual ~transaction_node_t() {
TRACE_DTOR(transaction_node_t);
if (payee_virtual_node)
- delete payee_virtual_node;
+ checked_delete(payee_virtual_node);
}
virtual node_t * children() const;
@@ -387,33 +388,33 @@ public:
};
template <typename T>
-inline parent_node_t * wrap_node(document_t * doc, T * item,
- void * parent_node = NULL) {
- assert(0);
+inline typename T::node_type *
+wrap_node(document_t * doc, T * item, void * parent_node = NULL) {
+ assert(false);
return NULL;
}
template <>
-inline parent_node_t * wrap_node(document_t * doc, transaction_t * xact,
- void * parent_node) {
+inline transaction_t::node_type *
+wrap_node(document_t * doc, transaction_t * xact, void * parent_node) {
return new transaction_node_t(doc, xact, (parent_node_t *)parent_node);
}
template <>
-inline parent_node_t * wrap_node(document_t * doc, entry_t * entry,
- void * parent_node) {
+inline entry_t::node_type *
+wrap_node(document_t * doc, entry_t * entry, void * parent_node) {
return new entry_node_t(doc, entry, (parent_node_t *)parent_node);
}
template <>
-inline parent_node_t * wrap_node(document_t * doc, account_t * account,
- void * parent_node) {
+inline account_t::node_type *
+wrap_node(document_t * doc, account_t * account, void * parent_node) {
return new account_node_t(doc, account, (parent_node_t *)parent_node);
}
template <>
-inline parent_node_t * wrap_node(document_t * doc, journal_t * journal,
- void * parent_node) {
+inline journal_t::node_type *
+wrap_node(document_t * doc, journal_t * journal, void * parent_node) {
return new journal_node_t(doc, journal, (parent_node_t *)parent_node);
}