diff --git a/XPath/XPath.hpp b/XPath/XPath.hpp index e224a3bf..2f61c482 100644 --- a/XPath/XPath.hpp +++ b/XPath/XPath.hpp @@ -33,7 +33,7 @@ xpath_resolver_holder.hpp xpath_step.hpp xpath_union.hpp xpath_value.hpp -xpath_variable.hpp +DONE - xpath_variable.hpp DONE - xpath_variable_resolver.hpp xpath_axis_enumerator.cpp diff --git a/XPath/impl/xpath_parser.hpp b/XPath/impl/xpath_parser.hpp index 2ebd134a..30e4e62b 100644 --- a/XPath/impl/xpath_parser.hpp +++ b/XPath/impl/xpath_parser.hpp @@ -472,7 +472,7 @@ XPathExpression* XPath::createBinaryEx p1 = new AndOperator(p1, p2); break; case impl::UnionOperator_id: - p1 = new UnionExpression(p1, p2); + p1 = new UnionExpression(p1, p2); break; default: throw UnsupportedException(boost::lexical_cast(op)); diff --git a/XPath/impl/xpath_union.hpp b/XPath/impl/xpath_union.hpp index 00022601..d7a59cce 100644 --- a/XPath/impl/xpath_union.hpp +++ b/XPath/impl/xpath_union.hpp @@ -9,24 +9,26 @@ namespace Arabica namespace XPath { -class UnionExpression : private BinaryExpression, public XPathExpression +template +class UnionExpression : private BinaryExpression, public XPathExpression { + typedef BinaryExpression baseT; public: - UnionExpression(XPathExpression* lhs, XPathExpression* rhs) : - BinaryExpression(lhs, rhs) { } + UnionExpression(XPathExpression* lhs, XPathExpression* rhs) : + BinaryExpression(lhs, rhs) { } - virtual XPathValuePtr evaluate(const DOM::Node& context, + virtual XPathValuePtr evaluate(const DOM::Node& context, const ExecutionContext& executionContext) const { - XPathValuePtr p1 = lhs()->evaluate(context, executionContext); + XPathValuePtr p1 = baseT::lhs()->evaluate(context, executionContext); if(p1->type() != NODE_SET) throw RuntimeException("Union operator joins node-sets. First argument is not a node-set."); - XPathValuePtr p2 = rhs()->evaluate(context, executionContext); + XPathValuePtr p2 = baseT::rhs()->evaluate(context, executionContext); if(p2->type() != NODE_SET) throw RuntimeException("Union operator joins node-sets. Second argument is not a node-set."); - NodeSet ns1(p1->asNodeSet()); - NodeSet ns2(p2->asNodeSet()); + NodeSet ns1(p1->asNodeSet()); + NodeSet ns2(p2->asNodeSet()); // do the obvious optimizations if(ns1.empty()) @@ -36,10 +38,10 @@ public: ns1.to_document_order(); ns2.to_document_order(); - NodeSet::const_iterator n1 = ns1.begin(), n1e = ns1.end(); - NodeSet::const_iterator n2 = ns2.begin(), n2e = ns2.end(); + NodeSet::const_iterator n1 = ns1.begin(), n1e = ns1.end(); + NodeSet::const_iterator n2 = ns2.begin(), n2e = ns2.end(); - NodeSet result(true); + NodeSet result(true); while((n1 != n1e) && (n2 != n2e)) { @@ -63,9 +65,9 @@ public: } // evaluate private: - XPathValuePtr wrap(const NodeSet& ns) const + XPathValuePtr wrap(const NodeSet& ns) const { - return XPathValuePtr(new NodeSetValue(ns)); + return XPathValuePtr(new NodeSetValue(ns)); } // wrap }; // UnionExpression