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 /xpath.cc | |
parent | 176b3044e355398a0c31e0c42a3cd7b8a2e3f3e5 (diff) | |
download | ledger-0a6b5726ec3bf402a953ea8a03b98ecbf4b90b0c.tar.gz ledger-0a6b5726ec3bf402a953ea8a03b98ecbf4b90b0c.tar.bz2 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 'xpath.cc')
-rw-r--r-- | xpath.cc | 17 |
1 files changed, 7 insertions, 10 deletions
@@ -714,6 +714,7 @@ xpath_t::parse_value_term(std::istream& in, unsigned short tflags) const case token_t::SLASH: node.reset(new op_t(op_t::NODE_ID)); node->name_id = document_t::ROOT; + push_token(); break; case token_t::STAR: node.reset(new op_t(op_t::NODE_ID)); @@ -783,11 +784,6 @@ xpath_t::parse_path_expr(std::istream& in, unsigned short tflags) const std::auto_ptr<op_t> node(parse_predicate_expr(in, tflags)); if (node.get()) { - // If the beginning of the path was /, just put it back; this - // makes parsing much simpler. - if (node->kind == op_t::NODE_ID && node->name_id == document_t::ROOT) - push_token(); - token_t& tok = next_token(in, tflags); while (tok.kind == token_t::SLASH) { std::auto_ptr<op_t> prev(node.release()); @@ -843,7 +839,7 @@ xpath_t::parse_unary_expr(std::istream& in, unsigned short tflags) const " operator not followed by argument"); // A very quick optimization if (texpr->kind == op_t::VALUE) { - texpr->valuep->negate(); + texpr->valuep->in_place_negate(); node.reset(texpr.release()); } else { node.reset(new op_t(op_t::O_NEG)); @@ -1422,9 +1418,9 @@ xpath_t::op_t * xpath_t::op_t::compile(value_t * context, scope_t * scope, } if (left == expr) { - return wrap_value(expr->valuep->negated())->acquire(); + return wrap_value(expr->valuep->negate())->acquire(); } else { - expr->valuep->negate(); + expr->valuep->in_place_negate(); return expr->acquire(); } } @@ -1782,6 +1778,7 @@ xpath_t::op_t * xpath_t::op_t::compile(value_t * context, scope_t * scope, xpath_t lexpr(left->compile(context, scope, resolve)); xpath_t rexpr(resolve ? right->acquire() : right->compile(context, scope, false)); + if (! lexpr->constant() || ! resolve) { if (left == lexpr) return acquire(); @@ -1952,9 +1949,9 @@ void xpath_t::context::describe(std::ostream& out) const throw() } } -bool xpath_t::op_t::write(std::ostream& out, +bool xpath_t::op_t::write(std::ostream& out, const bool relaxed, - const op_t * op_to_find, + const op_t * op_to_find, unsigned long * start_pos, unsigned long * end_pos) const { |