diff options
author | John Wiegley <johnw@newartisans.com> | 2007-04-19 20:31:46 +0000 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2008-04-13 03:38:28 -0400 |
commit | 0a6b5726ec3bf402a953ea8a03b98ecbf4b90b0c (patch) | |
tree | 0a2c2aca7100d045f491b03f0a5bda92378d3ef9 /xml.cc | |
parent | 176b3044e355398a0c31e0c42a3cd7b8a2e3f3e5 (diff) | |
download | fork-ledger-0a6b5726ec3bf402a953ea8a03b98ecbf4b90b0c.tar.gz fork-ledger-0a6b5726ec3bf402a953ea8a03b98ecbf4b90b0c.tar.bz2 fork-ledger-0a6b5726ec3bf402a953ea8a03b98ecbf4b90b0c.zip |
Made the amount/balance/value interface a bit more rational; added
back a useless version of the register command (just to prove the
command sequence); and added smart XML semantics to the XPath
implementation so that nodes can be coerced to values.
Diffstat (limited to 'xml.cc')
-rw-r--r-- | xml.cc | 46 |
1 files changed, 36 insertions, 10 deletions
@@ -9,11 +9,18 @@ namespace ledger { namespace xml { -document_t::document_t(node_t *, const char ** _builtins, +document_t::document_t(node_t * _top, const char ** _builtins, const int _builtins_size) : builtins(_builtins), builtins_size(_builtins_size), top(new terminal_node_t(this)) {} +void document_t::set_top(node_t * _top) +{ + if (top) + delete top; + top = _top; +} + int document_t::register_name(const std::string& name) { int index = lookup_name_id(name); @@ -102,16 +109,9 @@ node_t::node_t(document_t * _document, parent_node_t * _parent, flags(_flags), info(NULL), attrs(NULL) { TRACE_CTOR("node_t(document_t *, node_t *)"); -#ifdef THREADSAFE document = _document; -#else - if (! document) - document = _document; -#if 0 - else - assert(document == _document); -#endif -#endif + if (! document->top) + document->set_top(this); if (parent) parent->add_child(this); } @@ -359,6 +359,18 @@ document_t * parser_t::parse(std::istream& in, const char ** builtins, return doc.release(); } +node_t * commodity_node_t::children() const +{ + // jww (2007-04-19): Need to report the commodity and its details + return NULL; +} + +node_t * amount_node_t::children() const +{ + // jww (2007-04-19): Need to report the quantity and commodity + return NULL; +} + node_t * transaction_node_t::children() const { if (! _children) { @@ -370,6 +382,20 @@ node_t * transaction_node_t::children() const return parent_node_t::children(); } +node_t * transaction_node_t::lookup_child(int _name_id) +{ + if (_name_id == payee_id) { + payee_virtual_node = new terminal_node_t(document); + payee_virtual_node->set_text(transaction->entry->payee); + return payee_virtual_node; + } +} + +value_t transaction_node_t::to_value() const +{ + return transaction->amount; +} + node_t * entry_node_t::children() const { if (! _children) { |