mirror of
https://github.com/jezhiggins/arabica
synced 2025-02-05 20:45:56 +01:00
moved several classes into impl namespace
This commit is contained in:
parent
0670677ce2
commit
58603beff3
13 changed files with 102 additions and 83 deletions
|
@ -10,6 +10,9 @@ template<class string_type, class string_adaptor> class XPath;
|
||||||
template<class string_type, class string_adaptor> class NamespaceContext;
|
template<class string_type, class string_adaptor> class NamespaceContext;
|
||||||
template<class string_type, class string_adaptor> class FunctionResolver;
|
template<class string_type, class string_adaptor> class FunctionResolver;
|
||||||
|
|
||||||
|
namespace impl
|
||||||
|
{
|
||||||
|
|
||||||
template<class string_type, class string_adaptor>
|
template<class string_type, class string_adaptor>
|
||||||
class CompilationContext
|
class CompilationContext
|
||||||
{
|
{
|
||||||
|
@ -37,6 +40,7 @@ private:
|
||||||
bool operator==(const CompilationContext&) const;
|
bool operator==(const CompilationContext&) const;
|
||||||
}; // class CompilationContext
|
}; // class CompilationContext
|
||||||
|
|
||||||
|
} // namespace impl
|
||||||
} // namespace XPath
|
} // namespace XPath
|
||||||
} // namespace Arabica
|
} // namespace Arabica
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ public:
|
||||||
private:
|
private:
|
||||||
size_t position_;
|
size_t position_;
|
||||||
size_t last_;
|
size_t last_;
|
||||||
ResolverHolder<const VariableResolver<string_type, string_adaptor> > variableResolver_;
|
impl::ResolverHolder<const VariableResolver<string_type, string_adaptor> > variableResolver_;
|
||||||
|
|
||||||
ExecutionContext(const ExecutionContext&);
|
ExecutionContext(const ExecutionContext&);
|
||||||
ExecutionContext& operator=(const ExecutionContext&);
|
ExecutionContext& operator=(const ExecutionContext&);
|
||||||
|
|
|
@ -50,6 +50,8 @@ public:
|
||||||
} // XPathExpressionPtr
|
} // XPathExpressionPtr
|
||||||
}; // class XPathExpressionPtr
|
}; // class XPathExpressionPtr
|
||||||
|
|
||||||
|
namespace impl
|
||||||
|
{
|
||||||
template<class string_type, class string_adaptor>
|
template<class string_type, class string_adaptor>
|
||||||
class UnaryExpression
|
class UnaryExpression
|
||||||
{
|
{
|
||||||
|
@ -95,6 +97,7 @@ private:
|
||||||
XPathExpression<string_type, string_adaptor>* rhs_;
|
XPathExpression<string_type, string_adaptor>* rhs_;
|
||||||
}; // class BinaryExpression
|
}; // class BinaryExpression
|
||||||
|
|
||||||
|
} // namespace impl
|
||||||
} // namespace XPath
|
} // namespace XPath
|
||||||
} // namespace Arabica
|
} // namespace Arabica
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,9 @@ namespace XPath
|
||||||
|
|
||||||
const DOM::Node_base::Type NAMESPACE_NODE_TYPE = static_cast<DOM::Node_base::Type>(DOM::Node_base::MAX_TYPE + 27); // 27 is a random choice
|
const DOM::Node_base::Type NAMESPACE_NODE_TYPE = static_cast<DOM::Node_base::Type>(DOM::Node_base::MAX_TYPE + 27); // 27 is a random choice
|
||||||
|
|
||||||
|
namespace impl
|
||||||
|
{
|
||||||
|
|
||||||
template<class stringT, class string_adaptorT = Arabica::default_string_adaptor<stringT> >
|
template<class stringT, class string_adaptorT = Arabica::default_string_adaptor<stringT> >
|
||||||
class NamespaceNodeImpl : public SimpleDOM::ChildlessNodeImpl<stringT, string_adaptorT>
|
class NamespaceNodeImpl : public SimpleDOM::ChildlessNodeImpl<stringT, string_adaptorT>
|
||||||
{
|
{
|
||||||
|
@ -78,6 +81,7 @@ private:
|
||||||
unsigned int ref_;
|
unsigned int ref_;
|
||||||
}; // class NamespaceNodeImpl
|
}; // class NamespaceNodeImpl
|
||||||
|
|
||||||
|
} // namespace impl
|
||||||
} // namespace XPath
|
} // namespace XPath
|
||||||
} // namespace Arabica
|
} // namespace Arabica
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,8 @@ namespace Arabica
|
||||||
{
|
{
|
||||||
namespace XPath
|
namespace XPath
|
||||||
{
|
{
|
||||||
|
namespace impl
|
||||||
|
{
|
||||||
|
|
||||||
template<class string_type>
|
template<class string_type>
|
||||||
class NodeTest
|
class NodeTest
|
||||||
|
@ -153,9 +155,8 @@ public:
|
||||||
} // operator()
|
} // operator()
|
||||||
}; // RootNodeTest
|
}; // RootNodeTest
|
||||||
|
|
||||||
|
} // namespace impl
|
||||||
} // namespace XPath
|
} // namespace XPath
|
||||||
|
|
||||||
|
|
||||||
} // namespace Arabica
|
} // namespace Arabica
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -337,7 +337,6 @@ template<typename RT, typename string_type> struct value_of_node {
|
||||||
template<typename string_type> struct value_of_node<double, string_type> {
|
template<typename string_type> struct value_of_node<double, string_type> {
|
||||||
double operator()(const DOM::Node<string_type>& node) { return nodeNumberValue(node); }
|
double operator()(const DOM::Node<string_type>& node) { return nodeNumberValue(node); }
|
||||||
};
|
};
|
||||||
} // namespace impl
|
|
||||||
|
|
||||||
template<class Op, class string_type>
|
template<class Op, class string_type>
|
||||||
class compareNodeWith
|
class compareNodeWith
|
||||||
|
@ -351,7 +350,7 @@ public:
|
||||||
|
|
||||||
bool operator()(const DOM::Node<string_type>& node)
|
bool operator()(const DOM::Node<string_type>& node)
|
||||||
{
|
{
|
||||||
impl::value_of_node<T, string_type> nv;
|
value_of_node<T, string_type> nv;
|
||||||
return Op()(nv(node), value_);
|
return Op()(nv(node), value_);
|
||||||
} // operator()
|
} // operator()
|
||||||
|
|
||||||
|
@ -538,6 +537,7 @@ bool isGreaterThanEquals(const XPathValuePtr<string_type>& lhs, const XPathValue
|
||||||
return isLessThanEquals(rhs, lhs);
|
return isLessThanEquals(rhs, lhs);
|
||||||
} // isGreaterThanEquals
|
} // isGreaterThanEquals
|
||||||
|
|
||||||
|
} // namespace impl
|
||||||
} // namespace XPath
|
} // namespace XPath
|
||||||
} // namespace Arabica
|
} // namespace Arabica
|
||||||
|
|
||||||
|
|
|
@ -38,12 +38,15 @@ public:
|
||||||
UnsupportedException(const std::string& thing) : std::runtime_error("Sorry, haven't implemented '" + thing + "' yet") { }
|
UnsupportedException(const std::string& thing) : std::runtime_error("Sorry, haven't implemented '" + thing + "' yet") { }
|
||||||
}; // class UnsupportedException
|
}; // class UnsupportedException
|
||||||
|
|
||||||
template<class string_type, class string_adaptor> class CompilationContext;
|
namespace impl
|
||||||
|
{
|
||||||
|
template<class string_type, class string_adaptor> class CompilationContext;
|
||||||
|
|
||||||
template<class string_type, class string_adaptor> class StepExpression;
|
template<class string_type, class string_adaptor> class StepExpression;
|
||||||
|
|
||||||
template<class string_type, class string_adaptor>
|
template<class string_type, class string_adaptor>
|
||||||
class StepList : public std::vector<StepExpression<string_type, string_adaptor>*> { };
|
class StepList : public std::vector<impl::StepExpression<string_type, string_adaptor>*> { };
|
||||||
|
} // namespace impl
|
||||||
|
|
||||||
template<class string_type, class string_adaptor = Arabica::default_string_adaptor<string_type> >
|
template<class string_type, class string_adaptor = Arabica::default_string_adaptor<string_type> >
|
||||||
class XPath
|
class XPath
|
||||||
|
@ -109,7 +112,7 @@ private:
|
||||||
if(!ast.full)
|
if(!ast.full)
|
||||||
throw SyntaxException(xpath);
|
throw SyntaxException(xpath);
|
||||||
|
|
||||||
CompilationContext<string_type, string_adaptor> context(*this, getNamespaceContext(), getFunctionResolver());
|
impl::CompilationContext<string_type, string_adaptor> context(*this, getNamespaceContext(), getFunctionResolver());
|
||||||
return XPathExpressionPtr<string_type, string_adaptor>(compile_expression(ast.trees.begin(), context));
|
return XPathExpressionPtr<string_type, string_adaptor>(compile_expression(ast.trees.begin(), context));
|
||||||
} // try
|
} // try
|
||||||
catch(std::exception& ex)
|
catch(std::exception& ex)
|
||||||
|
@ -137,14 +140,14 @@ private:
|
||||||
xpath_grammar xpathg_;
|
xpath_grammar xpathg_;
|
||||||
xpath_grammar_expr xpathge_;
|
xpath_grammar_expr xpathge_;
|
||||||
|
|
||||||
ResolverHolder<const NamespaceContext<string_type, string_adaptor> > namespaceContext_;
|
impl::ResolverHolder<const NamespaceContext<string_type, string_adaptor> > namespaceContext_;
|
||||||
ResolverHolder<const VariableResolver<string_type, string_adaptor> > variableResolver_;
|
impl::ResolverHolder<const VariableResolver<string_type, string_adaptor> > variableResolver_;
|
||||||
ResolverHolder<const FunctionResolver<string_type, string_adaptor> > functionResolver_;
|
impl::ResolverHolder<const FunctionResolver<string_type, string_adaptor> > functionResolver_;
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
public:
|
public:
|
||||||
static XPathExpression<string_type, string_adaptor>* compile_expression(typename types<string_type>::node_iter_t const& i,
|
static XPathExpression<string_type, string_adaptor>* compile_expression(typename types<string_type>::node_iter_t const& i,
|
||||||
CompilationContext<string_type, string_adaptor>& context)
|
impl::CompilationContext<string_type, string_adaptor>& context)
|
||||||
{
|
{
|
||||||
long id = getNodeId<string_type>(i);
|
long id = getNodeId<string_type>(i);
|
||||||
|
|
||||||
|
@ -158,22 +161,22 @@ public:
|
||||||
} // compile_expression
|
} // compile_expression
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static XPathExpression<string_type, string_adaptor>* createAbsoluteLocationPath(typename types<string_type>::node_iter_t const& i, CompilationContext<string_type, string_adaptor>& context);
|
static XPathExpression<string_type, string_adaptor>* createAbsoluteLocationPath(typename types<string_type>::node_iter_t const& i, impl::CompilationContext<string_type, string_adaptor>& context);
|
||||||
static XPathExpression<string_type, string_adaptor>* createRelativeLocationPath(typename types<string_type>::node_iter_t const& i, CompilationContext<string_type, string_adaptor>& context);
|
static XPathExpression<string_type, string_adaptor>* createRelativeLocationPath(typename types<string_type>::node_iter_t const& i, impl::CompilationContext<string_type, string_adaptor>& context);
|
||||||
static XPathExpression<string_type, string_adaptor>* createSingleStepRelativeLocationPath(typename types<string_type>::node_iter_t const& i, CompilationContext<string_type, string_adaptor>& context);
|
static XPathExpression<string_type, string_adaptor>* createSingleStepRelativeLocationPath(typename types<string_type>::node_iter_t const& i, impl::CompilationContext<string_type, string_adaptor>& context);
|
||||||
static XPathExpression<string_type, string_adaptor>* createExpression(typename types<string_type>::node_iter_t const& i, CompilationContext<string_type, string_adaptor>& context);
|
static XPathExpression<string_type, string_adaptor>* createExpression(typename types<string_type>::node_iter_t const& i, impl::CompilationContext<string_type, string_adaptor>& context);
|
||||||
static XPathExpression<string_type, string_adaptor>* createFunction(typename types<string_type>::node_iter_t const& i, CompilationContext<string_type, string_adaptor>& context);
|
static XPathExpression<string_type, string_adaptor>* createFunction(typename types<string_type>::node_iter_t const& i, impl::CompilationContext<string_type, string_adaptor>& context);
|
||||||
static XPathExpression<string_type, string_adaptor>* createBinaryExpression(typename types<string_type>::node_iter_t const& i, CompilationContext<string_type, string_adaptor>& context);
|
static XPathExpression<string_type, string_adaptor>* createBinaryExpression(typename types<string_type>::node_iter_t const& i, impl::CompilationContext<string_type, string_adaptor>& context);
|
||||||
static XPathExpression<string_type, string_adaptor>* createLiteral(typename types<string_type>::node_iter_t const& i, CompilationContext<string_type, string_adaptor>& context);
|
static XPathExpression<string_type, string_adaptor>* createLiteral(typename types<string_type>::node_iter_t const& i, impl::CompilationContext<string_type, string_adaptor>& context);
|
||||||
static XPathExpression<string_type, string_adaptor>* createNumber(typename types<string_type>::node_iter_t const& i, CompilationContext<string_type, string_adaptor>& context);
|
static XPathExpression<string_type, string_adaptor>* createNumber(typename types<string_type>::node_iter_t const& i, impl::CompilationContext<string_type, string_adaptor>& context);
|
||||||
static XPathExpression<string_type, string_adaptor>* createVariable(typename types<string_type>::node_iter_t const& i, CompilationContext<string_type, string_adaptor>& context);
|
static XPathExpression<string_type, string_adaptor>* createVariable(typename types<string_type>::node_iter_t const& i, impl::CompilationContext<string_type, string_adaptor>& context);
|
||||||
static XPathExpression<string_type, string_adaptor>* createSingleStepAbsoluteLocationPath(typename types<string_type>::node_iter_t const& i, CompilationContext<string_type, string_adaptor>& context);
|
static XPathExpression<string_type, string_adaptor>* createSingleStepAbsoluteLocationPath(typename types<string_type>::node_iter_t const& i, impl::CompilationContext<string_type, string_adaptor>& context);
|
||||||
static XPathExpression<string_type, string_adaptor>* createUnaryExpression(typename types<string_type>::node_iter_t const& i, CompilationContext<string_type, string_adaptor>& context);
|
static XPathExpression<string_type, string_adaptor>* createUnaryExpression(typename types<string_type>::node_iter_t const& i, impl::CompilationContext<string_type, string_adaptor>& context);
|
||||||
static XPathExpression<string_type, string_adaptor>* createUnaryNegativeExpr(typename types<string_type>::node_iter_t const& i, CompilationContext<string_type, string_adaptor>& context);
|
static XPathExpression<string_type, string_adaptor>* createUnaryNegativeExpr(typename types<string_type>::node_iter_t const& i, impl::CompilationContext<string_type, string_adaptor>& context);
|
||||||
|
|
||||||
static StepList<string_type, string_adaptor> createStepList(typename types<string_type>::node_iter_t const& from, typename types<string_type>::node_iter_t const& to, CompilationContext<string_type, string_adaptor>& context);
|
static impl::StepList<string_type, string_adaptor> createStepList(typename types<string_type>::node_iter_t const& from, typename types<string_type>::node_iter_t const& to, impl::CompilationContext<string_type, string_adaptor>& context);
|
||||||
|
|
||||||
typedef XPathExpression<string_type, string_adaptor>* (*compileFn)(typename types<string_type>::node_iter_t const& i, CompilationContext<string_type, string_adaptor>& context);
|
typedef XPathExpression<string_type, string_adaptor>* (*compileFn)(typename types<string_type>::node_iter_t const& i, impl::CompilationContext<string_type, string_adaptor>& context);
|
||||||
static std::map<int, compileFn>& factory()
|
static std::map<int, compileFn>& factory()
|
||||||
{
|
{
|
||||||
static std::map<int, compileFn> f = init_createFunctions();
|
static std::map<int, compileFn> f = init_createFunctions();
|
||||||
|
@ -371,26 +374,26 @@ 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 types<string_type>::node_iter_t const& i, CompilationContext<string_type, string_adaptor>& context)
|
XPathExpression<string_type, string_adaptor>* XPath<string_type, string_adaptor>::createAbsoluteLocationPath(typename types<string_type>::node_iter_t const& i, impl::CompilationContext<string_type, string_adaptor>& context)
|
||||||
{
|
{
|
||||||
return new 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 types<string_type>::node_iter_t const& i, CompilationContext<string_type, string_adaptor>& context)
|
XPathExpression<string_type, string_adaptor>* XPath<string_type, string_adaptor>::createRelativeLocationPath(typename types<string_type>::node_iter_t const& i, impl::CompilationContext<string_type, string_adaptor>& context)
|
||||||
{
|
{
|
||||||
return new 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>::createSingleStepRelativeLocationPath(typename types<string_type>::node_iter_t const& i, CompilationContext<string_type, string_adaptor>& context)
|
XPathExpression<string_type, string_adaptor>* XPath<string_type, string_adaptor>::createSingleStepRelativeLocationPath(typename types<string_type>::node_iter_t const& i, impl::CompilationContext<string_type, string_adaptor>& context)
|
||||||
{
|
{
|
||||||
typename types<string_type>::node_iter_t n = i;
|
typename types<string_type>::node_iter_t n = i;
|
||||||
return new RelativeLocationPath<string_type, string_adaptor>(StepFactory<string_type, string_adaptor>::createStep(n, context));
|
return new impl::RelativeLocationPath<string_type, string_adaptor>(impl::StepFactory<string_type, string_adaptor>::createStep(n, 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 types<string_type>::node_iter_t const& i, CompilationContext<string_type, string_adaptor>& context)
|
XPathExpression<string_type, string_adaptor>* XPath<string_type, string_adaptor>::createExpression(typename types<string_type>::node_iter_t const& i, impl::CompilationContext<string_type, string_adaptor>& context)
|
||||||
{
|
{
|
||||||
typename types<string_type>::node_iter_t c = i->children.begin();
|
typename types<string_type>::node_iter_t c = i->children.begin();
|
||||||
skipWhitespace<string_type>(c);
|
skipWhitespace<string_type>(c);
|
||||||
|
@ -398,7 +401,7 @@ XPathExpression<string_type, string_adaptor>* XPath<string_type, string_adaptor>
|
||||||
} // 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 types<string_type>::node_iter_t const& i, CompilationContext<string_type, string_adaptor>& context)
|
XPathExpression<string_type, string_adaptor>* XPath<string_type, string_adaptor>::createFunction(typename types<string_type>::node_iter_t const& i, impl::CompilationContext<string_type, string_adaptor>& context)
|
||||||
{
|
{
|
||||||
typename types<string_type>::node_iter_t c = i->children.begin();
|
typename types<string_type>::node_iter_t c = i->children.begin();
|
||||||
string_type name(c->value.begin(), c->value.end());
|
string_type name(c->value.begin(), c->value.end());
|
||||||
|
@ -422,7 +425,7 @@ 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 types<string_type>::node_iter_t const& i, CompilationContext<string_type, string_adaptor>& context)
|
XPathExpression<string_type, string_adaptor>* XPath<string_type, string_adaptor>::createBinaryExpression(typename types<string_type>::node_iter_t const& i, impl::CompilationContext<string_type, string_adaptor>& context)
|
||||||
{
|
{
|
||||||
typename types<string_type>::node_iter_t c = i->children.begin();
|
typename types<string_type>::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, context);
|
||||||
|
@ -488,49 +491,49 @@ 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 types<string_type>::node_iter_t const& i, CompilationContext<string_type, string_adaptor>& context)
|
XPathExpression<string_type, string_adaptor>* XPath<string_type, string_adaptor>::createLiteral(typename types<string_type>::node_iter_t const& i, impl::CompilationContext<string_type, string_adaptor>& context)
|
||||||
{
|
{
|
||||||
string_type str(i->value.begin(), i->value.end());
|
string_type str(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 types<string_type>::node_iter_t const& i, CompilationContext<string_type, string_adaptor>& context)
|
XPathExpression<string_type, string_adaptor>* XPath<string_type, string_adaptor>::createNumber(typename types<string_type>::node_iter_t const& i, impl::CompilationContext<string_type, string_adaptor>& context)
|
||||||
{
|
{
|
||||||
return new NumericValue<string_type, string_adaptor>(boost::lexical_cast<double>(string_type(i->value.begin(), i->value.end())));
|
return new NumericValue<string_type, string_adaptor>(boost::lexical_cast<double>(string_type(i->value.begin(), i->value.end())));
|
||||||
} // 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 types<string_type>::node_iter_t const& i, CompilationContext<string_type, string_adaptor>& context)
|
XPathExpression<string_type, string_adaptor>* XPath<string_type, string_adaptor>::createVariable(typename types<string_type>::node_iter_t const& i, impl::CompilationContext<string_type, string_adaptor>& context)
|
||||||
{
|
{
|
||||||
return new Variable<string_type, string_adaptor>(string_type(i->value.begin()+1, i->value.end())); // skip $
|
return new Variable<string_type, string_adaptor>(string_type(i->value.begin()+1, i->value.end())); // skip $
|
||||||
} // 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 types<string_type>::node_iter_t const& i, CompilationContext<string_type, string_adaptor>& context)
|
XPathExpression<string_type, string_adaptor>* XPath<string_type, string_adaptor>::createSingleStepAbsoluteLocationPath(typename types<string_type>::node_iter_t const& i, impl::CompilationContext<string_type, string_adaptor>& context)
|
||||||
{
|
{
|
||||||
typename types<string_type>::node_iter_t n = i;
|
typename types<string_type>::node_iter_t n = i;
|
||||||
return new AbsoluteLocationPath<string_type, string_adaptor>(StepFactory<string_type, string_adaptor>::createStep(n, context));
|
return new impl::AbsoluteLocationPath<string_type, string_adaptor>(impl::StepFactory<string_type, string_adaptor>::createStep(n, 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 types<string_type>::node_iter_t const& i, CompilationContext<string_type, string_adaptor>& context)
|
XPathExpression<string_type, string_adaptor>* XPath<string_type, string_adaptor>::createUnaryExpression(typename types<string_type>::node_iter_t const& i, 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(), 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 types<string_type>::node_iter_t const& i, CompilationContext<string_type, string_adaptor>& context)
|
XPathExpression<string_type, string_adaptor>* XPath<string_type, string_adaptor>::createUnaryNegativeExpr(typename types<string_type>::node_iter_t const& i, 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, context));
|
||||||
} // createUnaryNegativeExpr
|
} // createUnaryNegativeExpr
|
||||||
|
|
||||||
template<class string_type, class string_adaptor>
|
template<class string_type, class string_adaptor>
|
||||||
StepList<string_type, string_adaptor> XPath<string_type, string_adaptor>::createStepList(typename types<string_type>::node_iter_t const& from,
|
impl::StepList<string_type, string_adaptor> XPath<string_type, string_adaptor>::createStepList(typename types<string_type>::node_iter_t const& from,
|
||||||
typename types<string_type>::node_iter_t const& to,
|
typename types<string_type>::node_iter_t const& to,
|
||||||
CompilationContext<string_type, string_adaptor>& context)
|
impl::CompilationContext<string_type, string_adaptor>& context)
|
||||||
{
|
{
|
||||||
StepList<string_type, string_adaptor> steps;
|
impl::StepList<string_type, string_adaptor> steps;
|
||||||
|
|
||||||
typename types<string_type>::node_iter_t c = from;
|
typename types<string_type>::node_iter_t c = from;
|
||||||
typename types<string_type>::node_iter_t end = to;
|
typename types<string_type>::node_iter_t end = to;
|
||||||
|
@ -550,19 +553,18 @@ StepList<string_type, string_adaptor> XPath<string_type, string_adaptor>::create
|
||||||
case impl::Step_id:
|
case impl::Step_id:
|
||||||
{
|
{
|
||||||
typename types<string_type>::node_iter_t step = c->children.begin();
|
typename types<string_type>::node_iter_t step = c->children.begin();
|
||||||
steps.push_back(StepFactory<string_type, string_adaptor>::createStep(step, c->children.end(), context));
|
steps.push_back(impl::StepFactory<string_type, string_adaptor>::createStep(step, c->children.end(), context));
|
||||||
++c;
|
++c;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
steps.push_back(StepFactory<string_type, string_adaptor>::createStep(c, end, context));
|
steps.push_back(impl::StepFactory<string_type, string_adaptor>::createStep(c, end, context));
|
||||||
} // switch(getNodeId(c))
|
} // switch(getNodeId(c))
|
||||||
|
|
||||||
return steps;
|
return steps;
|
||||||
} // createStepList
|
} // createStepList
|
||||||
|
|
||||||
} // namespace XPath
|
} // namespace XPath
|
||||||
|
|
||||||
} // namespace Arabica
|
} // namespace Arabica
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -7,6 +7,8 @@ namespace Arabica
|
||||||
{
|
{
|
||||||
namespace XPath
|
namespace XPath
|
||||||
{
|
{
|
||||||
|
namespace impl
|
||||||
|
{
|
||||||
|
|
||||||
template<typename ResolverT>
|
template<typename ResolverT>
|
||||||
class ResolverHolder
|
class ResolverHolder
|
||||||
|
@ -63,6 +65,7 @@ private:
|
||||||
bool operator==(const ResolverHolder&);
|
bool operator==(const ResolverHolder&);
|
||||||
}; // ResolverHolder
|
}; // ResolverHolder
|
||||||
|
|
||||||
|
} // namespace impl
|
||||||
} // namespace XPath
|
} // namespace XPath
|
||||||
} // namespace Arabica
|
} // namespace Arabica
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,8 @@ namespace Arabica
|
||||||
{
|
{
|
||||||
namespace XPath
|
namespace XPath
|
||||||
{
|
{
|
||||||
|
namespace impl
|
||||||
|
{
|
||||||
|
|
||||||
template<class string_type, class string_adaptor>
|
template<class string_type, class string_adaptor>
|
||||||
class StepExpression : public XPathExpression<string_type, string_adaptor>
|
class StepExpression : public XPathExpression<string_type, string_adaptor>
|
||||||
|
@ -423,7 +425,7 @@ public:
|
||||||
} // evaluate
|
} // evaluate
|
||||||
}; // class AbsoluteLocationPath
|
}; // class AbsoluteLocationPath
|
||||||
|
|
||||||
|
} // impl
|
||||||
} // XPath
|
} // XPath
|
||||||
} // Arabica
|
} // Arabica
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -673,7 +673,7 @@ public:
|
||||||
|
|
||||||
void namespaceNodeTest1()
|
void namespaceNodeTest1()
|
||||||
{
|
{
|
||||||
DOM::Node<std::string> node(new NamespaceNodeImpl<std::string>("p", "test-uri"));
|
DOM::Node<std::string> node(new impl::NamespaceNodeImpl<std::string>("p", "test-uri"));
|
||||||
DOM::Node<std::string> node2;
|
DOM::Node<std::string> node2;
|
||||||
|
|
||||||
node2 = node;
|
node2 = node;
|
||||||
|
@ -683,7 +683,7 @@ public:
|
||||||
{
|
{
|
||||||
DOM::Node<std::string> node;
|
DOM::Node<std::string> node;
|
||||||
{
|
{
|
||||||
DOM::Node<std::string> node2(new NamespaceNodeImpl<std::string>("p", "test-uri"));
|
DOM::Node<std::string> node2(new impl::NamespaceNodeImpl<std::string>("p", "test-uri"));
|
||||||
node = node2;
|
node = node2;
|
||||||
}
|
}
|
||||||
} // namespaceNodeTest2
|
} // namespaceNodeTest2
|
||||||
|
@ -692,7 +692,7 @@ public:
|
||||||
{
|
{
|
||||||
DOM::Node<std::string> node;
|
DOM::Node<std::string> node;
|
||||||
{
|
{
|
||||||
DOM::Node<std::string> node2(new NamespaceNodeImpl<std::string>("p", "test-uri"));
|
DOM::Node<std::string> node2(new impl::NamespaceNodeImpl<std::string>("p", "test-uri"));
|
||||||
node = node2;
|
node = node2;
|
||||||
}
|
}
|
||||||
node = 0;
|
node = 0;
|
||||||
|
@ -700,7 +700,7 @@ public:
|
||||||
|
|
||||||
void namespaceNodeTest4()
|
void namespaceNodeTest4()
|
||||||
{
|
{
|
||||||
DOM::Node<std::string> node(new NamespaceNodeImpl<std::string>("p", "test-uri"));
|
DOM::Node<std::string> node(new impl::NamespaceNodeImpl<std::string>("p", "test-uri"));
|
||||||
assertValuesEqual("p", node.getLocalName());
|
assertValuesEqual("p", node.getLocalName());
|
||||||
assertValuesEqual("test-uri", node.getNodeValue());
|
assertValuesEqual("test-uri", node.getNodeValue());
|
||||||
assertValuesEqual("", node.getNamespaceURI());
|
assertValuesEqual("", node.getNamespaceURI());
|
||||||
|
|
|
@ -68,7 +68,7 @@ public:
|
||||||
|
|
||||||
void test1()
|
void test1()
|
||||||
{
|
{
|
||||||
AnyNodeTest<std::string> test;
|
impl::AnyNodeTest<std::string> test;
|
||||||
|
|
||||||
assertTrue(test(element1_));
|
assertTrue(test(element1_));
|
||||||
assertTrue(test(element2_));
|
assertTrue(test(element2_));
|
||||||
|
@ -82,7 +82,7 @@ public:
|
||||||
|
|
||||||
void test2()
|
void test2()
|
||||||
{
|
{
|
||||||
NameNodeTest<std::string> test("child1");
|
impl::NameNodeTest<std::string> test("child1");
|
||||||
|
|
||||||
assertTrue(test(element1_));
|
assertTrue(test(element1_));
|
||||||
assertTrue(!test(element2_));
|
assertTrue(!test(element2_));
|
||||||
|
@ -96,7 +96,7 @@ public:
|
||||||
|
|
||||||
void test3()
|
void test3()
|
||||||
{
|
{
|
||||||
NameNodeTest<std::string> test("one");
|
impl::NameNodeTest<std::string> test("one");
|
||||||
|
|
||||||
assertTrue(!test(element1_));
|
assertTrue(!test(element1_));
|
||||||
assertTrue(!test(element2_));
|
assertTrue(!test(element2_));
|
||||||
|
@ -110,7 +110,7 @@ public:
|
||||||
|
|
||||||
void test4()
|
void test4()
|
||||||
{
|
{
|
||||||
TextNodeTest<std::string> test;
|
impl::TextNodeTest<std::string> test;
|
||||||
|
|
||||||
assertTrue(!test(element1_));
|
assertTrue(!test(element1_));
|
||||||
assertTrue(!test(root_));
|
assertTrue(!test(root_));
|
||||||
|
@ -123,7 +123,7 @@ public:
|
||||||
|
|
||||||
void test5()
|
void test5()
|
||||||
{
|
{
|
||||||
CommentNodeTest<std::string> test;
|
impl::CommentNodeTest<std::string> test;
|
||||||
|
|
||||||
assertTrue(!test(element1_));
|
assertTrue(!test(element1_));
|
||||||
assertTrue(!test(root_));
|
assertTrue(!test(root_));
|
||||||
|
@ -136,7 +136,7 @@ public:
|
||||||
|
|
||||||
void test6()
|
void test6()
|
||||||
{
|
{
|
||||||
ProcessingInstructionNodeTest<std::string> test;
|
impl::ProcessingInstructionNodeTest<std::string> test;
|
||||||
|
|
||||||
assertTrue(!test(element1_));
|
assertTrue(!test(element1_));
|
||||||
assertTrue(!test(root_));
|
assertTrue(!test(root_));
|
||||||
|
@ -149,7 +149,7 @@ public:
|
||||||
|
|
||||||
void test7()
|
void test7()
|
||||||
{
|
{
|
||||||
ProcessingInstructionNodeTest<std::string> test("fruity");
|
impl::ProcessingInstructionNodeTest<std::string> test("fruity");
|
||||||
|
|
||||||
assertTrue(!test(element1_));
|
assertTrue(!test(element1_));
|
||||||
assertTrue(!test(root_));
|
assertTrue(!test(root_));
|
||||||
|
@ -162,7 +162,7 @@ public:
|
||||||
|
|
||||||
void test8()
|
void test8()
|
||||||
{
|
{
|
||||||
ProcessingInstructionNodeTest<std::string> test("target");
|
impl::ProcessingInstructionNodeTest<std::string> test("target");
|
||||||
|
|
||||||
assertTrue(!test(element1_));
|
assertTrue(!test(element1_));
|
||||||
assertTrue(!test(root_));
|
assertTrue(!test(root_));
|
||||||
|
@ -175,7 +175,7 @@ public:
|
||||||
|
|
||||||
void test9()
|
void test9()
|
||||||
{
|
{
|
||||||
StarNodeTest<std::string> test;
|
impl::StarNodeTest<std::string> test;
|
||||||
|
|
||||||
AxisEnumerator<std::string, Arabica::default_string_adaptor<std::string> > e(element2_, CHILD);
|
AxisEnumerator<std::string, Arabica::default_string_adaptor<std::string> > e(element2_, CHILD);
|
||||||
assertTrue(!test(*e));
|
assertTrue(!test(*e));
|
||||||
|
@ -189,7 +189,7 @@ public:
|
||||||
|
|
||||||
void test10()
|
void test10()
|
||||||
{
|
{
|
||||||
QNameNodeTest<std::string> test("http://example.com/test", "one");
|
impl::QNameNodeTest<std::string> test("http://example.com/test", "one");
|
||||||
|
|
||||||
assertTrue(!test(element1_));
|
assertTrue(!test(element1_));
|
||||||
assertTrue(!test(element2_));
|
assertTrue(!test(element2_));
|
||||||
|
@ -203,7 +203,7 @@ public:
|
||||||
|
|
||||||
void test11()
|
void test11()
|
||||||
{
|
{
|
||||||
QNameNodeTest<std::string> test("http://example.com/test", "one");
|
impl::QNameNodeTest<std::string> test("http://example.com/test", "one");
|
||||||
|
|
||||||
DOM::Element<std::string> e1_ = document_.createElementNS("http://example.com/test", "ns:one");
|
DOM::Element<std::string> e1_ = document_.createElementNS("http://example.com/test", "ns:one");
|
||||||
DOM::Element<std::string> e2_ = document_.createElementNS("http://example.com/test", "ttt:one");
|
DOM::Element<std::string> e2_ = document_.createElementNS("http://example.com/test", "ttt:one");
|
||||||
|
@ -222,7 +222,7 @@ public:
|
||||||
|
|
||||||
void test12()
|
void test12()
|
||||||
{
|
{
|
||||||
QStarNodeTest<std::string> test("http://example.com/test");
|
impl::QStarNodeTest<std::string> test("http://example.com/test");
|
||||||
|
|
||||||
DOM::Element<std::string> e1_ = document_.createElementNS("http://example.com/test", "ns:one");
|
DOM::Element<std::string> e1_ = document_.createElementNS("http://example.com/test", "ns:one");
|
||||||
DOM::Element<std::string> e2_ = document_.createElementNS("http://example.com/test", "ttt:one");
|
DOM::Element<std::string> e2_ = document_.createElementNS("http://example.com/test", "ttt:one");
|
||||||
|
|
|
@ -55,7 +55,7 @@ public:
|
||||||
|
|
||||||
void test1()
|
void test1()
|
||||||
{
|
{
|
||||||
XPathExpressionPtr<std::string> step(new TestStepExpression<std::string, Arabica::default_string_adaptor<std::string> >(CHILD, new AnyNodeTest<std::string>()));
|
XPathExpressionPtr<std::string> step(new impl::TestStepExpression<std::string, Arabica::default_string_adaptor<std::string> >(CHILD, new impl::AnyNodeTest<std::string>()));
|
||||||
|
|
||||||
XPathValuePtr<std::string> value = step->evaluate(root_);
|
XPathValuePtr<std::string> value = step->evaluate(root_);
|
||||||
const NodeSet<std::string>& set = value->asNodeSet();
|
const NodeSet<std::string>& set = value->asNodeSet();
|
||||||
|
@ -68,7 +68,7 @@ public:
|
||||||
|
|
||||||
void test2()
|
void test2()
|
||||||
{
|
{
|
||||||
XPathExpressionPtr<std::string> step(new TestStepExpression<std::string, Arabica::default_string_adaptor<std::string> >(ATTRIBUTE, new AnyNodeTest<std::string>()));
|
XPathExpressionPtr<std::string> step(new impl::TestStepExpression<std::string, Arabica::default_string_adaptor<std::string> >(ATTRIBUTE, new impl::AnyNodeTest<std::string>()));
|
||||||
|
|
||||||
NodeSet<std::string> set = step->evaluateAsNodeSet(element2_);
|
NodeSet<std::string> set = step->evaluateAsNodeSet(element2_);
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ public:
|
||||||
|
|
||||||
void test3()
|
void test3()
|
||||||
{
|
{
|
||||||
XPathExpressionPtr<std::string> step(new TestStepExpression<std::string, Arabica::default_string_adaptor<std::string> >(CHILD, new NameNodeTest<std::string>("child2")));
|
XPathExpressionPtr<std::string> step(new impl::TestStepExpression<std::string, Arabica::default_string_adaptor<std::string> >(CHILD, new impl::NameNodeTest<std::string>("child2")));
|
||||||
|
|
||||||
XPathValuePtr<std::string> value = step->evaluate(root_);
|
XPathValuePtr<std::string> value = step->evaluate(root_);
|
||||||
const NodeSet<std::string>& set = value->asNodeSet();
|
const NodeSet<std::string>& set = value->asNodeSet();
|
||||||
|
|
|
@ -92,16 +92,16 @@ public:
|
||||||
XPathExpressionPtr<std::string> bf(new BoolValue<std::string, Arabica::default_string_adaptor<std::string> >(false));
|
XPathExpressionPtr<std::string> bf(new BoolValue<std::string, Arabica::default_string_adaptor<std::string> >(false));
|
||||||
XPathExpressionPtr<std::string> sf(new StringValue<std::string, Arabica::default_string_adaptor<std::string> >(""));
|
XPathExpressionPtr<std::string> sf(new StringValue<std::string, Arabica::default_string_adaptor<std::string> >(""));
|
||||||
|
|
||||||
assertTrue(areEqual(bt->evaluate(dummy_), (st->evaluate(dummy_))));
|
assertTrue(impl::areEqual(bt->evaluate(dummy_), (st->evaluate(dummy_))));
|
||||||
assertTrue(areEqual(st->evaluate(dummy_), (bt->evaluate(dummy_))));
|
assertTrue(impl::areEqual(st->evaluate(dummy_), (bt->evaluate(dummy_))));
|
||||||
|
|
||||||
assertTrue(areEqual(sf->evaluate(dummy_), (bf->evaluate(dummy_))));
|
assertTrue(impl::areEqual(sf->evaluate(dummy_), (bf->evaluate(dummy_))));
|
||||||
assertTrue(areEqual(bf->evaluate(dummy_), (sf->evaluate(dummy_))));
|
assertTrue(impl::areEqual(bf->evaluate(dummy_), (sf->evaluate(dummy_))));
|
||||||
|
|
||||||
assertTrue(areEqual(bt->evaluate(dummy_), (bt->evaluate(dummy_))));
|
assertTrue(impl::areEqual(bt->evaluate(dummy_), (bt->evaluate(dummy_))));
|
||||||
assertTrue(areEqual(bf->evaluate(dummy_), (bf->evaluate(dummy_))));
|
assertTrue(impl::areEqual(bf->evaluate(dummy_), (bf->evaluate(dummy_))));
|
||||||
assertTrue(areEqual(st->evaluate(dummy_), (st->evaluate(dummy_))));
|
assertTrue(impl::areEqual(st->evaluate(dummy_), (st->evaluate(dummy_))));
|
||||||
assertTrue(areEqual(sf->evaluate(dummy_), (sf->evaluate(dummy_))));
|
assertTrue(impl::areEqual(sf->evaluate(dummy_), (sf->evaluate(dummy_))));
|
||||||
} // test9
|
} // test9
|
||||||
|
|
||||||
void test10()
|
void test10()
|
||||||
|
@ -111,11 +111,11 @@ public:
|
||||||
XPathExpressionPtr<std::string> bf(new BoolValue<std::string, Arabica::default_string_adaptor<std::string> >(false));
|
XPathExpressionPtr<std::string> bf(new BoolValue<std::string, Arabica::default_string_adaptor<std::string> >(false));
|
||||||
XPathExpressionPtr<std::string> nf(new NumericValue<std::string, Arabica::default_string_adaptor<std::string> >(0.0));
|
XPathExpressionPtr<std::string> nf(new NumericValue<std::string, Arabica::default_string_adaptor<std::string> >(0.0));
|
||||||
|
|
||||||
assertTrue(areEqual(bt->evaluate(dummy_), (nt->evaluate(dummy_))));
|
assertTrue(impl::areEqual(bt->evaluate(dummy_), (nt->evaluate(dummy_))));
|
||||||
assertTrue(areEqual(nt->evaluate(dummy_), (bt->evaluate(dummy_))));
|
assertTrue(impl::areEqual(nt->evaluate(dummy_), (bt->evaluate(dummy_))));
|
||||||
|
|
||||||
assertTrue(areEqual(bf->evaluate(dummy_), (nf->evaluate(dummy_))));
|
assertTrue(impl::areEqual(bf->evaluate(dummy_), (nf->evaluate(dummy_))));
|
||||||
assertTrue(areEqual(nf->evaluate(dummy_), (bf->evaluate(dummy_))));
|
assertTrue(impl::areEqual(nf->evaluate(dummy_), (bf->evaluate(dummy_))));
|
||||||
} // test10
|
} // test10
|
||||||
|
|
||||||
void test11()
|
void test11()
|
||||||
|
@ -123,7 +123,7 @@ public:
|
||||||
XPathExpressionPtr<std::string> nt(new NumericValue<std::string, Arabica::default_string_adaptor<std::string> >(1.0));
|
XPathExpressionPtr<std::string> nt(new NumericValue<std::string, Arabica::default_string_adaptor<std::string> >(1.0));
|
||||||
XPathValuePtr<std::string> ns = nt->evaluate(dummy_);
|
XPathValuePtr<std::string> ns = nt->evaluate(dummy_);
|
||||||
|
|
||||||
assertTrue(areEqual(ns, (nt->evaluate(dummy_))));
|
assertTrue(impl::areEqual(ns, (nt->evaluate(dummy_))));
|
||||||
} // test11
|
} // test11
|
||||||
}; // ValueTest
|
}; // ValueTest
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue