mirror of
https://github.com/jezhiggins/arabica
synced 2025-01-17 18:12:04 +01:00
This commit is contained in:
parent
b0353ff1be
commit
645247287d
2 changed files with 115 additions and 94 deletions
|
@ -115,10 +115,10 @@ public:
|
||||||
void resetFunctionResolver() { functionResolver_.set(FunctionResolverPtr<string_type, string_adaptor>(new NullFunctionResolver<string_type, string_adaptor>())); }
|
void resetFunctionResolver() { functionResolver_.set(FunctionResolverPtr<string_type, string_adaptor>(new NullFunctionResolver<string_type, string_adaptor>())); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef XPathExpression<string_type, string_adaptor>* (*compileFn)(typename impl::types<string_adaptor>::node_iter_t const& i, impl::CompilationContext<string_type, string_adaptor>& context);
|
typedef XPathExpression<string_type, string_adaptor>* (*compileFn)(typename impl::types<string_adaptor>::node_iter_t const& i,
|
||||||
|
typename impl::types<string_adaptor>::node_iter_t const& ie,
|
||||||
|
impl::CompilationContext<string_type, string_adaptor>& context);
|
||||||
typedef typename impl::types<string_adaptor>::tree_info_t(XPath::*parserFn)(const string_type& str) const;
|
typedef typename impl::types<string_adaptor>::tree_info_t(XPath::*parserFn)(const string_type& str) const;
|
||||||
typedef XPathExpression<string_type, string_adaptor>* (*compilerFn)(typename impl::types<string_adaptor>::node_iter_t const& i,
|
|
||||||
impl::CompilationContext<string_type, string_adaptor>& context);
|
|
||||||
|
|
||||||
XPathExpressionPtr<string_type, string_adaptor> do_compile(const string_type& xpath,
|
XPathExpressionPtr<string_type, string_adaptor> do_compile(const string_type& xpath,
|
||||||
parserFn parser,
|
parserFn parser,
|
||||||
|
@ -132,7 +132,10 @@ private:
|
||||||
|
|
||||||
impl::CompilationContext<string_type, string_adaptor> context(*this, getNamespaceContext(), getFunctionResolver());
|
impl::CompilationContext<string_type, string_adaptor> context(*this, getNamespaceContext(), getFunctionResolver());
|
||||||
//XPath::dump(ast.trees.begin(), 0);
|
//XPath::dump(ast.trees.begin(), 0);
|
||||||
return XPathExpressionPtr<string_type, string_adaptor>(compile_with_factory(ast.trees.begin(), context, factory));
|
return XPathExpressionPtr<string_type, string_adaptor>(compile_with_factory(ast.trees.begin(),
|
||||||
|
ast.trees.end(),
|
||||||
|
context,
|
||||||
|
factory));
|
||||||
} // try
|
} // try
|
||||||
catch(const std::exception&)
|
catch(const std::exception&)
|
||||||
{
|
{
|
||||||
|
@ -180,24 +183,28 @@ private:
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
public:
|
public:
|
||||||
static XPathExpression<string_type, string_adaptor>* compile_expression(typename impl::types<string_adaptor>::node_iter_t const& i,
|
static XPathExpression<string_type, string_adaptor>* compile_expression(typename impl::types<string_adaptor>::node_iter_t const& i,
|
||||||
impl::CompilationContext<string_type, string_adaptor>& context)
|
typename impl::types<string_adaptor>::node_iter_t const& ie,
|
||||||
|
impl::CompilationContext<string_type, string_adaptor>& context)
|
||||||
{
|
{
|
||||||
return compile_with_factory(i, context, XPath::expression_factory());
|
return compile_with_factory(i, ie, context, XPath::expression_factory());
|
||||||
} // compile_expression
|
} // compile_expression
|
||||||
|
|
||||||
static XPathExpression<string_type, string_adaptor>* compile_match(typename impl::types<string_adaptor>::node_iter_t const& i,
|
static XPathExpression<string_type, string_adaptor>* compile_match(typename impl::types<string_adaptor>::node_iter_t const& i,
|
||||||
impl::CompilationContext<string_type, string_adaptor>& context)
|
typename impl::types<string_adaptor>::node_iter_t const& ie,
|
||||||
|
impl::CompilationContext<string_type, string_adaptor>& context)
|
||||||
{
|
{
|
||||||
return compile_with_factory(i, context, XPath::match_factory());
|
return compile_with_factory(i, ie, context, XPath::match_factory());
|
||||||
} // compile_match
|
} // compile_match
|
||||||
|
|
||||||
static XPathExpression<string_type, string_adaptor>* compile_attribute_value(typename impl::types<string_adaptor>::node_iter_t const& i,
|
static XPathExpression<string_type, string_adaptor>* compile_attribute_value(typename impl::types<string_adaptor>::node_iter_t const& i,
|
||||||
impl::CompilationContext<string_type, string_adaptor>& context)
|
typename impl::types<string_adaptor>::node_iter_t const& ie,
|
||||||
|
impl::CompilationContext<string_type, string_adaptor>& context)
|
||||||
{
|
{
|
||||||
return compile_with_factory(i, context, XPath::attribute_value_factory());
|
return compile_with_factory(i, ie, context, XPath::attribute_value_factory());
|
||||||
} // compile_attribute_value
|
} // compile_attribute_value
|
||||||
|
|
||||||
static XPathExpression<string_type, string_adaptor>* compile_with_factory(typename impl::types<string_adaptor>::node_iter_t const& i,
|
static XPathExpression<string_type, string_adaptor>* compile_with_factory(typename impl::types<string_adaptor>::node_iter_t const& i,
|
||||||
|
typename impl::types<string_adaptor>::node_iter_t const& ie,
|
||||||
impl::CompilationContext<string_type, string_adaptor>& context,
|
impl::CompilationContext<string_type, string_adaptor>& context,
|
||||||
const std::map<int, compileFn>& factory)
|
const std::map<int, compileFn>& factory)
|
||||||
{
|
{
|
||||||
|
@ -210,7 +217,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return (f->second)(i, context);
|
return (f->second)(i, ie, context);
|
||||||
}
|
}
|
||||||
catch(...)
|
catch(...)
|
||||||
{
|
{
|
||||||
|
@ -220,34 +227,35 @@ public:
|
||||||
} // compile_with_factory
|
} // compile_with_factory
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static XPathExpression<string_type, string_adaptor>* createAbsoluteLocationPath(typename impl::types<string_adaptor>::node_iter_t const& i, impl::CompilationContext<string_type, string_adaptor>& context);
|
static XPathExpression<string_type, string_adaptor>* createAbsoluteLocationPath(typename impl::types<string_adaptor>::node_iter_t const& i, typename impl::types<string_adaptor>::node_iter_t const& ie, impl::CompilationContext<string_type, string_adaptor>& context);
|
||||||
static XPathExpression<string_type, string_adaptor>* createRelativeLocationPath(typename impl::types<string_adaptor>::node_iter_t const& i, impl::CompilationContext<string_type, string_adaptor>& context);
|
static XPathExpression<string_type, string_adaptor>* createRelativeLocationPath(typename impl::types<string_adaptor>::node_iter_t const& i, typename impl::types<string_adaptor>::node_iter_t const& ie, impl::CompilationContext<string_type, string_adaptor>& context);
|
||||||
static XPathExpression<string_type, string_adaptor>* createFilteredPath(typename impl::types<string_adaptor>::node_iter_t const& i, impl::CompilationContext<string_type, string_adaptor>& context);
|
static XPathExpression<string_type, string_adaptor>* createFilteredPath(typename impl::types<string_adaptor>::node_iter_t const& i, typename impl::types<string_adaptor>::node_iter_t const& ie, impl::CompilationContext<string_type, string_adaptor>& context);
|
||||||
static XPathExpression<string_type, string_adaptor>* createSingleStepRelativeLocationPath(typename impl::types<string_adaptor>::node_iter_t const& i, impl::CompilationContext<string_type, string_adaptor>& context);
|
static XPathExpression<string_type, string_adaptor>* createSingleStepRelativeLocationPath(typename impl::types<string_adaptor>::node_iter_t const& i, typename impl::types<string_adaptor>::node_iter_t const& ie, impl::CompilationContext<string_type, string_adaptor>& context);
|
||||||
static XPathExpression<string_type, string_adaptor>* createExpression(typename impl::types<string_adaptor>::node_iter_t const& i, impl::CompilationContext<string_type, string_adaptor>& context);
|
static XPathExpression<string_type, string_adaptor>* createExpression(typename impl::types<string_adaptor>::node_iter_t const& i, typename impl::types<string_adaptor>::node_iter_t const& ie, impl::CompilationContext<string_type, string_adaptor>& context);
|
||||||
static XPathExpression<string_type, string_adaptor>* createFunction(typename impl::types<string_adaptor>::node_iter_t const& i, impl::CompilationContext<string_type, string_adaptor>& context);
|
static XPathExpression<string_type, string_adaptor>* createFunction(typename impl::types<string_adaptor>::node_iter_t const& i, typename impl::types<string_adaptor>::node_iter_t const& ie, impl::CompilationContext<string_type, string_adaptor>& context);
|
||||||
static XPathExpression<string_type, string_adaptor>* createBinaryExpression(typename impl::types<string_adaptor>::node_iter_t const& i, impl::CompilationContext<string_type, string_adaptor>& context);
|
static XPathExpression<string_type, string_adaptor>* createBinaryExpression(typename impl::types<string_adaptor>::node_iter_t const& i, typename impl::types<string_adaptor>::node_iter_t const& ie, impl::CompilationContext<string_type, string_adaptor>& context);
|
||||||
static XPathExpression<string_type, string_adaptor>* createLiteral(typename impl::types<string_adaptor>::node_iter_t const& i, impl::CompilationContext<string_type, string_adaptor>& context);
|
static XPathExpression<string_type, string_adaptor>* createLiteral(typename impl::types<string_adaptor>::node_iter_t const& i, typename impl::types<string_adaptor>::node_iter_t const& ie, impl::CompilationContext<string_type, string_adaptor>& context);
|
||||||
static XPathExpression<string_type, string_adaptor>* createNumber(typename impl::types<string_adaptor>::node_iter_t const& i, impl::CompilationContext<string_type, string_adaptor>& context);
|
static XPathExpression<string_type, string_adaptor>* createNumber(typename impl::types<string_adaptor>::node_iter_t const& i, typename impl::types<string_adaptor>::node_iter_t const& ie, impl::CompilationContext<string_type, string_adaptor>& context);
|
||||||
static XPathExpression<string_type, string_adaptor>* createVariable(typename impl::types<string_adaptor>::node_iter_t const& i, impl::CompilationContext<string_type, string_adaptor>& context);
|
static XPathExpression<string_type, string_adaptor>* createVariable(typename impl::types<string_adaptor>::node_iter_t const& i, typename impl::types<string_adaptor>::node_iter_t const& ie, impl::CompilationContext<string_type, string_adaptor>& context);
|
||||||
static XPathExpression<string_type, string_adaptor>* createSingleStepAbsoluteLocationPath(typename impl::types<string_adaptor>::node_iter_t const& i, impl::CompilationContext<string_type, string_adaptor>& context);
|
static XPathExpression<string_type, string_adaptor>* createSingleStepAbsoluteLocationPath(typename impl::types<string_adaptor>::node_iter_t const& i, typename impl::types<string_adaptor>::node_iter_t const& ie, impl::CompilationContext<string_type, string_adaptor>& context);
|
||||||
static XPathExpression<string_type, string_adaptor>* createUnaryExpression(typename impl::types<string_adaptor>::node_iter_t const& i, impl::CompilationContext<string_type, string_adaptor>& context);
|
static XPathExpression<string_type, string_adaptor>* createUnaryExpression(typename impl::types<string_adaptor>::node_iter_t const& i, typename impl::types<string_adaptor>::node_iter_t const& ie, impl::CompilationContext<string_type, string_adaptor>& context);
|
||||||
static XPathExpression<string_type, string_adaptor>* createUnaryNegativeExpr(typename impl::types<string_adaptor>::node_iter_t const& i, impl::CompilationContext<string_type, string_adaptor>& context);
|
static XPathExpression<string_type, string_adaptor>* createUnaryNegativeExpr(typename impl::types<string_adaptor>::node_iter_t const& i, typename impl::types<string_adaptor>::node_iter_t const& ie, impl::CompilationContext<string_type, string_adaptor>& context);
|
||||||
|
|
||||||
static impl::StepList<string_type, string_adaptor> createStepList(typename impl::types<string_adaptor>::node_iter_t const& from, typename impl::types<string_adaptor>::node_iter_t const& to, impl::CompilationContext<string_type, string_adaptor>& context);
|
static impl::StepList<string_type, string_adaptor> createStepList(typename impl::types<string_adaptor>::node_iter_t const& from, typename impl::types<string_adaptor>::node_iter_t const& to, impl::CompilationContext<string_type, string_adaptor>& context);
|
||||||
|
|
||||||
static XPathExpression<string_type, string_adaptor>* createDocMatch(typename impl::types<string_adaptor>::node_iter_t const& i, impl::CompilationContext<string_type, string_adaptor>& context);
|
static XPathExpression<string_type, string_adaptor>* createDocMatch(typename impl::types<string_adaptor>::node_iter_t const& i, typename impl::types<string_adaptor>::node_iter_t const& ie, impl::CompilationContext<string_type, string_adaptor>& context);
|
||||||
static XPathExpression<string_type, string_adaptor>* createSingleMatchStep(typename impl::types<string_adaptor>::node_iter_t const& i, impl::CompilationContext<string_type, string_adaptor>& context);
|
static XPathExpression<string_type, string_adaptor>* createSingleMatchStep(typename impl::types<string_adaptor>::node_iter_t const& i, typename impl::types<string_adaptor>::node_iter_t const& ie, impl::CompilationContext<string_type, string_adaptor>& context);
|
||||||
static XPathExpression<string_type, string_adaptor>* createRelativePathPattern(typename impl::types<string_adaptor>::node_iter_t const& i, impl::CompilationContext<string_type, string_adaptor>& context);
|
static XPathExpression<string_type, string_adaptor>* createRelativePathPattern(typename impl::types<string_adaptor>::node_iter_t const& i, typename impl::types<string_adaptor>::node_iter_t const& ie, impl::CompilationContext<string_type, string_adaptor>& context);
|
||||||
static XPathExpression<string_type, string_adaptor>* createAlternatePattern(typename impl::types<string_adaptor>::node_iter_t const& i, impl::CompilationContext<string_type, string_adaptor>& context);
|
static XPathExpression<string_type, string_adaptor>* createAlternatePattern(typename impl::types<string_adaptor>::node_iter_t const& i, typename impl::types<string_adaptor>::node_iter_t const& ie, impl::CompilationContext<string_type, string_adaptor>& context);
|
||||||
static double defaultPriority(typename impl::types<string_adaptor>::node_iter_t const& i);
|
static double defaultPriority(typename impl::types<string_adaptor>::node_iter_t const& i,
|
||||||
|
typename impl::types<string_adaptor>::node_iter_t const& ie);
|
||||||
|
|
||||||
static impl::StepList<string_type, string_adaptor> createPatternList(typename impl::types<string_adaptor>::node_iter_t const& from, typename impl::types<string_adaptor>::node_iter_t const& to, impl::CompilationContext<string_type, string_adaptor>& context);
|
static impl::StepList<string_type, string_adaptor> createPatternList(typename impl::types<string_adaptor>::node_iter_t const& from, typename impl::types<string_adaptor>::node_iter_t const& to, impl::CompilationContext<string_type, string_adaptor>& context);
|
||||||
|
|
||||||
static XPathExpression<string_type, string_adaptor>* createAttributeValue(typename impl::types<string_adaptor>::node_iter_t const& i, impl::CompilationContext<string_type, string_adaptor>& context);
|
static XPathExpression<string_type, string_adaptor>* createAttributeValue(typename impl::types<string_adaptor>::node_iter_t const& i, typename impl::types<string_adaptor>::node_iter_t const& ie, impl::CompilationContext<string_type, string_adaptor>& context);
|
||||||
static XPathExpression<string_type, string_adaptor>* createEmbeddedExpr(typename impl::types<string_adaptor>::node_iter_t const& i, impl::CompilationContext<string_type, string_adaptor>& context);
|
static XPathExpression<string_type, string_adaptor>* createEmbeddedExpr(typename impl::types<string_adaptor>::node_iter_t const& i, typename impl::types<string_adaptor>::node_iter_t const& ie, impl::CompilationContext<string_type, string_adaptor>& context);
|
||||||
static XPathExpression<string_type, string_adaptor>* createDoubleLeftCurly(typename impl::types<string_adaptor>::node_iter_t const& i, impl::CompilationContext<string_type, string_adaptor>& context);
|
static XPathExpression<string_type, string_adaptor>* createDoubleLeftCurly(typename impl::types<string_adaptor>::node_iter_t const& i, typename impl::types<string_adaptor>::node_iter_t const& ie, impl::CompilationContext<string_type, string_adaptor>& context);
|
||||||
static XPathExpression<string_type, string_adaptor>* createDoubleRightCurly(typename impl::types<string_adaptor>::node_iter_t const& i, impl::CompilationContext<string_type, string_adaptor>& context);
|
static XPathExpression<string_type, string_adaptor>* createDoubleRightCurly(typename impl::types<string_adaptor>::node_iter_t const& i, typename impl::types<string_adaptor>::node_iter_t const& ie, impl::CompilationContext<string_type, string_adaptor>& context);
|
||||||
|
|
||||||
static std::map<int, compileFn>& expression_factory()
|
static std::map<int, compileFn>& expression_factory()
|
||||||
{
|
{
|
||||||
|
@ -508,19 +516,19 @@ namespace XPath
|
||||||
{
|
{
|
||||||
|
|
||||||
template<class string_type, class string_adaptor>
|
template<class string_type, class string_adaptor>
|
||||||
XPathExpression<string_type, string_adaptor>* XPath<string_type, string_adaptor>::createAbsoluteLocationPath(typename impl::types<string_adaptor>::node_iter_t const& i, impl::CompilationContext<string_type, string_adaptor>& context)
|
XPathExpression<string_type, string_adaptor>* XPath<string_type, string_adaptor>::createAbsoluteLocationPath(typename impl::types<string_adaptor>::node_iter_t const& i, typename impl::types<string_adaptor>::node_iter_t const& ie, impl::CompilationContext<string_type, string_adaptor>& context)
|
||||||
{
|
{
|
||||||
return new impl::AbsoluteLocationPath<string_type, string_adaptor>(createStepList(i->children.begin(), i->children.end(), context));
|
return new impl::AbsoluteLocationPath<string_type, string_adaptor>(createStepList(i->children.begin(), i->children.end(), context));
|
||||||
} // createAbsoluteLocationPath
|
} // createAbsoluteLocationPath
|
||||||
|
|
||||||
template<class string_type, class string_adaptor>
|
template<class string_type, class string_adaptor>
|
||||||
XPathExpression<string_type, string_adaptor>* XPath<string_type, string_adaptor>::createRelativeLocationPath(typename impl::types<string_adaptor>::node_iter_t const& i, impl::CompilationContext<string_type, string_adaptor>& context)
|
XPathExpression<string_type, string_adaptor>* XPath<string_type, string_adaptor>::createRelativeLocationPath(typename impl::types<string_adaptor>::node_iter_t const& i, typename impl::types<string_adaptor>::node_iter_t const& ie, impl::CompilationContext<string_type, string_adaptor>& context)
|
||||||
{
|
{
|
||||||
return new impl::RelativeLocationPath<string_type, string_adaptor>(createStepList(i->children.begin(), i->children.end(), context));
|
return new impl::RelativeLocationPath<string_type, string_adaptor>(createStepList(i->children.begin(), i->children.end(), context));
|
||||||
} // createRelativeLocationPath
|
} // createRelativeLocationPath
|
||||||
|
|
||||||
template<class string_type, class string_adaptor>
|
template<class string_type, class string_adaptor>
|
||||||
XPathExpression<string_type, string_adaptor>* XPath<string_type, string_adaptor>::createFilteredPath(typename impl::types<string_adaptor>::node_iter_t const& i, impl::CompilationContext<string_type, string_adaptor>& context)
|
XPathExpression<string_type, string_adaptor>* XPath<string_type, string_adaptor>::createFilteredPath(typename impl::types<string_adaptor>::node_iter_t const& i, typename impl::types<string_adaptor>::node_iter_t const& ie, impl::CompilationContext<string_type, string_adaptor>& context)
|
||||||
{
|
{
|
||||||
impl::StepList<string_type, string_adaptor> steps;
|
impl::StepList<string_type, string_adaptor> steps;
|
||||||
steps.push_back(impl::StepFactory<string_type, string_adaptor>::createFilter(i, context));
|
steps.push_back(impl::StepFactory<string_type, string_adaptor>::createFilter(i, context));
|
||||||
|
@ -528,22 +536,22 @@ XPathExpression<string_type, string_adaptor>* XPath<string_type, string_adaptor>
|
||||||
} // createFilteredPath
|
} // createFilteredPath
|
||||||
|
|
||||||
template<class string_type, class string_adaptor>
|
template<class string_type, class string_adaptor>
|
||||||
XPathExpression<string_type, string_adaptor>* XPath<string_type, string_adaptor>::createSingleStepRelativeLocationPath(typename impl::types<string_adaptor>::node_iter_t const& i, impl::CompilationContext<string_type, string_adaptor>& context)
|
XPathExpression<string_type, string_adaptor>* XPath<string_type, string_adaptor>::createSingleStepRelativeLocationPath(typename impl::types<string_adaptor>::node_iter_t const& i, typename impl::types<string_adaptor>::node_iter_t const& ie, impl::CompilationContext<string_type, string_adaptor>& context)
|
||||||
{
|
{
|
||||||
typename impl::types<string_adaptor>::node_iter_t n = i;
|
typename impl::types<string_adaptor>::node_iter_t n = i;
|
||||||
return new impl::RelativeLocationPath<string_type, string_adaptor>(impl::StepFactory<string_type, string_adaptor>::createStep(n, context));
|
return new impl::RelativeLocationPath<string_type, string_adaptor>(impl::StepFactory<string_type, string_adaptor>::createSingleStep(n, ie, context));
|
||||||
} // createSingleStepRelativeLocationPath
|
} // createSingleStepRelativeLocationPath
|
||||||
|
|
||||||
template<class string_type, class string_adaptor>
|
template<class string_type, class string_adaptor>
|
||||||
XPathExpression<string_type, string_adaptor>* XPath<string_type, string_adaptor>::createExpression(typename impl::types<string_adaptor>::node_iter_t const& i, impl::CompilationContext<string_type, string_adaptor>& context)
|
XPathExpression<string_type, string_adaptor>* XPath<string_type, string_adaptor>::createExpression(typename impl::types<string_adaptor>::node_iter_t const& i, typename impl::types<string_adaptor>::node_iter_t const& ie, impl::CompilationContext<string_type, string_adaptor>& context)
|
||||||
{
|
{
|
||||||
typename impl::types<string_adaptor>::node_iter_t c = i->children.begin();
|
typename impl::types<string_adaptor>::node_iter_t c = i->children.begin();
|
||||||
impl::skipWhitespace<string_adaptor>(c);
|
impl::skipWhitespace<string_adaptor>(c);
|
||||||
return XPath<string_type, string_adaptor>::compile_expression(c, context);
|
return XPath<string_type, string_adaptor>::compile_expression(c, i->children.end(), context);
|
||||||
} // createExpression
|
} // createExpression
|
||||||
|
|
||||||
template<class string_type, class string_adaptor>
|
template<class string_type, class string_adaptor>
|
||||||
XPathExpression<string_type, string_adaptor>* XPath<string_type, string_adaptor>::createFunction(typename impl::types<string_adaptor>::node_iter_t const& i, impl::CompilationContext<string_type, string_adaptor>& context)
|
XPathExpression<string_type, string_adaptor>* XPath<string_type, string_adaptor>::createFunction(typename impl::types<string_adaptor>::node_iter_t const& i, typename impl::types<string_adaptor>::node_iter_t const& ie, impl::CompilationContext<string_type, string_adaptor>& context)
|
||||||
{
|
{
|
||||||
typename impl::types<string_adaptor>::node_iter_t c = i->children.begin();
|
typename impl::types<string_adaptor>::node_iter_t c = i->children.begin();
|
||||||
|
|
||||||
|
@ -568,7 +576,7 @@ XPathExpression<string_type, string_adaptor>* XPath<string_type, string_adaptor>
|
||||||
std::vector<XPathExpressionPtr<string_type, string_adaptor> > args;
|
std::vector<XPathExpressionPtr<string_type, string_adaptor> > args;
|
||||||
while(impl::getNodeId<string_adaptor>(c) != impl::RightBracket_id)
|
while(impl::getNodeId<string_adaptor>(c) != impl::RightBracket_id)
|
||||||
{
|
{
|
||||||
XPathExpressionPtr<string_type, string_adaptor> arg(XPath<string_type, string_adaptor>::compile_expression(c++, context));
|
XPathExpressionPtr<string_type, string_adaptor> arg(XPath<string_type, string_adaptor>::compile_expression(c++, i->children.end(), context));
|
||||||
args.push_back(arg);
|
args.push_back(arg);
|
||||||
|
|
||||||
impl::skipWhitespace<string_adaptor>(c);
|
impl::skipWhitespace<string_adaptor>(c);
|
||||||
|
@ -579,17 +587,17 @@ XPathExpression<string_type, string_adaptor>* XPath<string_type, string_adaptor>
|
||||||
} // createFunction
|
} // createFunction
|
||||||
|
|
||||||
template<class string_type, class string_adaptor>
|
template<class string_type, class string_adaptor>
|
||||||
XPathExpression<string_type, string_adaptor>* XPath<string_type, string_adaptor>::createBinaryExpression(typename impl::types<string_adaptor>::node_iter_t const& i, impl::CompilationContext<string_type, string_adaptor>& context)
|
XPathExpression<string_type, string_adaptor>* XPath<string_type, string_adaptor>::createBinaryExpression(typename impl::types<string_adaptor>::node_iter_t const& i, typename impl::types<string_adaptor>::node_iter_t const& ie, impl::CompilationContext<string_type, string_adaptor>& context)
|
||||||
{
|
{
|
||||||
typename impl::types<string_adaptor>::node_iter_t c = i->children.begin();
|
typename impl::types<string_adaptor>::node_iter_t c = i->children.begin();
|
||||||
XPathExpression<string_type, string_adaptor>* p1 = XPath<string_type, string_adaptor>::compile_expression(c, context);
|
XPathExpression<string_type, string_adaptor>* p1 = XPath<string_type, string_adaptor>::compile_expression(c, i->children.end(), context);
|
||||||
++c;
|
++c;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
long op = impl::getNodeId<string_adaptor>(c);
|
long op = impl::getNodeId<string_adaptor>(c);
|
||||||
++c;
|
++c;
|
||||||
XPathExpression<string_type, string_adaptor>* p2 = XPath<string_type, string_adaptor>::compile_expression(c, context);
|
XPathExpression<string_type, string_adaptor>* p2 = XPath<string_type, string_adaptor>::compile_expression(c, i->children.end(), context);
|
||||||
|
|
||||||
switch(op)
|
switch(op)
|
||||||
{
|
{
|
||||||
|
@ -645,21 +653,21 @@ XPathExpression<string_type, string_adaptor>* XPath<string_type, string_adaptor>
|
||||||
} // createBinaryExpression
|
} // createBinaryExpression
|
||||||
|
|
||||||
template<class string_type, class string_adaptor>
|
template<class string_type, class string_adaptor>
|
||||||
XPathExpression<string_type, string_adaptor>* XPath<string_type, string_adaptor>::createLiteral(typename impl::types<string_adaptor>::node_iter_t const& i, impl::CompilationContext<string_type, string_adaptor>& context)
|
XPathExpression<string_type, string_adaptor>* XPath<string_type, string_adaptor>::createLiteral(typename impl::types<string_adaptor>::node_iter_t const& i, typename impl::types<string_adaptor>::node_iter_t const& ie, impl::CompilationContext<string_type, string_adaptor>& context)
|
||||||
{
|
{
|
||||||
string_type str = string_adaptor::construct(i->value.begin(), i->value.end());
|
string_type str = string_adaptor::construct(i->value.begin(), i->value.end());
|
||||||
return new StringValue<string_type, string_adaptor>(str);
|
return new StringValue<string_type, string_adaptor>(str);
|
||||||
} // createLiteral
|
} // createLiteral
|
||||||
|
|
||||||
template<class string_type, class string_adaptor>
|
template<class string_type, class string_adaptor>
|
||||||
XPathExpression<string_type, string_adaptor>* XPath<string_type, string_adaptor>::createNumber(typename impl::types<string_adaptor>::node_iter_t const& i, impl::CompilationContext<string_type, string_adaptor>& context)
|
XPathExpression<string_type, string_adaptor>* XPath<string_type, string_adaptor>::createNumber(typename impl::types<string_adaptor>::node_iter_t const& i, typename impl::types<string_adaptor>::node_iter_t const& ie, impl::CompilationContext<string_type, string_adaptor>& context)
|
||||||
{
|
{
|
||||||
string_type str = string_adaptor::construct(i->value.begin(), i->value.end());
|
string_type str = string_adaptor::construct(i->value.begin(), i->value.end());
|
||||||
return new NumericValue<string_type, string_adaptor>(boost::lexical_cast<double>(str));
|
return new NumericValue<string_type, string_adaptor>(boost::lexical_cast<double>(str));
|
||||||
} // createNumber
|
} // createNumber
|
||||||
|
|
||||||
template<class string_type, class string_adaptor>
|
template<class string_type, class string_adaptor>
|
||||||
XPathExpression<string_type, string_adaptor>* XPath<string_type, string_adaptor>::createVariable(typename impl::types<string_adaptor>::node_iter_t const& i, impl::CompilationContext<string_type, string_adaptor>& context)
|
XPathExpression<string_type, string_adaptor>* XPath<string_type, string_adaptor>::createVariable(typename impl::types<string_adaptor>::node_iter_t const& i, typename impl::types<string_adaptor>::node_iter_t const& ie, impl::CompilationContext<string_type, string_adaptor>& context)
|
||||||
{
|
{
|
||||||
typename impl::types<string_adaptor>::node_iter_t n = i->children.begin();
|
typename impl::types<string_adaptor>::node_iter_t n = i->children.begin();
|
||||||
++n; // skip $
|
++n; // skip $
|
||||||
|
@ -677,22 +685,22 @@ XPathExpression<string_type, string_adaptor>* XPath<string_type, string_adaptor>
|
||||||
} // createVariable
|
} // createVariable
|
||||||
|
|
||||||
template<class string_type, class string_adaptor>
|
template<class string_type, class string_adaptor>
|
||||||
XPathExpression<string_type, string_adaptor>* XPath<string_type, string_adaptor>::createSingleStepAbsoluteLocationPath(typename impl::types<string_adaptor>::node_iter_t const& i, impl::CompilationContext<string_type, string_adaptor>& context)
|
XPathExpression<string_type, string_adaptor>* XPath<string_type, string_adaptor>::createSingleStepAbsoluteLocationPath(typename impl::types<string_adaptor>::node_iter_t const& i, typename impl::types<string_adaptor>::node_iter_t const& ie, impl::CompilationContext<string_type, string_adaptor>& context)
|
||||||
{
|
{
|
||||||
typename impl::types<string_adaptor>::node_iter_t n = i;
|
typename impl::types<string_adaptor>::node_iter_t n = i;
|
||||||
return new impl::AbsoluteLocationPath<string_type, string_adaptor>(impl::StepFactory<string_type, string_adaptor>::createStep(n, context));
|
return new impl::AbsoluteLocationPath<string_type, string_adaptor>(impl::StepFactory<string_type, string_adaptor>::createSingleStep(n, ie, context));
|
||||||
} // createSingleStepAbsoluteLocationPath
|
} // createSingleStepAbsoluteLocationPath
|
||||||
|
|
||||||
template<class string_type, class string_adaptor>
|
template<class string_type, class string_adaptor>
|
||||||
XPathExpression<string_type, string_adaptor>* XPath<string_type, string_adaptor>::createUnaryExpression(typename impl::types<string_adaptor>::node_iter_t const& i, impl::CompilationContext<string_type, string_adaptor>& context)
|
XPathExpression<string_type, string_adaptor>* XPath<string_type, string_adaptor>::createUnaryExpression(typename impl::types<string_adaptor>::node_iter_t const& i, typename impl::types<string_adaptor>::node_iter_t const& ie, impl::CompilationContext<string_type, string_adaptor>& context)
|
||||||
{
|
{
|
||||||
return XPath<string_type, string_adaptor>::compile_expression(i->children.begin(), context);
|
return XPath<string_type, string_adaptor>::compile_expression(i->children.begin(), i->children.end(), context);
|
||||||
} // createUnaryExpression
|
} // createUnaryExpression
|
||||||
|
|
||||||
template<class string_type, class string_adaptor>
|
template<class string_type, class string_adaptor>
|
||||||
XPathExpression<string_type, string_adaptor>* XPath<string_type, string_adaptor>::createUnaryNegativeExpr(typename impl::types<string_adaptor>::node_iter_t const& i, impl::CompilationContext<string_type, string_adaptor>& context)
|
XPathExpression<string_type, string_adaptor>* XPath<string_type, string_adaptor>::createUnaryNegativeExpr(typename impl::types<string_adaptor>::node_iter_t const& i, typename impl::types<string_adaptor>::node_iter_t const& ie, impl::CompilationContext<string_type, string_adaptor>& context)
|
||||||
{
|
{
|
||||||
return new impl::UnaryNegative<string_type, string_adaptor>(XPath<string_type, string_adaptor>::compile_expression(i+1, context));
|
return new impl::UnaryNegative<string_type, string_adaptor>(XPath<string_type, string_adaptor>::compile_expression(i+1, ie, context));
|
||||||
} // createUnaryNegativeExpr
|
} // createUnaryNegativeExpr
|
||||||
|
|
||||||
template<class string_type, class string_adaptor>
|
template<class string_type, class string_adaptor>
|
||||||
|
@ -737,48 +745,49 @@ impl::StepList<string_type, string_adaptor> XPath<string_type, string_adaptor>::
|
||||||
} // createStepList
|
} // createStepList
|
||||||
|
|
||||||
template<class string_type, class string_adaptor>
|
template<class string_type, class string_adaptor>
|
||||||
XPathExpression<string_type, string_adaptor>* XPath<string_type, string_adaptor>::createDocMatch(typename impl::types<string_adaptor>::node_iter_t const& i, impl::CompilationContext<string_type, string_adaptor>& context)
|
XPathExpression<string_type, string_adaptor>* XPath<string_type, string_adaptor>::createDocMatch(typename impl::types<string_adaptor>::node_iter_t const& i, typename impl::types<string_adaptor>::node_iter_t const& ie, impl::CompilationContext<string_type, string_adaptor>& context)
|
||||||
{
|
{
|
||||||
typename impl::types<string_adaptor>::node_iter_t n = i;
|
typename impl::types<string_adaptor>::node_iter_t n = i;
|
||||||
return new impl::MatchExpressionWrapper<string_type, string_adaptor>(new impl::RelativeLocationPath<string_type, string_adaptor>(impl::StepFactory<string_type, string_adaptor>::createStep(n, context)), defaultPriority(i));
|
return new impl::MatchExpressionWrapper<string_type, string_adaptor>(new impl::RelativeLocationPath<string_type, string_adaptor>(impl::StepFactory<string_type, string_adaptor>::createSingleStep(n, ie, context)), defaultPriority(i, ie));
|
||||||
} // createDocMatch
|
} // createDocMatch
|
||||||
|
|
||||||
template<class string_type, class string_adaptor>
|
template<class string_type, class string_adaptor>
|
||||||
XPathExpression<string_type, string_adaptor>* XPath<string_type, string_adaptor>::createSingleMatchStep(typename impl::types<string_adaptor>::node_iter_t const& i, impl::CompilationContext<string_type, string_adaptor>& context)
|
XPathExpression<string_type, string_adaptor>* XPath<string_type, string_adaptor>::createSingleMatchStep(typename impl::types<string_adaptor>::node_iter_t const& i, typename impl::types<string_adaptor>::node_iter_t const& ie, impl::CompilationContext<string_type, string_adaptor>& context)
|
||||||
{
|
{
|
||||||
typename impl::types<string_adaptor>::node_iter_t n = i;
|
typename impl::types<string_adaptor>::node_iter_t n = i;
|
||||||
|
|
||||||
impl::StepList<string_type, string_adaptor> steps;
|
impl::StepList<string_type, string_adaptor> steps;
|
||||||
steps.push_back(new impl::TestStepExpression<string_type, string_adaptor>(SELF, new impl::NotAttributeNodeTest<string_type>()));
|
steps.push_back(new impl::TestStepExpression<string_type, string_adaptor>(SELF, new impl::NotAttributeNodeTest<string_type>()));
|
||||||
steps.push_back(impl::StepFactory<string_type, string_adaptor>::createStep(n, context, SELF));
|
steps.push_back(impl::StepFactory<string_type, string_adaptor>::createSingleStep(n, ie, context, SELF));
|
||||||
return new impl::MatchExpressionWrapper<string_type, string_adaptor>(new impl::RelativeLocationPath<string_type, string_adaptor>(steps), defaultPriority(i));
|
return new impl::MatchExpressionWrapper<string_type, string_adaptor>(new impl::RelativeLocationPath<string_type, string_adaptor>(steps), defaultPriority(i, ie));
|
||||||
} // createSingleMatchStep
|
} // createSingleMatchStep
|
||||||
|
|
||||||
template<class string_type, class string_adaptor>
|
template<class string_type, class string_adaptor>
|
||||||
XPathExpression<string_type, string_adaptor>* XPath<string_type, string_adaptor>::createRelativePathPattern(typename impl::types<string_adaptor>::node_iter_t const& i, impl::CompilationContext<string_type, string_adaptor>& context)
|
XPathExpression<string_type, string_adaptor>* XPath<string_type, string_adaptor>::createRelativePathPattern(typename impl::types<string_adaptor>::node_iter_t const& i, typename impl::types<string_adaptor>::node_iter_t const& ie, impl::CompilationContext<string_type, string_adaptor>& context)
|
||||||
{
|
{
|
||||||
return new impl::MatchExpressionWrapper<string_type, string_adaptor>(new impl::RelativeLocationPath<string_type, string_adaptor>(createPatternList(i->children.begin(), i->children.end(), context)), defaultPriority(i));
|
return new impl::MatchExpressionWrapper<string_type, string_adaptor>(new impl::RelativeLocationPath<string_type, string_adaptor>(createPatternList(i->children.begin(), i->children.end(), context)), defaultPriority(i, ie));
|
||||||
} // createRelativePathPattern
|
} // createRelativePathPattern
|
||||||
|
|
||||||
template<class string_type, class string_adaptor>
|
template<class string_type, class string_adaptor>
|
||||||
XPathExpression<string_type, string_adaptor>* XPath<string_type, string_adaptor>::createAlternatePattern(typename impl::types<string_adaptor>::node_iter_t const& i, impl::CompilationContext<string_type, string_adaptor>& context)
|
XPathExpression<string_type, string_adaptor>* XPath<string_type, string_adaptor>::createAlternatePattern(typename impl::types<string_adaptor>::node_iter_t const& i, typename impl::types<string_adaptor>::node_iter_t const& ie, impl::CompilationContext<string_type, string_adaptor>& context)
|
||||||
{
|
{
|
||||||
// child sequence is test union_op test ...
|
// child sequence is test union_op test ...
|
||||||
typename impl::types<string_adaptor>::node_iter_t n = i->children.begin(), e = i->children.end();
|
typename impl::types<string_adaptor>::node_iter_t n = i->children.begin(), e = i->children.end();
|
||||||
|
|
||||||
impl::MatchExpressionWrapper<string_type, string_adaptor>* matches =
|
impl::MatchExpressionWrapper<string_type, string_adaptor>* matches =
|
||||||
new impl::MatchExpressionWrapper<string_type, string_adaptor>(compile_match(n++, context));
|
new impl::MatchExpressionWrapper<string_type, string_adaptor>(compile_match(n++, e, context));
|
||||||
while(n != e)
|
while(n != e)
|
||||||
{
|
{
|
||||||
++n; // skip |
|
++n; // skip |
|
||||||
matches->add_matches(compile_match(n++, context));
|
matches->add_matches(compile_match(n++, e, context));
|
||||||
} // while
|
} // while
|
||||||
|
|
||||||
return matches;
|
return matches;
|
||||||
} // createAlternatePattern
|
} // createAlternatePattern
|
||||||
|
|
||||||
template<class string_type, class string_adaptor>
|
template<class string_type, class string_adaptor>
|
||||||
double XPath<string_type, string_adaptor>::defaultPriority(typename impl::types<string_adaptor>::node_iter_t const& node)
|
double XPath<string_type, string_adaptor>::defaultPriority(typename impl::types<string_adaptor>::node_iter_t const& node,
|
||||||
|
typename impl::types<string_adaptor>::node_iter_t const& end)
|
||||||
{
|
{
|
||||||
typename impl::types<string_adaptor>::node_iter_t i = node;
|
typename impl::types<string_adaptor>::node_iter_t i = node;
|
||||||
impl::skipWhitespace<string_adaptor>(i);
|
impl::skipWhitespace<string_adaptor>(i);
|
||||||
|
@ -793,7 +802,10 @@ double XPath<string_type, string_adaptor>::defaultPriority(typename impl::types<
|
||||||
case impl::QName_id:
|
case impl::QName_id:
|
||||||
return 0;
|
return 0;
|
||||||
case impl::NCName_id:
|
case impl::NCName_id:
|
||||||
impl::skipWhitespace<string_adaptor>(++i);
|
++i;
|
||||||
|
if(i == end)
|
||||||
|
return 0;
|
||||||
|
impl::skipWhitespace<string_adaptor>(i);
|
||||||
if(impl::getNodeId<string_adaptor>(i) == impl::Predicate_id)
|
if(impl::getNodeId<string_adaptor>(i) == impl::Predicate_id)
|
||||||
return 0.5;
|
return 0.5;
|
||||||
if(impl::getNodeId<string_adaptor>(i) == impl::AnyName_id)
|
if(impl::getNodeId<string_adaptor>(i) == impl::AnyName_id)
|
||||||
|
@ -813,7 +825,10 @@ double XPath<string_type, string_adaptor>::defaultPriority(typename impl::types<
|
||||||
case impl::Text_id:
|
case impl::Text_id:
|
||||||
case impl::Comment_id:
|
case impl::Comment_id:
|
||||||
case impl::ProcessingInstruction_id:
|
case impl::ProcessingInstruction_id:
|
||||||
impl::skipWhitespace<string_adaptor>(++i);
|
++i;
|
||||||
|
if(i == end)
|
||||||
|
return -0.5;
|
||||||
|
impl::skipWhitespace<string_adaptor>(i);
|
||||||
if(impl::getNodeId<string_adaptor>(i) == impl::Predicate_id)
|
if(impl::getNodeId<string_adaptor>(i) == impl::Predicate_id)
|
||||||
return 0.5;
|
return 0.5;
|
||||||
return -0.5;
|
return -0.5;
|
||||||
|
@ -824,14 +839,14 @@ double XPath<string_type, string_adaptor>::defaultPriority(typename impl::types<
|
||||||
case impl::RelativePathPattern_id:
|
case impl::RelativePathPattern_id:
|
||||||
// case impl::Pattern_id:
|
// case impl::Pattern_id:
|
||||||
if(child_count <= 2)
|
if(child_count <= 2)
|
||||||
return defaultPriority(i->children.begin());
|
return defaultPriority(i->children.begin(), i->children.end());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case impl::Child_id:
|
case impl::Child_id:
|
||||||
case impl::Attribute_id:
|
case impl::Attribute_id:
|
||||||
case impl::AbbreviatedAxisSpecifier_id:
|
case impl::AbbreviatedAxisSpecifier_id:
|
||||||
if(child_count == 0)
|
if(child_count == 0)
|
||||||
return defaultPriority(i+1);
|
return defaultPriority(i+1, end);
|
||||||
break;
|
break;
|
||||||
} // switch
|
} // switch
|
||||||
|
|
||||||
|
@ -873,7 +888,7 @@ void createStepsFromPattern(impl::StepList<string_type, string_adaptor>& steps,
|
||||||
switch(impl::getNodeId<string_adaptor>(c))
|
switch(impl::getNodeId<string_adaptor>(c))
|
||||||
{
|
{
|
||||||
case impl::Slash_id:
|
case impl::Slash_id:
|
||||||
steps.push_front(impl::StepFactory<string_type, string_adaptor>::createStep(c, context, PARENT));
|
steps.push_front(impl::StepFactory<string_type, string_adaptor>::createStep(c, to, context, PARENT));
|
||||||
case impl::SlashSlash_id:
|
case impl::SlashSlash_id:
|
||||||
++c;
|
++c;
|
||||||
break;
|
break;
|
||||||
|
@ -932,7 +947,7 @@ impl::StepList<string_type, string_adaptor> XPath<string_type, string_adaptor>::
|
||||||
switch(impl::getNodeId<string_adaptor>(c))
|
switch(impl::getNodeId<string_adaptor>(c))
|
||||||
{
|
{
|
||||||
case impl::Slash_id:
|
case impl::Slash_id:
|
||||||
steps.push_front(impl::StepFactory<string_type, string_adaptor>::createStep(c, context, PARENT));
|
steps.push_front(impl::StepFactory<string_type, string_adaptor>::createStep(c, to, context, PARENT));
|
||||||
case impl::SlashSlash_id:
|
case impl::SlashSlash_id:
|
||||||
++c;
|
++c;
|
||||||
break;
|
break;
|
||||||
|
@ -945,12 +960,12 @@ impl::StepList<string_type, string_adaptor> XPath<string_type, string_adaptor>::
|
||||||
|
|
||||||
|
|
||||||
template<class string_type, class string_adaptor>
|
template<class string_type, class string_adaptor>
|
||||||
XPathExpression<string_type, string_adaptor>* XPath<string_type, string_adaptor>::createAttributeValue(typename impl::types<string_adaptor>::node_iter_t const& i, impl::CompilationContext<string_type, string_adaptor>& context)
|
XPathExpression<string_type, string_adaptor>* XPath<string_type, string_adaptor>::createAttributeValue(typename impl::types<string_adaptor>::node_iter_t const& i, typename impl::types<string_adaptor>::node_iter_t const& ie, impl::CompilationContext<string_type, string_adaptor>& context)
|
||||||
{
|
{
|
||||||
std::vector<XPathExpressionPtr<string_type, string_adaptor> > args;
|
std::vector<XPathExpressionPtr<string_type, string_adaptor> > args;
|
||||||
for(typename impl::types<string_adaptor>::node_iter_t a = i->children.begin(), e = i->children.end(); a != e; ++a)
|
for(typename impl::types<string_adaptor>::node_iter_t a = i->children.begin(), e = i->children.end(); a != e; ++a)
|
||||||
{
|
{
|
||||||
XPathExpressionPtr<string_type, string_adaptor> arg(XPath<string_type, string_adaptor>::compile_attribute_value(a, context));
|
XPathExpressionPtr<string_type, string_adaptor> arg(XPath<string_type, string_adaptor>::compile_attribute_value(a, e, context));
|
||||||
args.push_back(arg);
|
args.push_back(arg);
|
||||||
} // while ...
|
} // while ...
|
||||||
// maybe trailing whitespace ...
|
// maybe trailing whitespace ...
|
||||||
|
@ -962,19 +977,19 @@ XPathExpression<string_type, string_adaptor>* XPath<string_type, string_adaptor>
|
||||||
} // createAttributeValue
|
} // createAttributeValue
|
||||||
|
|
||||||
template<class string_type, class string_adaptor>
|
template<class string_type, class string_adaptor>
|
||||||
XPathExpression<string_type, string_adaptor>* XPath<string_type, string_adaptor>::createEmbeddedExpr(typename impl::types<string_adaptor>::node_iter_t const& i, impl::CompilationContext<string_type, string_adaptor>& context)
|
XPathExpression<string_type, string_adaptor>* XPath<string_type, string_adaptor>::createEmbeddedExpr(typename impl::types<string_adaptor>::node_iter_t const& i, typename impl::types<string_adaptor>::node_iter_t const& ie, impl::CompilationContext<string_type, string_adaptor>& context)
|
||||||
{
|
{
|
||||||
return compile_expression(i->children.begin() + 1, context);
|
return compile_expression(i->children.begin() + 1, i->children.end(), context);
|
||||||
} // createEmbeddedExpr
|
} // createEmbeddedExpr
|
||||||
|
|
||||||
template<class string_type, class string_adaptor>
|
template<class string_type, class string_adaptor>
|
||||||
XPathExpression<string_type, string_adaptor>* XPath<string_type, string_adaptor>::createDoubleLeftCurly(typename impl::types<string_adaptor>::node_iter_t const& i, impl::CompilationContext<string_type, string_adaptor>& context)
|
XPathExpression<string_type, string_adaptor>* XPath<string_type, string_adaptor>::createDoubleLeftCurly(typename impl::types<string_adaptor>::node_iter_t const& i, typename impl::types<string_adaptor>::node_iter_t const& ie, impl::CompilationContext<string_type, string_adaptor>& context)
|
||||||
{
|
{
|
||||||
return new StringValue<string_type, string_adaptor>("{");
|
return new StringValue<string_type, string_adaptor>("{");
|
||||||
} // createDoubleLeftCurly
|
} // createDoubleLeftCurly
|
||||||
|
|
||||||
template<class string_type, class string_adaptor>
|
template<class string_type, class string_adaptor>
|
||||||
XPathExpression<string_type, string_adaptor>* XPath<string_type, string_adaptor>::createDoubleRightCurly(typename impl::types<string_adaptor>::node_iter_t const& i, impl::CompilationContext<string_type, string_adaptor>& context)
|
XPathExpression<string_type, string_adaptor>* XPath<string_type, string_adaptor>::createDoubleRightCurly(typename impl::types<string_adaptor>::node_iter_t const& i, typename impl::types<string_adaptor>::node_iter_t const& ie, impl::CompilationContext<string_type, string_adaptor>& context)
|
||||||
{
|
{
|
||||||
return new StringValue<string_type, string_adaptor>("}");
|
return new StringValue<string_type, string_adaptor>("}");
|
||||||
} // createDoubleRightCurly
|
} // createDoubleRightCurly
|
||||||
|
|
|
@ -200,10 +200,10 @@ public:
|
||||||
Axis axis,
|
Axis axis,
|
||||||
bool is_attr = false)
|
bool is_attr = false)
|
||||||
{
|
{
|
||||||
NodeTest<string_type>* test = getTest(node, !is_attr ? axis : ATTRIBUTE, context.namespaceContext());
|
NodeTest<string_type>* test = getTest(node, end, !is_attr ? axis : ATTRIBUTE, context.namespaceContext());
|
||||||
XPathExpression<string_type, string_adaptor>* thing = 0;
|
XPathExpression<string_type, string_adaptor>* thing = 0;
|
||||||
if(!test)
|
if(!test)
|
||||||
thing = XPath<string_type>::compile_expression(node++, context);
|
thing = XPath<string_type>::compile_expression(node++, end, context);
|
||||||
|
|
||||||
std::vector<XPathExpression<string_type, string_adaptor>*> preds =
|
std::vector<XPathExpression<string_type, string_adaptor>*> preds =
|
||||||
createPredicates(node, end, context);
|
createPredicates(node, end, context);
|
||||||
|
@ -217,28 +217,32 @@ public:
|
||||||
CompilationContext<string_type, string_adaptor>& context)
|
CompilationContext<string_type, string_adaptor>& context)
|
||||||
{
|
{
|
||||||
typename types<string_adaptor>::node_iter_t c = node->children.begin();
|
typename types<string_adaptor>::node_iter_t c = node->children.begin();
|
||||||
XPathExpression<string_type, string_adaptor>* step = XPath<string_type>::compile_expression(c, context);
|
typename types<string_adaptor>::node_iter_t const ce = node->children.end();
|
||||||
|
XPathExpression<string_type, string_adaptor>* step = XPath<string_type>::compile_expression(c, ce, context);
|
||||||
++c;
|
++c;
|
||||||
std::vector<XPathExpression<string_type, string_adaptor>*> preds = createPredicates(c, node->children.end(), context);
|
std::vector<XPathExpression<string_type, string_adaptor>*> preds = createPredicates(c, ce, context);
|
||||||
return new ExprStepExpression<string_type, string_adaptor>(step, preds);
|
return new ExprStepExpression<string_type, string_adaptor>(step, preds);
|
||||||
} // createFilter
|
} // createFilter
|
||||||
|
|
||||||
static StepExpression<string_type, string_adaptor>* createStep(typename types<string_adaptor>::node_iter_t& node,
|
static StepExpression<string_type, string_adaptor>* createSingleStep(typename types<string_adaptor>::node_iter_t& node,
|
||||||
CompilationContext<string_type, string_adaptor>& context)
|
typename types<string_adaptor>::node_iter_t const& end,
|
||||||
|
CompilationContext<string_type, string_adaptor>& context)
|
||||||
{
|
{
|
||||||
Axis axis = getAxis(node);
|
Axis axis = getAxis(node);
|
||||||
NodeTest<string_type>* test = getTest(node, axis, context.namespaceContext());
|
return createSingleStep(node, end, context, axis);
|
||||||
return new TestStepExpression<string_type, string_adaptor>(axis, test);
|
|
||||||
} // createStep
|
} // createStep
|
||||||
|
|
||||||
static StepExpression<string_type, string_adaptor>* createStep(typename types<string_adaptor>::node_iter_t& node,
|
static StepExpression<string_type, string_adaptor>* createSingleStep(typename types<string_adaptor>::node_iter_t& node,
|
||||||
CompilationContext<string_type, string_adaptor>& context,
|
typename types<string_adaptor>::node_iter_t const& end,
|
||||||
Axis axis)
|
CompilationContext<string_type, string_adaptor>& context,
|
||||||
|
Axis axis)
|
||||||
{
|
{
|
||||||
NodeTest<string_type>* test = getTest(node, axis, context.namespaceContext());
|
NodeTest<string_type>* test = getTest(node, end, axis, context.namespaceContext());
|
||||||
return new TestStepExpression<string_type, string_adaptor>(axis, test);
|
return new TestStepExpression<string_type, string_adaptor>(axis, test);
|
||||||
|
return 0;
|
||||||
} // createStep
|
} // createStep
|
||||||
|
|
||||||
|
private:
|
||||||
static Axis getAxis(typename types<string_adaptor>::node_iter_t& node)
|
static Axis getAxis(typename types<string_adaptor>::node_iter_t& node)
|
||||||
{
|
{
|
||||||
long id = getNodeId<string_adaptor>(node);
|
long id = getNodeId<string_adaptor>(node);
|
||||||
|
@ -309,7 +313,6 @@ public:
|
||||||
return CHILD;
|
return CHILD;
|
||||||
} // getAxis
|
} // getAxis
|
||||||
|
|
||||||
private:
|
|
||||||
static std::vector<XPathExpression<string_type, string_adaptor>*> createPredicates(typename types<string_adaptor>::node_iter_t& node,
|
static std::vector<XPathExpression<string_type, string_adaptor>*> createPredicates(typename types<string_adaptor>::node_iter_t& node,
|
||||||
typename types<string_adaptor>::node_iter_t const& end,
|
typename types<string_adaptor>::node_iter_t const& end,
|
||||||
CompilationContext<string_type, string_adaptor>& context)
|
CompilationContext<string_type, string_adaptor>& context)
|
||||||
|
@ -321,7 +324,7 @@ private:
|
||||||
typename types<string_adaptor>::node_iter_t c = node->children.begin();
|
typename types<string_adaptor>::node_iter_t c = node->children.begin();
|
||||||
assert(getNodeId<string_adaptor>(c) == impl::LeftSquare_id);
|
assert(getNodeId<string_adaptor>(c) == impl::LeftSquare_id);
|
||||||
++c;
|
++c;
|
||||||
preds.push_back(XPath<string_type>::compile_expression(c, context));
|
preds.push_back(XPath<string_type>::compile_expression(c, node->children.end(), context));
|
||||||
++c;
|
++c;
|
||||||
assert(getNodeId<string_adaptor>(c) == impl::RightSquare_id);
|
assert(getNodeId<string_adaptor>(c) == impl::RightSquare_id);
|
||||||
|
|
||||||
|
@ -331,7 +334,10 @@ private:
|
||||||
return preds;
|
return preds;
|
||||||
} // createPredicates
|
} // createPredicates
|
||||||
|
|
||||||
static NodeTest<string_type>* getTest(typename types<string_adaptor>::node_iter_t& node, Axis axis, const NamespaceContext<string_type, string_adaptor>& namespaceContext)
|
static NodeTest<string_type>* getTest(typename types<string_adaptor>::node_iter_t& node,
|
||||||
|
typename types<string_adaptor>::node_iter_t const& end,
|
||||||
|
Axis axis,
|
||||||
|
const NamespaceContext<string_type, string_adaptor>& namespaceContext)
|
||||||
{
|
{
|
||||||
long id = getNodeId<string_adaptor>(skipWhitespace<string_adaptor>(node));
|
long id = getNodeId<string_adaptor>(skipWhitespace<string_adaptor>(node));
|
||||||
|
|
||||||
|
@ -340,7 +346,7 @@ private:
|
||||||
case impl::NodeTest_id:
|
case impl::NodeTest_id:
|
||||||
{
|
{
|
||||||
typename types<string_adaptor>::node_iter_t c = node->children.begin();
|
typename types<string_adaptor>::node_iter_t c = node->children.begin();
|
||||||
NodeTest<string_type>* t = getTest(c, axis, namespaceContext);
|
NodeTest<string_type>* t = getTest(c, node->children.end(), axis, namespaceContext);
|
||||||
++node;
|
++node;
|
||||||
return t;
|
return t;
|
||||||
} // case NodeTest_id
|
} // case NodeTest_id
|
||||||
|
@ -382,7 +388,7 @@ private:
|
||||||
case impl::ProcessingInstruction_id:
|
case impl::ProcessingInstruction_id:
|
||||||
{
|
{
|
||||||
++node;
|
++node;
|
||||||
if(getNodeId<string_adaptor>(node) != impl::Literal_id) // not sure if this is always safe
|
if((node == end) || (getNodeId<string_adaptor>(node) != impl::Literal_id))
|
||||||
return new ProcessingInstructionNodeTest<string_type, string_adaptor>();
|
return new ProcessingInstructionNodeTest<string_type, string_adaptor>();
|
||||||
|
|
||||||
string_type target = string_adaptor::construct(node->value.begin(), node->value.end());
|
string_type target = string_adaptor::construct(node->value.begin(), node->value.end());
|
||||||
|
|
Loading…
Reference in a new issue