summaryrefslogtreecommitdiff
path: root/xml.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2007-04-20 23:49:18 +0000
committerJohn Wiegley <johnw@newartisans.com>2008-04-13 03:38:29 -0400
commitc30f52090012f4632f4cfe6536abc4af7edfe363 (patch)
tree07388964ba67caba450283b28c7a9eff7e01a220 /xml.cc
parentb84f676946941df6f7e8476d77d1db0cbe7736c5 (diff)
downloadfork-ledger-c30f52090012f4632f4cfe6536abc4af7edfe363.tar.gz
fork-ledger-c30f52090012f4632f4cfe6536abc4af7edfe363.tar.bz2
fork-ledger-c30f52090012f4632f4cfe6536abc4af7edfe363.zip
Decreased memory usage considerably
Diffstat (limited to 'xml.cc')
-rw-r--r--xml.cc37
1 files changed, 30 insertions, 7 deletions
diff --git a/xml.cc b/xml.cc
index 02db6021..b4be437f 100644
--- a/xml.cc
+++ b/xml.cc
@@ -11,21 +11,21 @@ namespace xml {
document_t::document_t(node_t * _top, const char ** _builtins,
const int _builtins_size)
- : builtins(_builtins), builtins_size(_builtins_size),
- top(_top ? _top : new terminal_node_t(this)) {
- TRACE_CTOR("xml::document_t(node_t *, const char **, const int)");
+ : builtins(_builtins), builtins_size(_builtins_size), stub(this),
+ top(_top ? _top : &stub) {
+ TRACE_CTOR(xml::document_t, "node_t *, const char **, const int");
}
document_t::~document_t()
{
- TRACE_DTOR("xml::document_t");
- if (top)
+ TRACE_DTOR(xml::document_t);
+ if (top && top != &stub)
delete top;
}
void document_t::set_top(node_t * _top)
{
- if (top)
+ if (top && top != &stub)
delete top;
top = _top;
}
@@ -117,7 +117,7 @@ node_t::node_t(document_t * _document, parent_node_t * _parent,
: name_id(0), parent(_parent), next(NULL), prev(NULL),
flags(_flags), info(NULL), attrs(NULL)
{
- TRACE_CTOR("node_t(document_t *, node_t *)");
+ TRACE_CTOR(node_t, "document_t *, node_t *");
document = _document;
if (document && ! document->top)
document->set_top(this);
@@ -147,6 +147,29 @@ void node_t::extract()
prev = NULL;
}
+const char * node_t::name() const
+{
+ return document->lookup_name(name_id);
+}
+
+int node_t::set_name(const char * _name)
+{
+ name_id = document->register_name(_name);
+ return name_id;
+}
+
+node_t * node_t::lookup_child(const char * _name)
+{
+ int id = document->lookup_name_id(_name);
+ return lookup_child(id);
+}
+
+node_t * node_t::lookup_child(const string& _name)
+{
+ int id = document->lookup_name_id(_name);
+ return lookup_child(id);
+}
+
void parent_node_t::clear()
{
node_t * child = _children;