s/XPathExpressionPtr/XPathExpression/g

This commit is contained in:
jez 2007-10-25 20:42:00 +00:00
parent 240c97814c
commit af3ebfde60
17 changed files with 406 additions and 314 deletions

View file

@ -50,27 +50,119 @@ private:
XPathExpression_impl& operator=(const XPathExpression_impl&);
}; // class XPathExpression_impl
template<class string_type, class string_adaptor> class XPathExpressionPtr;
template<class string_type, class string_adaptor = Arabica::default_string_adaptor<string_type> >
class XPathExpressionPtr
class XPathExpression
{
public:
XPathExpressionPtr() : ptr_() { }
explicit XPathExpressionPtr(XPathExpression_impl<string_type, string_adaptor>* xp) : ptr_(xp) { }
XPathExpressionPtr(const XPathExpressionPtr& rhs) : ptr_(rhs.ptr_) { }
XPathExpressionPtr& operator=(const XPathExpressionPtr& rhs)
XPathExpression() : ptr_() { }
explicit XPathExpression(XPathExpression_impl<string_type, string_adaptor>* xp) : ptr_(xp) { }
XPathExpression(const XPathExpression& rhs) : ptr_(rhs.ptr_) { }
XPathExpression& operator=(const XPathExpression& rhs)
{
ptr_ = rhs.ptr_;
return *this;
} // operator=
const XPathExpression_impl<string_type, string_adaptor>* get() const { return ptr_.get(); }
const XPathExpression_impl<string_type, string_adaptor>* operator->() const { return ptr_.get(); }
operator bool() const { return ptr_.get(); }
XPathValue<string_type, string_adaptor> evaluate(const DOM::Node<string_type, string_adaptor>& context) const
{
return ptr_->evaluate(context);
} // evaluate
bool evaluateAsBool(const DOM::Node<string_type, string_adaptor>& context) const
{
return ptr_->evaluateAsBool(context);
} // evaluateAsBool
double evaluateAsNumber(const DOM::Node<string_type, string_adaptor>& context) const
{
return ptr_->evaluateAsNumber(context);
} // evaluateAsNumber
string_type evaluateAsString(const DOM::Node<string_type, string_adaptor>& context) const
{
return ptr_->evaluateAsString(context);
} // evaluateAsString
NodeSet<string_type, string_adaptor> evaluateAsNodeSet(const DOM::Node<string_type, string_adaptor>& context) const
{
return ptr_->evaluate(context).asNodeSet();
} // evaluateAsNodeSet
XPathValue<string_type, string_adaptor> evaluate(const DOM::Node<string_type, string_adaptor>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const
{
return ptr_->evaluate(context, executionContext);
} // evaluate
bool evaluateAsBool(const DOM::Node<string_type, string_adaptor>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const
{
return ptr_->evaluateAsBool(context, executionContext);
} // evaluateAsBool
double evaluateAsNumber(const DOM::Node<string_type, string_adaptor>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const
{
return ptr_->evaluateAsNumber(context, executionContext);
} // evaluateAsNumber
string_type evaluateAsString(const DOM::Node<string_type, string_adaptor>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const
{
return ptr_->evaluateAsString(context, executionContext);
} // evaluateAsString
NodeSet<string_type, string_adaptor> evaluateAsNodeSet(const DOM::Node<string_type, string_adaptor>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const
{
return ptr_->evaluate(context, executionContext).asNodeSet();
} // evaluateAsNodeSet
private:
typedef boost::shared_ptr<const XPathExpression_impl<string_type, string_adaptor> > ExpressionPtr;
ExpressionPtr ptr_;
explicit XPathExpression(ExpressionPtr ptr) : ptr_(ptr) { }
friend class XPathExpressionPtr<string_type, string_adaptor>;
}; // class XPathExpression
template<class string_type, class string_adaptor = Arabica::default_string_adaptor<string_type> >
class XPathExpressionPtr
{
public:
explicit XPathExpressionPtr() : ptr_() { }
explicit XPathExpressionPtr(const XPathExpression_impl<string_type, string_adaptor>* v) : ptr_(v) { }
XPathExpressionPtr(const XPathExpression<string_type, string_adaptor>& rhs) : ptr_(rhs.ptr_) { }
XPathExpressionPtr(const XPathExpressionPtr& rhs) : ptr_(rhs.ptr_) { }
XPathExpressionPtr& operator=(const XPathExpression<string_type, string_adaptor>& rhs)
{
ptr_ = rhs.ptr_;
return *this;
} // operator=
XPathExpressionPtr& operator=(const XPathExpressionPtr& rhs)
{
ptr_ = rhs.ptr_;
return *this;
} // operator=
const XPathExpression_impl<string_type, string_adaptor>* operator->() const { return ptr_.get(); }
operator bool() const { return ptr_.get(); }
operator XPathExpression<string_type, string_adaptor>() const { return XPathExpression<string_type, string_adaptor>(ptr_); }
private:
bool operator==(const XPathExpressionPtr&) const;
typedef boost::shared_ptr<const XPathExpression_impl<string_type, string_adaptor> > ExpressionPtr;
ExpressionPtr ptr_;
}; // class XPathExpressionPtr
namespace impl

View file

@ -18,7 +18,7 @@ template<class string_type, class string_adaptor = Arabica::default_string_adapt
class XPathFunction
{
protected:
XPathFunction(int minArgs, int maxArgs, const std::vector<XPathExpressionPtr<string_type, string_adaptor> >& args) :
XPathFunction(int minArgs, int maxArgs, const std::vector<XPathExpression<string_type, string_adaptor> >& args) :
args_(args)
{
if(((minArgs != -1) && (static_cast<int>(args.size()) < minArgs)) ||
@ -39,39 +39,39 @@ protected:
const DOM::Node<string_type, string_adaptor>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const
{
return args_[index]->evaluate(context, executionContext);
return args_[index].evaluate(context, executionContext);
} // argAsBool
bool argAsBool(size_t index,
const DOM::Node<string_type, string_adaptor>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const
{
return args_[index]->evaluate(context, executionContext).asBool();
return args_[index].evaluate(context, executionContext).asBool();
} // argAsBool
double argAsNumber(size_t index,
const DOM::Node<string_type, string_adaptor>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const
{
return args_[index]->evaluate(context, executionContext).asNumber();
return args_[index].evaluate(context, executionContext).asNumber();
} // argAsNumber
string_type argAsString(size_t index,
const DOM::Node<string_type, string_adaptor>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const
{
return args_[index]->evaluate(context, executionContext).asString();
return args_[index].evaluate(context, executionContext).asString();
} // argAsString
NodeSet<string_type, string_adaptor> argAsNodeSet(size_t index,
const DOM::Node<string_type, string_adaptor>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const
{
return args_[index]->evaluate(context, executionContext).asNodeSet();
return args_[index].evaluate(context, executionContext).asNodeSet();
} // argAsNodeSet
private:
const std::vector<XPathExpressionPtr<string_type, string_adaptor> > args_;
const std::vector<XPathExpression<string_type, string_adaptor> > args_;
}; // class XPathFunction
namespace impl
@ -83,7 +83,7 @@ template<class string_type, class string_adaptor>
class LastFn : public XPathFunction<string_type, string_adaptor>
{
public:
LastFn(const std::vector<XPathExpressionPtr<string_type, string_adaptor> >& args) : XPathFunction<string_type, string_adaptor>(0, 0, args) { }
LastFn(const std::vector<XPathExpression<string_type, string_adaptor> >& args) : XPathFunction<string_type, string_adaptor>(0, 0, args) { }
virtual XPathValue_impl<string_type, string_adaptor>* evaluate(const DOM::Node<string_type, string_adaptor>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const
@ -97,7 +97,7 @@ template<class string_type, class string_adaptor>
class PositionFn : public XPathFunction<string_type, string_adaptor>
{
public:
PositionFn(const std::vector<XPathExpressionPtr<string_type, string_adaptor> >& args) : XPathFunction<string_type, string_adaptor>(0, 0, args) { }
PositionFn(const std::vector<XPathExpression<string_type, string_adaptor> >& args) : XPathFunction<string_type, string_adaptor>(0, 0, args) { }
virtual XPathValue_impl<string_type, string_adaptor>* evaluate(const DOM::Node<string_type, string_adaptor>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const
@ -112,7 +112,7 @@ class CountFn : public XPathFunction<string_type, string_adaptor>
{
typedef XPathFunction<string_type, string_adaptor> baseT;
public:
CountFn(const std::vector<XPathExpressionPtr<string_type, string_adaptor> >& args) : XPathFunction<string_type, string_adaptor>(1, 1, args) { }
CountFn(const std::vector<XPathExpression<string_type, string_adaptor> >& args) : XPathFunction<string_type, string_adaptor>(1, 1, args) { }
virtual XPathValue_impl<string_type, string_adaptor>* evaluate(const DOM::Node<string_type, string_adaptor>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const
@ -128,7 +128,7 @@ class LocalNameFn : public XPathFunction<string_type, string_adaptor>
{
typedef XPathFunction<string_type, string_adaptor> baseT;
public:
LocalNameFn(const std::vector<XPathExpressionPtr<string_type, string_adaptor> >& args) : XPathFunction<string_type, string_adaptor>(0, 1, args) { }
LocalNameFn(const std::vector<XPathExpression<string_type, string_adaptor> >& args) : XPathFunction<string_type, string_adaptor>(0, 1, args) { }
virtual XPathValue_impl<string_type, string_adaptor>* evaluate(const DOM::Node<string_type, string_adaptor>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const
@ -163,7 +163,7 @@ class NamespaceURIFn : public XPathFunction<string_type, string_adaptor>
{
typedef XPathFunction<string_type, string_adaptor> baseT;
public:
NamespaceURIFn(const std::vector<XPathExpressionPtr<string_type, string_adaptor> >& args) : XPathFunction<string_type, string_adaptor>(0, 1, args) { }
NamespaceURIFn(const std::vector<XPathExpression<string_type, string_adaptor> >& args) : XPathFunction<string_type, string_adaptor>(0, 1, args) { }
virtual XPathValue_impl<string_type, string_adaptor>* evaluate(const DOM::Node<string_type, string_adaptor>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const
@ -197,7 +197,7 @@ class NameFn : public XPathFunction<string_type, string_adaptor>
{
typedef XPathFunction<string_type, string_adaptor> baseT;
public:
NameFn(const std::vector<XPathExpressionPtr<string_type, string_adaptor> >& args) : XPathFunction<string_type, string_adaptor>(0, 1, args) { }
NameFn(const std::vector<XPathExpression<string_type, string_adaptor> >& args) : XPathFunction<string_type, string_adaptor>(0, 1, args) { }
virtual XPathValue_impl<string_type, string_adaptor>* evaluate(const DOM::Node<string_type, string_adaptor>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const
@ -236,7 +236,7 @@ class StringFn : public XPathFunction<string_type, string_adaptor>
{
typedef XPathFunction<string_type, string_adaptor> baseT;
public:
StringFn(const std::vector<XPathExpressionPtr<string_type, string_adaptor> >& args) : XPathFunction<string_type, string_adaptor>(0, 1, args) { }
StringFn(const std::vector<XPathExpression<string_type, string_adaptor> >& args) : XPathFunction<string_type, string_adaptor>(0, 1, args) { }
virtual XPathValue_impl<string_type, string_adaptor>* evaluate(const DOM::Node<string_type, string_adaptor>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const
@ -251,7 +251,7 @@ class ConcatFn : public XPathFunction<string_type, string_adaptor>
{
typedef XPathFunction<string_type, string_adaptor> baseT;
public:
ConcatFn(const std::vector<XPathExpressionPtr<string_type, string_adaptor> >& args) : XPathFunction<string_type, string_adaptor>(2, -1, args) { }
ConcatFn(const std::vector<XPathExpression<string_type, string_adaptor> >& args) : XPathFunction<string_type, string_adaptor>(2, -1, args) { }
virtual XPathValue_impl<string_type, string_adaptor>* evaluate(const DOM::Node<string_type, string_adaptor>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const
@ -269,7 +269,7 @@ class StartsWithFn : public XPathFunction<string_type, string_adaptor>
{
typedef XPathFunction<string_type, string_adaptor> baseT;
public:
StartsWithFn(const std::vector<XPathExpressionPtr<string_type, string_adaptor> >& args) : XPathFunction<string_type, string_adaptor>(2, 2, args) { }
StartsWithFn(const std::vector<XPathExpression<string_type, string_adaptor> >& args) : XPathFunction<string_type, string_adaptor>(2, 2, args) { }
virtual XPathValue_impl<string_type, string_adaptor>* evaluate(const DOM::Node<string_type, string_adaptor>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const
@ -297,7 +297,7 @@ class ContainsFn : public XPathFunction<string_type, string_adaptor>
{
typedef XPathFunction<string_type, string_adaptor> baseT;
public:
ContainsFn(const std::vector<XPathExpressionPtr<string_type, string_adaptor> >& args) : XPathFunction<string_type, string_adaptor>(2, 2, args) { }
ContainsFn(const std::vector<XPathExpression<string_type, string_adaptor> >& args) : XPathFunction<string_type, string_adaptor>(2, 2, args) { }
virtual XPathValue_impl<string_type, string_adaptor>* evaluate(const DOM::Node<string_type, string_adaptor>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const
@ -313,7 +313,7 @@ class SubstringBeforeFn : public XPathFunction<string_type, string_adaptor>
{
typedef XPathFunction<string_type, string_adaptor> baseT;
public:
SubstringBeforeFn(const std::vector<XPathExpressionPtr<string_type, string_adaptor> >& args) : XPathFunction<string_type, string_adaptor>(2, 2, args) { }
SubstringBeforeFn(const std::vector<XPathExpression<string_type, string_adaptor> >& args) : XPathFunction<string_type, string_adaptor>(2, 2, args) { }
virtual XPathValue_impl<string_type, string_adaptor>* evaluate(const DOM::Node<string_type, string_adaptor>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const
@ -334,7 +334,7 @@ class SubstringAfterFn : public XPathFunction<string_type, string_adaptor>
{
typedef XPathFunction<string_type, string_adaptor> baseT;
public:
SubstringAfterFn(const std::vector<XPathExpressionPtr<string_type, string_adaptor> >& args) : XPathFunction<string_type, string_adaptor>(2, 2, args) { }
SubstringAfterFn(const std::vector<XPathExpression<string_type, string_adaptor> >& args) : XPathFunction<string_type, string_adaptor>(2, 2, args) { }
virtual XPathValue_impl<string_type, string_adaptor>* evaluate(const DOM::Node<string_type, string_adaptor>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const
@ -356,7 +356,7 @@ class SubstringFn : public XPathFunction<string_type, string_adaptor>
{
typedef XPathFunction<string_type, string_adaptor> baseT;
public:
SubstringFn(const std::vector<XPathExpressionPtr<string_type, string_adaptor> >& args) : XPathFunction<string_type, string_adaptor>(2, 3, args) { }
SubstringFn(const std::vector<XPathExpression<string_type, string_adaptor> >& args) : XPathFunction<string_type, string_adaptor>(2, 3, args) { }
virtual XPathValue_impl<string_type, string_adaptor>* evaluate(const DOM::Node<string_type, string_adaptor>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const
@ -386,7 +386,7 @@ class StringLengthFn : public XPathFunction<string_type, string_adaptor>
{
typedef XPathFunction<string_type, string_adaptor> baseT;
public:
StringLengthFn(const std::vector<XPathExpressionPtr<string_type, string_adaptor> >& args) : XPathFunction<string_type, string_adaptor>(0, 1, args) { }
StringLengthFn(const std::vector<XPathExpression<string_type, string_adaptor> >& args) : XPathFunction<string_type, string_adaptor>(0, 1, args) { }
virtual XPathValue_impl<string_type, string_adaptor>* evaluate(const DOM::Node<string_type, string_adaptor>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const
@ -402,7 +402,7 @@ class NormalizeSpaceFn : public XPathFunction<string_type, string_adaptor>
{
typedef XPathFunction<string_type, string_adaptor> baseT;
public:
NormalizeSpaceFn(const std::vector<XPathExpressionPtr<string_type, string_adaptor> >& args) : XPathFunction<string_type, string_adaptor>(0, 1, args) { }
NormalizeSpaceFn(const std::vector<XPathExpression<string_type, string_adaptor> >& args) : XPathFunction<string_type, string_adaptor>(0, 1, args) { }
virtual XPathValue_impl<string_type, string_adaptor>* evaluate(const DOM::Node<string_type, string_adaptor>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const
@ -419,7 +419,7 @@ class TranslateFn : public XPathFunction<string_type, string_adaptor>
{
typedef XPathFunction<string_type, string_adaptor> baseT;
public:
TranslateFn(const std::vector<XPathExpressionPtr<string_type, string_adaptor> >& args) : XPathFunction<string_type, string_adaptor>(3, 3, args) { }
TranslateFn(const std::vector<XPathExpression<string_type, string_adaptor> >& args) : XPathFunction<string_type, string_adaptor>(3, 3, args) { }
virtual XPathValue_impl<string_type, string_adaptor>* evaluate(const DOM::Node<string_type, string_adaptor>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const
@ -453,7 +453,7 @@ class BooleanFn : public XPathFunction<string_type, string_adaptor>
{
typedef XPathFunction<string_type, string_adaptor> baseT;
public:
BooleanFn(const std::vector<XPathExpressionPtr<string_type, string_adaptor> >& args) : XPathFunction<string_type, string_adaptor>(1, 1, args) { }
BooleanFn(const std::vector<XPathExpression<string_type, string_adaptor> >& args) : XPathFunction<string_type, string_adaptor>(1, 1, args) { }
virtual XPathValue_impl<string_type, string_adaptor>* evaluate(const DOM::Node<string_type, string_adaptor>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const
@ -468,7 +468,7 @@ class NotFn : public XPathFunction<string_type, string_adaptor>
{
typedef XPathFunction<string_type, string_adaptor> baseT;
public:
NotFn(const std::vector<XPathExpressionPtr<string_type, string_adaptor> >& args) : XPathFunction<string_type, string_adaptor>(1, 1, args) { }
NotFn(const std::vector<XPathExpression<string_type, string_adaptor> >& args) : XPathFunction<string_type, string_adaptor>(1, 1, args) { }
virtual XPathValue_impl<string_type, string_adaptor>* evaluate(const DOM::Node<string_type, string_adaptor>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const
@ -482,7 +482,7 @@ template<class string_type, class string_adaptor>
class TrueFn : public XPathFunction<string_type, string_adaptor>
{
public:
TrueFn(const std::vector<XPathExpressionPtr<string_type, string_adaptor> >& args) : XPathFunction<string_type, string_adaptor>(0, 0, args) { }
TrueFn(const std::vector<XPathExpression<string_type, string_adaptor> >& args) : XPathFunction<string_type, string_adaptor>(0, 0, args) { }
virtual XPathValue_impl<string_type, string_adaptor>* evaluate(const DOM::Node<string_type, string_adaptor>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const
@ -496,7 +496,7 @@ template<class string_type, class string_adaptor>
class FalseFn : public XPathFunction<string_type, string_adaptor>
{
public:
FalseFn(const std::vector<XPathExpressionPtr<string_type, string_adaptor> >& args) : XPathFunction<string_type, string_adaptor>(0, 0, args) { }
FalseFn(const std::vector<XPathExpression<string_type, string_adaptor> >& args) : XPathFunction<string_type, string_adaptor>(0, 0, args) { }
virtual XPathValue_impl<string_type, string_adaptor>* evaluate(const DOM::Node<string_type, string_adaptor>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const
@ -516,7 +516,7 @@ class NumberFn : public XPathFunction<string_type, string_adaptor>
{
typedef XPathFunction<string_type, string_adaptor> baseT;
public:
NumberFn(const std::vector<XPathExpressionPtr<string_type, string_adaptor> >& args) : XPathFunction<string_type, string_adaptor>(0, 1, args) { }
NumberFn(const std::vector<XPathExpression<string_type, string_adaptor> >& args) : XPathFunction<string_type, string_adaptor>(0, 1, args) { }
virtual XPathValue_impl<string_type, string_adaptor>* evaluate(const DOM::Node<string_type, string_adaptor>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const
@ -533,7 +533,7 @@ class SumFn : public XPathFunction<string_type, string_adaptor>
{
typedef XPathFunction<string_type, string_adaptor> baseT;
public:
SumFn(const std::vector<XPathExpressionPtr<string_type, string_adaptor> >& args) : XPathFunction<string_type, string_adaptor>(1, 1, args) { }
SumFn(const std::vector<XPathExpression<string_type, string_adaptor> >& args) : XPathFunction<string_type, string_adaptor>(1, 1, args) { }
virtual XPathValue_impl<string_type, string_adaptor>* evaluate(const DOM::Node<string_type, string_adaptor>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const
@ -552,7 +552,7 @@ class FloorFn : public XPathFunction<string_type, string_adaptor>
{
typedef XPathFunction<string_type, string_adaptor> baseT;
public:
FloorFn(const std::vector<XPathExpressionPtr<string_type, string_adaptor> >& args) : XPathFunction<string_type, string_adaptor>(1, 1, args) { }
FloorFn(const std::vector<XPathExpression<string_type, string_adaptor> >& args) : XPathFunction<string_type, string_adaptor>(1, 1, args) { }
virtual XPathValue_impl<string_type, string_adaptor>* evaluate(const DOM::Node<string_type, string_adaptor>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const
@ -567,7 +567,7 @@ class CeilingFn : public XPathFunction<string_type, string_adaptor>
{
typedef XPathFunction<string_type, string_adaptor> baseT;
public:
CeilingFn(const std::vector<XPathExpressionPtr<string_type, string_adaptor> >& args) : XPathFunction<string_type, string_adaptor>(1, 1, args) { }
CeilingFn(const std::vector<XPathExpression<string_type, string_adaptor> >& args) : XPathFunction<string_type, string_adaptor>(1, 1, args) { }
virtual XPathValue_impl<string_type, string_adaptor>* evaluate(const DOM::Node<string_type, string_adaptor>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const
@ -582,7 +582,7 @@ class RoundFn : public XPathFunction<string_type, string_adaptor>
{
typedef XPathFunction<string_type, string_adaptor> baseT;
public:
RoundFn(const std::vector<XPathExpressionPtr<string_type, string_adaptor> >& args) : XPathFunction<string_type, string_adaptor>(1, 1, args) { }
RoundFn(const std::vector<XPathExpression<string_type, string_adaptor> >& args) : XPathFunction<string_type, string_adaptor>(1, 1, args) { }
virtual XPathValue_impl<string_type, string_adaptor>* evaluate(const DOM::Node<string_type, string_adaptor>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const

View file

@ -13,7 +13,7 @@ namespace impl
{
template<class function_type, class string_type, class string_adaptor>
XPathFunction<string_type, string_adaptor>* CreateFn(const std::vector<XPathExpressionPtr<string_type, string_adaptor> >& argExprs) { return new function_type(argExprs); }
XPathFunction<string_type, string_adaptor>* CreateFn(const std::vector<XPathExpression<string_type, string_adaptor> >& argExprs) { return new function_type(argExprs); }
template<class string_type, class string_adaptor>
class FunctionHolder : public XPathExpression_impl<string_type, string_adaptor>
@ -37,7 +37,7 @@ public:
static FunctionHolder* createFunction(const string_type& namespace_uri,
const string_type& name,
const std::vector<XPathExpressionPtr<string_type, string_adaptor> >& argExprs,
const std::vector<XPathExpression<string_type, string_adaptor> >& argExprs,
const CompilationContext<string_type, string_adaptor>& context)
{
if(string_adaptor::empty(namespace_uri))
@ -66,7 +66,7 @@ public:
private:
XPathFunction<string_type, string_adaptor>* func_;
typedef XPathFunction<string_type, string_adaptor>* (*CreateFnPtr)(const std::vector<XPathExpressionPtr<string_type, string_adaptor> >& argExprs);
typedef XPathFunction<string_type, string_adaptor>* (*CreateFnPtr)(const std::vector<XPathExpression<string_type, string_adaptor> >& argExprs);
struct NamedFunction { const char* name; CreateFnPtr creator; };

View file

@ -7,7 +7,7 @@ namespace XPath
{
template<class string_type, class string_adaptor> class XPathFunction;
template<class string_type, class string_adaptor> class XPathExpressionPtr;
template<class string_type, class string_adaptor> class XPathExpression;
class UndefinedFunctionException : public std::runtime_error
{
@ -25,7 +25,7 @@ public:
virtual XPathFunction<string_type, string_adaptor>*
resolveFunction(const string_type& namespace_uri,
const string_type& name,
const std::vector<XPathExpressionPtr<string_type, string_adaptor> >& argExprs) const = 0;
const std::vector<XPathExpression<string_type, string_adaptor> >& argExprs) const = 0;
}; // class FunctionResolver
template<class string_type, class string_adaptor>
@ -45,7 +45,7 @@ public:
virtual XPathFunction<string_type, string_adaptor>*
resolveFunction(const string_type& namespace_uri,
const string_type& name,
const std::vector<XPathExpressionPtr<string_type, string_adaptor> >& argExprs) const
const std::vector<XPathExpression<string_type, string_adaptor> >& argExprs) const
{
string_type error;
if(!string_adaptor::empty(namespace_uri))

View file

@ -25,13 +25,13 @@ public:
bool evaluate(const DOM::Node<string_type, string_adaptor>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const
{
return match_->evaluateAsBool(context, executionContext);
return match_.evaluateAsBool(context, executionContext);
} // evaluate
void override_priority(double p) { priority_ = p; }
private:
XPathExpressionPtr<string_type, string_adaptor> match_;
XPathExpression<string_type, string_adaptor> match_;
double priority_;
}; // MatchExpr

View file

@ -64,24 +64,24 @@ public:
{
} // ~XPath
XPathExpressionPtr<string_type, string_adaptor> compile(const string_type& xpath) const
XPathExpression<string_type, string_adaptor> compile(const string_type& xpath) const
{
return do_compile(xpath, &XPath::parse_xpath, expression_factory());
} // compile
XPathExpressionPtr<string_type, string_adaptor> compile_expr(const string_type& xpath) const
XPathExpression<string_type, string_adaptor> compile_expr(const string_type& xpath) const
{
return do_compile(xpath, &XPath::parse_xpath_expr, expression_factory());
} // compile_expr
XPathExpressionPtr<string_type, string_adaptor> compile_attribute_value_template(const string_type& xpath) const
XPathExpression<string_type, string_adaptor> compile_attribute_value_template(const string_type& xpath) const
{
return do_compile(xpath, &XPath::parse_xpath_attribute_value_template, attribute_value_factory());
} // compile_attribute_value_template
std::vector<MatchExpr<string_type, string_adaptor> > compile_match(const string_type& xpath) const
{
XPathExpressionPtr<string_type, string_adaptor> wrapper = do_compile(xpath, &XPath::parse_xpath_match, match_factory());
XPathExpression<string_type, string_adaptor> wrapper = do_compile(xpath, &XPath::parse_xpath_match, match_factory());
return (static_cast<const impl::MatchExpressionWrapper<string_type, string_adaptor>*>(wrapper.get()))->matches();
} // compile_match
@ -89,14 +89,14 @@ public:
{
ExecutionContext<string_type, string_adaptor> executionContext;
executionContext.setVariableResolver(getVariableResolver());
return compile(xpath)->evaluate(context, executionContext);
return compile(xpath).evaluate(context, executionContext);
} // evaluate
XPathValue<string_type, string_adaptor> evaluate_expr(const string_type& xpath, const DOM::Node<string_type, string_adaptor>& context) const
{
ExecutionContext<string_type, string_adaptor> executionContext;
executionContext.setVariableResolver(getVariableResolver());
return compile_expr(xpath)->evaluate(context, executionContext);
return compile_expr(xpath).evaluate(context, executionContext);
} // evaluate_expr
void setNamespaceContext(const NamespaceContext<string_type, string_adaptor>& namespaceContext) { namespaceContext_.set(namespaceContext); }
@ -120,7 +120,7 @@ private:
impl::CompilationContext<string_type, string_adaptor>& context);
typedef typename impl::types<string_adaptor>::tree_info_t(XPath::*parserFn)(const string_type& str) const;
XPathExpressionPtr<string_type, string_adaptor> do_compile(const string_type& xpath,
XPathExpression<string_type, string_adaptor> do_compile(const string_type& xpath,
parserFn parser,
const std::map<int, compileFn>& factory) const
{
@ -132,7 +132,7 @@ private:
impl::CompilationContext<string_type, string_adaptor> context(*this, getNamespaceContext(), getFunctionResolver());
//XPath::dump(ast.trees.begin(), 0);
return XPathExpressionPtr<string_type, string_adaptor>(compile_with_factory(ast.trees.begin(),
return XPathExpression<string_type, string_adaptor>(compile_with_factory(ast.trees.begin(),
ast.trees.end(),
context,
factory));
@ -573,10 +573,10 @@ XPathExpression_impl<string_type, string_adaptor>* XPath<string_type, string_ada
++c;
impl::skipWhitespace<string_adaptor>(c);
std::vector<XPathExpressionPtr<string_type, string_adaptor> > args;
std::vector<XPathExpression<string_type, string_adaptor> > args;
while(impl::getNodeId<string_adaptor>(c) != impl::RightBracket_id)
{
XPathExpressionPtr<string_type, string_adaptor> arg(XPath<string_type, string_adaptor>::compile_expression(c++, i->children.end(), context));
XPathExpression<string_type, string_adaptor> arg(XPath<string_type, string_adaptor>::compile_expression(c++, i->children.end(), context));
args.push_back(arg);
impl::skipWhitespace<string_adaptor>(c);
@ -962,10 +962,10 @@ impl::StepList<string_type, string_adaptor> XPath<string_type, string_adaptor>::
template<class string_type, class string_adaptor>
XPathExpression_impl<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<XPathExpression<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)
{
XPathExpressionPtr<string_type, string_adaptor> arg(XPath<string_type, string_adaptor>::compile_attribute_value(a, e, context));
XPathExpression<string_type, string_adaptor> arg(XPath<string_type, string_adaptor>::compile_attribute_value(a, e, context));
args.push_back(arg);
} // while ...
// maybe trailing whitespace ...

View file

@ -15,7 +15,7 @@ class CurrentFunction : public Arabica::XPath::XPathFunction<std::string>
typedef Arabica::XPath::XPathFunction<std::string> baseT;
public:
CurrentFunction(const std::vector<Arabica::XPath::XPathExpressionPtr<std::string> >& args) :
CurrentFunction(const std::vector<Arabica::XPath::XPathExpression<std::string> >& args) :
Arabica::XPath::XPathFunction<std::string>(0, 0, args) { }
virtual Arabica::XPath::XPathValue_impl<std::string>* evaluate(const DOM::Node<std::string>& context,
@ -34,7 +34,7 @@ class DocumentFunction : public Arabica::XPath::XPathFunction<std::string>
public:
DocumentFunction(const std::string& currentBase,
const std::vector<Arabica::XPath::XPathExpressionPtr<std::string> >& args) :
const std::vector<Arabica::XPath::XPathExpression<std::string> >& args) :
Arabica::XPath::XPathFunction<std::string>(1, 2, args),
baseURI_(currentBase)
{ }
@ -81,7 +81,7 @@ class SystemPropertyFunction : public Arabica::XPath::XPathFunction<std::string>
typedef Arabica::XPath::XPathFunction<std::string> baseT;
public:
SystemPropertyFunction (const std::vector<Arabica::XPath::XPathExpressionPtr<std::string> >& args) :
SystemPropertyFunction (const std::vector<Arabica::XPath::XPathExpression<std::string> >& args) :
Arabica::XPath::XPathFunction<std::string>(1, 1, args) { }
virtual Arabica::XPath::XPathValue_impl<std::string>* evaluate(const DOM::Node<std::string>& context,

View file

@ -199,7 +199,7 @@ private:
virtual Arabica::XPath::XPathFunction<std::string>* resolveFunction(
const std::string& namespace_uri,
const std::string& name,
const std::vector<Arabica::XPath::XPathExpressionPtr<std::string> >& argExprs) const
const std::vector<Arabica::XPath::XPathExpression<std::string> >& argExprs) const
{
if(!namespace_uri.empty())
return 0;

View file

@ -25,10 +25,10 @@ public:
XPathExpression_impl<string_type, string_adaptor>* p1 = new NumericValue<string_type, string_adaptor>(1);
XPathExpression_impl<string_type, string_adaptor>* p2 = new NumericValue<string_type, string_adaptor>(2);
XPathExpressionPtr<string_type, string_adaptor> add(new impl::PlusOperator<string_type, string_adaptor>(p1, p2));
XPathExpression<string_type, string_adaptor> add(new impl::PlusOperator<string_type, string_adaptor>(p1, p2));
add->evaluate(dummy_);
assertEquals(3.0, add->evaluateAsNumber(dummy_), 0.0);
add.evaluate(dummy_);
assertEquals(3.0, add.evaluateAsNumber(dummy_), 0.0);
} // test1
void test2()
@ -37,9 +37,9 @@ public:
XPathExpression_impl<string_type, string_adaptor>* p1 = new NumericValue<string_type, string_adaptor>(1);
XPathExpression_impl<string_type, string_adaptor>* p2 = new NumericValue<string_type, string_adaptor>(2);
XPathExpressionPtr<string_type, string_adaptor> minus(new impl::MinusOperator<string_type, string_adaptor>(p1, p2));
XPathExpression<string_type, string_adaptor> minus(new impl::MinusOperator<string_type, string_adaptor>(p1, p2));
assertEquals(-1.0, minus->evaluateAsNumber(dummy_), 0.0);
assertEquals(-1.0, minus.evaluateAsNumber(dummy_), 0.0);
} // test2
void test3()
@ -48,9 +48,9 @@ public:
XPathExpression_impl<string_type, string_adaptor>* p1 = new NumericValue<string_type, string_adaptor>(3);
XPathExpression_impl<string_type, string_adaptor>* p2 = new NumericValue<string_type, string_adaptor>(2);
XPathExpressionPtr<string_type, string_adaptor> mult(new impl::MultiplyOperator<string_type, string_adaptor>(p1, p2));
XPathExpression<string_type, string_adaptor> mult(new impl::MultiplyOperator<string_type, string_adaptor>(p1, p2));
assertEquals(6, mult->evaluateAsNumber(dummy_), 0.0);
assertEquals(6, mult.evaluateAsNumber(dummy_), 0.0);
} // test3
void test4()
@ -58,10 +58,10 @@ public:
using namespace Arabica::XPath;
XPathExpression_impl<string_type, string_adaptor>* mult = new impl::MultiplyOperator<string_type, string_adaptor>(new NumericValue<string_type, string_adaptor>(4), new NumericValue<string_type, string_adaptor>(2));
XPathExpressionPtr<string_type, string_adaptor> minus(new impl::MinusOperator<string_type, string_adaptor>(mult, new NumericValue<string_type, string_adaptor>(2)));
XPathExpression<string_type, string_adaptor> minus(new impl::MinusOperator<string_type, string_adaptor>(mult, new NumericValue<string_type, string_adaptor>(2)));
assertEquals(8, mult->evaluateAsNumber(dummy_), 0.0);
assertEquals(6, minus->evaluateAsNumber(dummy_), 0.0);
assertEquals(6, minus.evaluateAsNumber(dummy_), 0.0);
} // test4
void test5()
@ -70,9 +70,9 @@ public:
XPathExpression_impl<string_type, string_adaptor>* p1 = new NumericValue<string_type, string_adaptor>(12);
XPathExpression_impl<string_type, string_adaptor>* p2 = new NumericValue<string_type, string_adaptor>(2);
XPathExpressionPtr<string_type, string_adaptor> div(new impl::DivideOperator<string_type, string_adaptor>(p1, p2));
XPathExpression<string_type, string_adaptor> div(new impl::DivideOperator<string_type, string_adaptor>(p1, p2));
assertEquals(6, div->evaluateAsNumber(dummy_), 0.0);
assertEquals(6, div.evaluateAsNumber(dummy_), 0.0);
} // test5
void test6()
@ -81,9 +81,9 @@ public:
XPathExpression_impl<string_type, string_adaptor>* p1 = new NumericValue<string_type, string_adaptor>(12);
XPathExpression_impl<string_type, string_adaptor>* p2 = new NumericValue<string_type, string_adaptor>(2);
XPathExpressionPtr<string_type, string_adaptor> mod(new impl::ModOperator<string_type, string_adaptor>(p1, p2));
XPathExpression<string_type, string_adaptor> mod(new impl::ModOperator<string_type, string_adaptor>(p1, p2));
assertEquals(0, mod->evaluateAsNumber(dummy_), 0.0);
assertEquals(0, mod.evaluateAsNumber(dummy_), 0.0);
} // test6
void test7()
@ -92,9 +92,9 @@ public:
XPathExpression_impl<string_type, string_adaptor>* p1 = new NumericValue<string_type, string_adaptor>(11);
XPathExpression_impl<string_type, string_adaptor>* p2 = new NumericValue<string_type, string_adaptor>(2);
XPathExpressionPtr<string_type, string_adaptor> div(new impl::DivideOperator<string_type, string_adaptor>(p1, p2));
XPathExpression<string_type, string_adaptor> div(new impl::DivideOperator<string_type, string_adaptor>(p1, p2));
assertEquals(5.5, div->evaluateAsNumber(dummy_), 0.0);
assertEquals(5.5, div.evaluateAsNumber(dummy_), 0.0);
} // test7
void test8()
@ -103,9 +103,9 @@ public:
XPathExpression_impl<string_type, string_adaptor>* p1 = new NumericValue<string_type, string_adaptor>(11);
XPathExpression_impl<string_type, string_adaptor>* p2 = new NumericValue<string_type, string_adaptor>(4);
XPathExpressionPtr<string_type, string_adaptor> mod(new impl::ModOperator<string_type, string_adaptor>(p1, p2));
XPathExpression<string_type, string_adaptor> mod(new impl::ModOperator<string_type, string_adaptor>(p1, p2));
assertEquals(3, mod->evaluateAsNumber(dummy_), 0.0);
assertEquals(3, mod.evaluateAsNumber(dummy_), 0.0);
} // test8
void test9()
@ -114,9 +114,9 @@ public:
XPathExpression_impl<string_type, string_adaptor>* p1 = new NumericValue<string_type, string_adaptor>(5);
XPathExpression_impl<string_type, string_adaptor>* p2 = new NumericValue<string_type, string_adaptor>(2);
XPathExpressionPtr<string_type, string_adaptor> mod(new impl::ModOperator<string_type, string_adaptor>(p1, p2));
XPathExpression<string_type, string_adaptor> mod(new impl::ModOperator<string_type, string_adaptor>(p1, p2));
assertEquals(1.0, mod->evaluateAsNumber(dummy_), 0.0);
assertEquals(1.0, mod.evaluateAsNumber(dummy_), 0.0);
} // test9
void test10()
@ -125,9 +125,9 @@ public:
XPathExpression_impl<string_type, string_adaptor>* p1 = new NumericValue<string_type, string_adaptor>(5);
XPathExpression_impl<string_type, string_adaptor>* p2 = new NumericValue<string_type, string_adaptor>(-2);
XPathExpressionPtr<string_type, string_adaptor> mod(new impl::ModOperator<string_type, string_adaptor>(p1, p2));
XPathExpression<string_type, string_adaptor> mod(new impl::ModOperator<string_type, string_adaptor>(p1, p2));
assertEquals(1.00, mod->evaluateAsNumber(dummy_), 0.0);
assertEquals(1.00, mod.evaluateAsNumber(dummy_), 0.0);
} // test10
void test11()
@ -136,9 +136,9 @@ public:
XPathExpression_impl<string_type, string_adaptor>* p1 = new NumericValue<string_type, string_adaptor>(-5);
XPathExpression_impl<string_type, string_adaptor>* p2 = new NumericValue<string_type, string_adaptor>(2);
XPathExpressionPtr<string_type, string_adaptor> mod(new impl::ModOperator<string_type, string_adaptor>(p1, p2));
XPathExpression<string_type, string_adaptor> mod(new impl::ModOperator<string_type, string_adaptor>(p1, p2));
assertEquals(-1.0, mod->evaluateAsNumber(dummy_), 0.0);
assertEquals(-1.0, mod.evaluateAsNumber(dummy_), 0.0);
} // test11
void test12()
@ -147,27 +147,27 @@ public:
XPathExpression_impl<string_type, string_adaptor>* p1 = new NumericValue<string_type, string_adaptor>(-5);
XPathExpression_impl<string_type, string_adaptor>* p2 = new NumericValue<string_type, string_adaptor>(-2);
XPathExpressionPtr<string_type, string_adaptor> mod(new impl::ModOperator<string_type, string_adaptor>(p1, p2));
XPathExpression<string_type, string_adaptor> mod(new impl::ModOperator<string_type, string_adaptor>(p1, p2));
assertEquals(-1.0, mod->evaluateAsNumber(dummy_), 0.0);
assertEquals(-1.0, mod.evaluateAsNumber(dummy_), 0.0);
} // test12
void test13()
{
using namespace Arabica::XPath;
XPathExpression_impl<string_type, string_adaptor>* p1 = new NumericValue<string_type, string_adaptor>(5);
XPathExpressionPtr<string_type, string_adaptor> p2(new impl::UnaryNegative<string_type, string_adaptor>(p1));
XPathExpression<string_type, string_adaptor> p2(new impl::UnaryNegative<string_type, string_adaptor>(p1));
assertEquals(-5.0, p2->evaluateAsNumber(dummy_), 0.0);
assertEquals(-5.0, p2.evaluateAsNumber(dummy_), 0.0);
} // test13
void test14()
{
using namespace Arabica::XPath;
XPathExpression_impl<string_type, string_adaptor>* p1 = new NumericValue<string_type, string_adaptor>(-5);
XPathExpressionPtr<string_type, string_adaptor> p2(new impl::UnaryNegative<string_type, string_adaptor>(p1));
XPathExpression<string_type, string_adaptor> p2(new impl::UnaryNegative<string_type, string_adaptor>(p1));
assertEquals(5.0, p2->evaluateAsNumber(dummy_), 0.0);
assertEquals(5.0, p2.evaluateAsNumber(dummy_), 0.0);
} // test14
private:

View file

@ -25,16 +25,16 @@ public:
void testParse()
{
Arabica::DOM::Node<string_type, string_adaptor> dummy;
assertTrue(SA::construct_from_utf8("hello") == compileThis("hello")->evaluateAsString(dummy));
assertTrue(SA::construct_from_utf8("") == compileThis("{hello}")->evaluateAsString(dummy));
assertTrue(SA::construct_from_utf8("{hello}") == compileThis("{{hello}}")->evaluateAsString(dummy));
assertTrue(SA::construct_from_utf8("{hello}") == compileThis("{{{'hello'}}}")->evaluateAsString(dummy));
assertTrue(SA::construct_from_utf8("{}") == compileThis("{{{hello}}}")->evaluateAsString(dummy));
assertTrue(SA::construct_from_utf8("{") == compileThis("{{")->evaluateAsString(dummy));
assertTrue(SA::construct_from_utf8("}") == compileThis("}}")->evaluateAsString(dummy));
assertTrue(SA::construct_from_utf8("hello") == compileThis("hello{@there}")->evaluateAsString(dummy));
assertTrue(SA::construct_from_utf8("helloMOTHER{}") == compileThis("hello{@there}MOTHER{{}}")->evaluateAsString(dummy));
assertTrue(SA::construct_from_utf8("hello there everyone look a }") == compileThis("hello {string('there')} everyone {string('look a }')}")->evaluateAsString(dummy));
assertTrue(SA::construct_from_utf8("hello") == compileThis("hello").evaluateAsString(dummy));
assertTrue(SA::construct_from_utf8("") == compileThis("{hello}").evaluateAsString(dummy));
assertTrue(SA::construct_from_utf8("{hello}") == compileThis("{{hello}}").evaluateAsString(dummy));
assertTrue(SA::construct_from_utf8("{hello}") == compileThis("{{{'hello'}}}").evaluateAsString(dummy));
assertTrue(SA::construct_from_utf8("{}") == compileThis("{{{hello}}}").evaluateAsString(dummy));
assertTrue(SA::construct_from_utf8("{") == compileThis("{{").evaluateAsString(dummy));
assertTrue(SA::construct_from_utf8("}") == compileThis("}}").evaluateAsString(dummy));
assertTrue(SA::construct_from_utf8("hello") == compileThis("hello{@there}").evaluateAsString(dummy));
assertTrue(SA::construct_from_utf8("helloMOTHER{}") == compileThis("hello{@there}MOTHER{{}}").evaluateAsString(dummy));
assertTrue(SA::construct_from_utf8("hello there everyone look a }") == compileThis("hello {string('there')} everyone {string('look a }')}").evaluateAsString(dummy));
} // testParse
void testParseFail()
@ -60,7 +60,7 @@ public:
return true;
} // dontCompileThis
Arabica::XPath::XPathExpressionPtr<string_type, string_adaptor> compileThis(const char* match)
Arabica::XPath::XPathExpression<string_type, string_adaptor> compileThis(const char* match)
{
//std::cout << "----\n" << match << std::endl;
return parser.compile_attribute_value_template(SA::construct_from_utf8(match));

View file

@ -62,7 +62,7 @@ class TestFunction : public Arabica::XPath::XPathFunction<string_type, string_ad
{
//typedef string_adaptorstring_adaptor;
public:
TestFunction(const std::vector<Arabica::XPath::XPathExpressionPtr<string_type, string_adaptor> >& args) :
TestFunction(const std::vector<Arabica::XPath::XPathExpression<string_type, string_adaptor> >& args) :
Arabica::XPath::XPathFunction<string_type, string_adaptor>(0, 0, args) { }
virtual Arabica::XPath::XPathValue_impl<string_type, string_adaptor>* evaluate(const Arabica::DOM::Node<string_type, string_adaptor>& context,
@ -82,7 +82,7 @@ public:
virtual Arabica::XPath::XPathFunction<string_type, string_adaptor>* resolveFunction(
const string_type& namespace_uri,
const string_type& name,
const std::vector<Arabica::XPath::XPathExpressionPtr<string_type, string_adaptor> >& argExprs) const
const std::vector<Arabica::XPath::XPathExpression<string_type, string_adaptor> >& argExprs) const
{
if(name == string_adaptor::construct_from_utf8("test-function"))
return new TestFunction<string_type, string_adaptor>(argExprs);
@ -176,9 +176,9 @@ public:
void test1()
{
using namespace Arabica::XPath;
XPathExpressionPtr<string_type, string_adaptor> xpath;
XPathExpression<string_type, string_adaptor> xpath;
xpath = parser.compile(SA::construct_from_utf8("root"));
XPathValue<string_type, string_adaptor> result = xpath->evaluate(document_);
XPathValue<string_type, string_adaptor> result = xpath.evaluate(document_);
assertValuesEqual(NODE_SET, result.type());
assertValuesEqual(1, result.asNodeSet().size());
@ -189,8 +189,8 @@ public:
void test2()
{
using namespace Arabica::XPath;
XPathExpressionPtr<string_type, string_adaptor> xpath = parser.compile(SA::construct_from_utf8("root/child2"));
XPathValue<string_type, string_adaptor> result = xpath->evaluate(document_);
XPathExpression<string_type, string_adaptor> xpath = parser.compile(SA::construct_from_utf8("root/child2"));
XPathValue<string_type, string_adaptor> result = xpath.evaluate(document_);
assertValuesEqual(NODE_SET, result.type());
assertValuesEqual(1, result.asNodeSet().size());
@ -201,8 +201,8 @@ public:
void test3()
{
using namespace Arabica::XPath;
XPathExpressionPtr<string_type, string_adaptor> xpath = parser.compile(SA::construct_from_utf8("root/*"));
XPathValue<string_type, string_adaptor> result = xpath->evaluate(document_);
XPathExpression<string_type, string_adaptor> xpath = parser.compile(SA::construct_from_utf8("root/*"));
XPathValue<string_type, string_adaptor> result = xpath.evaluate(document_);
assertValuesEqual(NODE_SET, result.type());
assertValuesEqual(3, result.asNodeSet().size());
@ -214,8 +214,8 @@ public:
void test4()
{
using namespace Arabica::XPath;
XPathExpressionPtr<string_type, string_adaptor> xpath = parser.compile(SA::construct_from_utf8("root/*/text()"));
XPathValue<string_type, string_adaptor> result = xpath->evaluate(document_);
XPathExpression<string_type, string_adaptor> xpath = parser.compile(SA::construct_from_utf8("root/*/text()"));
XPathValue<string_type, string_adaptor> result = xpath.evaluate(document_);
assertValuesEqual(NODE_SET, result.type());
assertValuesEqual(1, result.asNodeSet().size());
@ -226,36 +226,36 @@ public:
void test5()
{
using namespace Arabica::XPath;
XPathExpressionPtr<string_type, string_adaptor> xpath = parser.compile(SA::construct_from_utf8("root/*/text()"));
assertTrue(text_.getNodeValue() == xpath->evaluateAsString(document_));
XPathExpression<string_type, string_adaptor> xpath = parser.compile(SA::construct_from_utf8("root/*/text()"));
assertTrue(text_.getNodeValue() == xpath.evaluateAsString(document_));
} // test5
void test6()
{
using namespace Arabica::XPath;
XPathExpressionPtr<string_type, string_adaptor> xpath = parser.compile(SA::construct_from_utf8("*"));
XPathExpression<string_type, string_adaptor> xpath = parser.compile(SA::construct_from_utf8("*"));
XPathValue<string_type, string_adaptor> result = xpath->evaluate(document_);
XPathValue<string_type, string_adaptor> result = xpath.evaluate(document_);
assertValuesEqual(NODE_SET, result.type());
assertValuesEqual(1, result.asNodeSet().size());
assertTrue(root_ == result.asNodeSet()[0]);
result = xpath->evaluate(root_);
result = xpath.evaluate(root_);
assertValuesEqual(NODE_SET, result.type());
assertValuesEqual(3, result.asNodeSet().size());
assertTrue(element1_ == result.asNodeSet()[0]);
assertTrue(element2_ == result.asNodeSet()[1]);
assertTrue(element3_ == result.asNodeSet()[2]);
result = xpath->evaluate(element1_);
result = xpath.evaluate(element1_);
assertValuesEqual(NODE_SET, result.type());
assertValuesEqual(0, result.asNodeSet().size());
result = xpath->evaluate(element2_);
result = xpath.evaluate(element2_);
assertValuesEqual(NODE_SET, result.type());
assertValuesEqual(1, result.asNodeSet().size());
result = xpath->evaluate(element3_);
result = xpath.evaluate(element3_);
assertValuesEqual(NODE_SET, result.type());
assertValuesEqual(0, result.asNodeSet().size());
} // test6
@ -263,14 +263,14 @@ public:
void test7()
{
using namespace Arabica::XPath;
XPathExpressionPtr<string_type, string_adaptor> xpath = parser.compile(SA::construct_from_utf8("/root"));
XPathExpression<string_type, string_adaptor> xpath = parser.compile(SA::construct_from_utf8("/root"));
XPathValue<string_type, string_adaptor> result = xpath->evaluate(document_);
XPathValue<string_type, string_adaptor> result = xpath.evaluate(document_);
assertValuesEqual(NODE_SET, result.type());
assertValuesEqual(1, result.asNodeSet().size());
assertTrue(root_ == result.asNodeSet()[0]);
result = xpath->evaluate(text_);
result = xpath.evaluate(text_);
assertValuesEqual(NODE_SET, result.type());
assertValuesEqual(1, result.asNodeSet().size());
assertTrue(root_ == result.asNodeSet()[0]);
@ -282,14 +282,14 @@ public:
StandardNamespaceContext<string_type, string_adaptor> nsContext;
nsContext.addNamespaceDeclaration(SA::construct_from_utf8("urn:something:or:other"), SA::construct_from_utf8("ns"));
parser.setNamespaceContext(nsContext);
XPathExpressionPtr<string_type, string_adaptor> xpath = parser.compile(SA::construct_from_utf8("/ns:root"));
XPathExpression<string_type, string_adaptor> xpath = parser.compile(SA::construct_from_utf8("/ns:root"));
parser.resetNamespaceContext();
XPathValue<string_type, string_adaptor> result = xpath->evaluate(document_);
XPathValue<string_type, string_adaptor> result = xpath.evaluate(document_);
assertValuesEqual(NODE_SET, result.type());
assertValuesEqual(0, result.asNodeSet().size());
result = xpath->evaluate(text_);
result = xpath.evaluate(text_);
assertValuesEqual(NODE_SET, result.type());
assertValuesEqual(0, result.asNodeSet().size());
} // test8
@ -297,15 +297,15 @@ public:
void test9()
{
using namespace Arabica::XPath;
XPathExpressionPtr<string_type, string_adaptor> xpath = parser.compile(SA::construct_from_utf8("child2"));
XPathExpression<string_type, string_adaptor> xpath = parser.compile(SA::construct_from_utf8("child2"));
XPathValue<string_type, string_adaptor> result = xpath->evaluate(root_);
XPathValue<string_type, string_adaptor> result = xpath.evaluate(root_);
assertValuesEqual(NODE_SET, result.type());
assertValuesEqual(1, result.asNodeSet().size());
assertTrue(element2_ == result.asNodeSet()[0]);
xpath = parser.compile(SA::construct_from_utf8("./child2"));
result = xpath->evaluate(root_);
result = xpath.evaluate(root_);
assertValuesEqual(NODE_SET, result.type());
assertValuesEqual(1, result.asNodeSet().size());
assertTrue(element2_ == result.asNodeSet()[0]);
@ -325,9 +325,9 @@ public:
void test11()
{
using namespace Arabica::XPath;
XPathExpressionPtr<string_type, string_adaptor> xpath = parser.compile(SA::construct_from_utf8(".."));
XPathExpression<string_type, string_adaptor> xpath = parser.compile(SA::construct_from_utf8(".."));
XPathValue<string_type, string_adaptor> result = xpath->evaluate(element3_);
XPathValue<string_type, string_adaptor> result = xpath.evaluate(element3_);
assertValuesEqual(NODE_SET, result.type());
assertValuesEqual(1, result.asNodeSet().size());
assertTrue(root_ == result.asNodeSet()[0]);
@ -336,8 +336,8 @@ public:
void test12()
{
using namespace Arabica::XPath;
XPathExpressionPtr<string_type, string_adaptor> xpath = parser.compile(SA::construct_from_utf8("root/*[2]"));
XPathValue<string_type, string_adaptor> result = xpath->evaluate(document_);
XPathExpression<string_type, string_adaptor> xpath = parser.compile(SA::construct_from_utf8("root/*[2]"));
XPathValue<string_type, string_adaptor> result = xpath.evaluate(document_);
assertValuesEqual(NODE_SET, result.type());
assertValuesEqual(1, result.asNodeSet().size());
@ -409,8 +409,8 @@ public:
void test19()
{
using namespace Arabica::XPath;
XPathExpressionPtr<string_type, string_adaptor> xpath = parser.compile(SA::construct_from_utf8("root/*[position() = 2]"));
XPathValue<string_type, string_adaptor> result = xpath->evaluate(document_);
XPathExpression<string_type, string_adaptor> xpath = parser.compile(SA::construct_from_utf8("root/*[position() = 2]"));
XPathValue<string_type, string_adaptor> result = xpath.evaluate(document_);
assertValuesEqual(NODE_SET, result.type());
assertValuesEqual(1, result.asNodeSet().size());
@ -421,8 +421,8 @@ public:
void test20()
{
using namespace Arabica::XPath;
XPathExpressionPtr<string_type, string_adaptor> xpath = parser.compile(SA::construct_from_utf8("root/*[last()]"));
XPathValue<string_type, string_adaptor> result = xpath->evaluate(document_);
XPathExpression<string_type, string_adaptor> xpath = parser.compile(SA::construct_from_utf8("root/*[last()]"));
XPathValue<string_type, string_adaptor> result = xpath.evaluate(document_);
assertValuesEqual(NODE_SET, result.type());
assertValuesEqual(1, result.asNodeSet().size());
@ -432,8 +432,8 @@ public:
void test21()
{
using namespace Arabica::XPath;
XPathExpressionPtr<string_type, string_adaptor> xpath = parser.compile(SA::construct_from_utf8("root/*[position() != last()]"));
XPathValue<string_type, string_adaptor> result = xpath->evaluate(document_);
XPathExpression<string_type, string_adaptor> xpath = parser.compile(SA::construct_from_utf8("root/*[position() != last()]"));
XPathValue<string_type, string_adaptor> result = xpath.evaluate(document_);
assertValuesEqual(NODE_SET, result.type());
assertValuesEqual(2, result.asNodeSet().size());
@ -444,8 +444,8 @@ public:
void test22()
{
using namespace Arabica::XPath;
XPathExpressionPtr<string_type, string_adaptor> xpath = parser.compile(SA::construct_from_utf8("root/*[position() = 2 or position() = 1]"));
XPathValue<string_type, string_adaptor> result = xpath->evaluate(document_);
XPathExpression<string_type, string_adaptor> xpath = parser.compile(SA::construct_from_utf8("root/*[position() = 2 or position() = 1]"));
XPathValue<string_type, string_adaptor> result = xpath.evaluate(document_);
assertValuesEqual(NODE_SET, result.type());
assertValuesEqual(2, result.asNodeSet().size());
@ -456,8 +456,8 @@ public:
void test23()
{
using namespace Arabica::XPath;
XPathExpressionPtr<string_type, string_adaptor> xpath = parser.compile(SA::construct_from_utf8("root/*[position() = 2 and @two = '1']"));
XPathValue<string_type, string_adaptor> result = xpath->evaluate(document_);
XPathExpression<string_type, string_adaptor> xpath = parser.compile(SA::construct_from_utf8("root/*[position() = 2 and @two = '1']"));
XPathValue<string_type, string_adaptor> result = xpath.evaluate(document_);
assertValuesEqual(NODE_SET, result.type());
assertValuesEqual(1, result.asNodeSet().size());
@ -467,8 +467,8 @@ public:
void test24()
{
using namespace Arabica::XPath;
XPathExpressionPtr<string_type, string_adaptor> xpath = parser.compile(SA::construct_from_utf8("root/*[last()][1]"));
XPathValue<string_type, string_adaptor> result = xpath->evaluate(document_);
XPathExpression<string_type, string_adaptor> xpath = parser.compile(SA::construct_from_utf8("root/*[last()][1]"));
XPathValue<string_type, string_adaptor> result = xpath.evaluate(document_);
assertValuesEqual(NODE_SET, result.type());
assertValuesEqual(1, result.asNodeSet().size());
@ -478,8 +478,8 @@ public:
void test25()
{
using namespace Arabica::XPath;
XPathExpressionPtr<string_type, string_adaptor> xpath = parser.compile(SA::construct_from_utf8("root/*[last()][2]"));
XPathValue<string_type, string_adaptor> result = xpath->evaluate(document_);
XPathExpression<string_type, string_adaptor> xpath = parser.compile(SA::construct_from_utf8("root/*[last()][2]"));
XPathValue<string_type, string_adaptor> result = xpath.evaluate(document_);
assertValuesEqual(NODE_SET, result.type());
assertValuesEqual(0, result.asNodeSet().size());
@ -488,8 +488,8 @@ public:
void test26()
{
using namespace Arabica::XPath;
XPathExpressionPtr<string_type, string_adaptor> xpath = parser.compile(SA::construct_from_utf8("/root/child2/spinkle/ancestor::node()[2]"));
XPathValue<string_type, string_adaptor> result = xpath->evaluate(document_);
XPathExpression<string_type, string_adaptor> xpath = parser.compile(SA::construct_from_utf8("/root/child2/spinkle/ancestor::node()[2]"));
XPathValue<string_type, string_adaptor> result = xpath.evaluate(document_);
assertValuesEqual(NODE_SET, result.type());
assertValuesEqual(1, result.asNodeSet().size());
@ -500,8 +500,8 @@ public:
void test27()
{
using namespace Arabica::XPath;
XPathExpressionPtr<string_type, string_adaptor> xpath = parser.compile(SA::construct_from_utf8("/root/child2/spinkle/ancestor-or-self::node()[2]"));
XPathValue<string_type, string_adaptor> result = xpath->evaluate(document_);
XPathExpression<string_type, string_adaptor> xpath = parser.compile(SA::construct_from_utf8("/root/child2/spinkle/ancestor-or-self::node()[2]"));
XPathValue<string_type, string_adaptor> result = xpath.evaluate(document_);
assertValuesEqual(NODE_SET, result.type());
assertValuesEqual(1, result.asNodeSet().size());
@ -512,8 +512,8 @@ public:
void test28()
{
using namespace Arabica::XPath;
XPathExpressionPtr<string_type, string_adaptor> xpath = parser.compile(SA::construct_from_utf8("/root/child2/spinkle/ancestor-or-self::node()[3]"));
XPathValue<string_type, string_adaptor> result = xpath->evaluate(document_);
XPathExpression<string_type, string_adaptor> xpath = parser.compile(SA::construct_from_utf8("/root/child2/spinkle/ancestor-or-self::node()[3]"));
XPathValue<string_type, string_adaptor> result = xpath.evaluate(document_);
assertValuesEqual(NODE_SET, result.type());
assertValuesEqual(1, result.asNodeSet().size());

View file

@ -95,14 +95,14 @@ public:
void testNode1()
{
using namespace Arabica::XPath;
XPathExpressionPtr<string_type, string_adaptor> xpath = parser.compile_expr(SA::construct_from_utf8("node()"));
XPathValue<string_type, string_adaptor> result = xpath->evaluate(document_);
XPathExpression<string_type, string_adaptor> xpath = parser.compile_expr(SA::construct_from_utf8("node()"));
XPathValue<string_type, string_adaptor> result = xpath.evaluate(document_);
assertValuesEqual(NODE_SET, result.type());
assertValuesEqual(1, result.asNodeSet().size());
assertTrue(root_ == result.asNodeSet()[0]);
result = xpath->evaluate(element2_);
result = xpath.evaluate(element2_);
assertValuesEqual(NODE_SET, result.type());
assertValuesEqual(4, result.asNodeSet().size());
} // testNode1

View file

@ -22,57 +22,57 @@ public:
void test1()
{
using namespace Arabica::XPath;
XPathExpressionPtr<string_type, string_adaptor> orTest(new impl::OrOperator<string_type, string_adaptor>(new BoolValue<string_type, string_adaptor>(false), new BoolValue<string_type, string_adaptor>(false)));
assertEquals(false, orTest->evaluateAsBool(dummy_));
XPathExpression<string_type, string_adaptor> orTest(new impl::OrOperator<string_type, string_adaptor>(new BoolValue<string_type, string_adaptor>(false), new BoolValue<string_type, string_adaptor>(false)));
assertEquals(false, orTest.evaluateAsBool(dummy_));
} // test1
void test2()
{
using namespace Arabica::XPath;
XPathExpressionPtr<string_type, string_adaptor> orTest(new impl::OrOperator<string_type, string_adaptor>(new BoolValue<string_type, string_adaptor>(false), new BoolValue<string_type, string_adaptor>(true)));
assertEquals(true, orTest->evaluateAsBool(dummy_));
XPathExpression<string_type, string_adaptor> orTest(new impl::OrOperator<string_type, string_adaptor>(new BoolValue<string_type, string_adaptor>(false), new BoolValue<string_type, string_adaptor>(true)));
assertEquals(true, orTest.evaluateAsBool(dummy_));
} // test2
void test3()
{
using namespace Arabica::XPath;
XPathExpressionPtr<string_type, string_adaptor> orTest(new impl::OrOperator<string_type, string_adaptor>(new BoolValue<string_type, string_adaptor>(true), new BoolValue<string_type, string_adaptor>(false)));
assertEquals(true, orTest->evaluateAsBool(dummy_));
XPathExpression<string_type, string_adaptor> orTest(new impl::OrOperator<string_type, string_adaptor>(new BoolValue<string_type, string_adaptor>(true), new BoolValue<string_type, string_adaptor>(false)));
assertEquals(true, orTest.evaluateAsBool(dummy_));
} // test3
void test4()
{
using namespace Arabica::XPath;
XPathExpressionPtr<string_type, string_adaptor> orTest(new impl::OrOperator<string_type, string_adaptor>(new BoolValue<string_type, string_adaptor>(true), new BoolValue<string_type, string_adaptor>(true)));
assertEquals(true, orTest->evaluateAsBool(dummy_));
XPathExpression<string_type, string_adaptor> orTest(new impl::OrOperator<string_type, string_adaptor>(new BoolValue<string_type, string_adaptor>(true), new BoolValue<string_type, string_adaptor>(true)));
assertEquals(true, orTest.evaluateAsBool(dummy_));
} // test4
void test5()
{
using namespace Arabica::XPath;
XPathExpressionPtr<string_type, string_adaptor> andTest(new impl::AndOperator<string_type, string_adaptor>(new BoolValue<string_type, string_adaptor>(false), new BoolValue<string_type, string_adaptor>(false)));
assertEquals(false, andTest->evaluateAsBool(dummy_));
XPathExpression<string_type, string_adaptor> andTest(new impl::AndOperator<string_type, string_adaptor>(new BoolValue<string_type, string_adaptor>(false), new BoolValue<string_type, string_adaptor>(false)));
assertEquals(false, andTest.evaluateAsBool(dummy_));
} // test5
void test6()
{
using namespace Arabica::XPath;
XPathExpressionPtr<string_type, string_adaptor> andTest(new impl::AndOperator<string_type, string_adaptor>(new BoolValue<string_type, string_adaptor>(false), new BoolValue<string_type, string_adaptor>(true)));
assertEquals(false, andTest->evaluateAsBool(dummy_));
XPathExpression<string_type, string_adaptor> andTest(new impl::AndOperator<string_type, string_adaptor>(new BoolValue<string_type, string_adaptor>(false), new BoolValue<string_type, string_adaptor>(true)));
assertEquals(false, andTest.evaluateAsBool(dummy_));
} // test6
void test7()
{
using namespace Arabica::XPath;
XPathExpressionPtr<string_type, string_adaptor> andTest(new impl::AndOperator<string_type, string_adaptor>(new BoolValue<string_type, string_adaptor>(true), new BoolValue<string_type, string_adaptor>(false)));
assertEquals(false, andTest->evaluateAsBool(dummy_));
XPathExpression<string_type, string_adaptor> andTest(new impl::AndOperator<string_type, string_adaptor>(new BoolValue<string_type, string_adaptor>(true), new BoolValue<string_type, string_adaptor>(false)));
assertEquals(false, andTest.evaluateAsBool(dummy_));
} // test7
void test8()
{
using namespace Arabica::XPath;
XPathExpressionPtr<string_type, string_adaptor> andTest(new impl::AndOperator<string_type, string_adaptor>(new BoolValue<string_type, string_adaptor>(true), new BoolValue<string_type, string_adaptor>(true)));
assertEquals(true, andTest->evaluateAsBool(dummy_));
XPathExpression<string_type, string_adaptor> andTest(new impl::AndOperator<string_type, string_adaptor>(new BoolValue<string_type, string_adaptor>(true), new BoolValue<string_type, string_adaptor>(true)));
assertEquals(true, andTest.evaluateAsBool(dummy_));
} // test8
private:

View file

@ -14,7 +14,7 @@ public:
virtual Arabica::XPath::XPathFunction<string_type, string_adaptor>* resolveFunction(
const string_type& namespace_uri,
const string_type& name,
const std::vector<Arabica::XPath::XPathExpressionPtr<string_type> >& argExprs) const
const std::vector<Arabica::XPath::XPathExpression<string_type> >& argExprs) const
{
if((namespace_uri == string_adaptor::construct_from_utf8("something")) &&
(name == string_adaptor::construct_from_utf8("true")))

View file

@ -22,29 +22,29 @@ public:
void test1()
{
using namespace Arabica::XPath;
XPathExpressionPtr<string_type, string_adaptor> equals1(new impl::EqualsOperator<string_type, string_adaptor>(new NumericValue<string_type, string_adaptor>(1), new NumericValue<string_type, string_adaptor>(1)));
XPathExpressionPtr<string_type, string_adaptor> equals2(new impl::EqualsOperator<string_type, string_adaptor>(new NumericValue<string_type, string_adaptor>(1), new NumericValue<string_type, string_adaptor>(1)));
XPathExpression<string_type, string_adaptor> equals1(new impl::EqualsOperator<string_type, string_adaptor>(new NumericValue<string_type, string_adaptor>(1), new NumericValue<string_type, string_adaptor>(1)));
XPathExpression<string_type, string_adaptor> equals2(new impl::EqualsOperator<string_type, string_adaptor>(new NumericValue<string_type, string_adaptor>(1), new NumericValue<string_type, string_adaptor>(1)));
assertEquals(true, equals1->evaluateAsBool(dummy_));
assertEquals(true, equals2->evaluateAsBool(dummy_));
assertEquals(true, equals1.evaluateAsBool(dummy_));
assertEquals(true, equals2.evaluateAsBool(dummy_));
} // test1
void test2()
{
using namespace Arabica::XPath;
XPathExpressionPtr<string_type, string_adaptor> equals1(new impl::EqualsOperator<string_type, string_adaptor>(new NumericValue<string_type, string_adaptor>(1), new NumericValue<string_type, string_adaptor>(2)));
XPathExpressionPtr<string_type, string_adaptor> equals2(new impl::EqualsOperator<string_type, string_adaptor>(new NumericValue<string_type, string_adaptor>(2), new NumericValue<string_type, string_adaptor>(1)));
XPathExpression<string_type, string_adaptor> equals1(new impl::EqualsOperator<string_type, string_adaptor>(new NumericValue<string_type, string_adaptor>(1), new NumericValue<string_type, string_adaptor>(2)));
XPathExpression<string_type, string_adaptor> equals2(new impl::EqualsOperator<string_type, string_adaptor>(new NumericValue<string_type, string_adaptor>(2), new NumericValue<string_type, string_adaptor>(1)));
assertEquals(false, equals1->evaluateAsBool(dummy_));
assertEquals(false, equals2->evaluateAsBool(dummy_));
assertEquals(false, equals1.evaluateAsBool(dummy_));
assertEquals(false, equals2.evaluateAsBool(dummy_));
} // test2
void test3()
{
using namespace Arabica::XPath;
XPathExpressionPtr<string_type, string_adaptor> equals1(new impl::EqualsOperator<string_type, string_adaptor>(new NumericValue<string_type, string_adaptor>(1), new NumericValue<string_type, string_adaptor>(1)));
XPathExpression<string_type, string_adaptor> equals1(new impl::EqualsOperator<string_type, string_adaptor>(new NumericValue<string_type, string_adaptor>(1), new NumericValue<string_type, string_adaptor>(1)));
assertEquals(true, equals1->evaluateAsBool(dummy_));
assertEquals(true, equals1.evaluateAsBool(dummy_));
} // test3
void test4()
@ -53,9 +53,9 @@ public:
XPathExpression_impl<string_type, string_adaptor>* p1 = new StringValue<string_type, string_adaptor>("charlie");
XPathExpression_impl<string_type, string_adaptor>* p2 = new StringValue<string_type, string_adaptor>("charlie");
XPathExpressionPtr<string_type, string_adaptor> equals1(new impl::EqualsOperator<string_type, string_adaptor>(p1, p2));
XPathExpression<string_type, string_adaptor> equals1(new impl::EqualsOperator<string_type, string_adaptor>(p1, p2));
assertEquals(true, equals1->evaluateAsBool(dummy_));
assertEquals(true, equals1.evaluateAsBool(dummy_));
} // test4
void test5()
@ -64,113 +64,113 @@ public:
XPathExpression_impl<string_type, string_adaptor>* p1 = new StringValue<string_type, string_adaptor>("trousers");
XPathExpression_impl<string_type, string_adaptor>* p2 = new StringValue<string_type, string_adaptor>("charlie");
XPathExpressionPtr<string_type, string_adaptor> equals1(new impl::EqualsOperator<string_type, string_adaptor>(p1, p2));
XPathExpression<string_type, string_adaptor> equals1(new impl::EqualsOperator<string_type, string_adaptor>(p1, p2));
assertEquals(false, equals1->evaluateAsBool(dummy_));
assertEquals(false, equals1.evaluateAsBool(dummy_));
} // test5
void test6()
{
using namespace Arabica::XPath;
XPathExpressionPtr<string_type, string_adaptor> equals1(new impl::EqualsOperator<string_type, string_adaptor>(new BoolValue<string_type, string_adaptor>(true), new BoolValue<string_type, string_adaptor>(true)));
XPathExpressionPtr<string_type, string_adaptor> equals2(new impl::EqualsOperator<string_type, string_adaptor>(new BoolValue<string_type, string_adaptor>(false), new BoolValue<string_type, string_adaptor>(false)));
XPathExpression<string_type, string_adaptor> equals1(new impl::EqualsOperator<string_type, string_adaptor>(new BoolValue<string_type, string_adaptor>(true), new BoolValue<string_type, string_adaptor>(true)));
XPathExpression<string_type, string_adaptor> equals2(new impl::EqualsOperator<string_type, string_adaptor>(new BoolValue<string_type, string_adaptor>(false), new BoolValue<string_type, string_adaptor>(false)));
assertEquals(true, equals1->evaluateAsBool(dummy_));
assertEquals(true, equals2->evaluateAsBool(dummy_));
assertEquals(true, equals1.evaluateAsBool(dummy_));
assertEquals(true, equals2.evaluateAsBool(dummy_));
} // test6
void test7()
{
using namespace Arabica::XPath;
XPathExpressionPtr<string_type, string_adaptor> equals1(new impl::EqualsOperator<string_type, string_adaptor>(new BoolValue<string_type, string_adaptor>(true), new BoolValue<string_type, string_adaptor>(false)));
XPathExpressionPtr<string_type, string_adaptor> equals2(new impl::EqualsOperator<string_type, string_adaptor>(new BoolValue<string_type, string_adaptor>(false), new BoolValue<string_type, string_adaptor>(true)));
XPathExpression<string_type, string_adaptor> equals1(new impl::EqualsOperator<string_type, string_adaptor>(new BoolValue<string_type, string_adaptor>(true), new BoolValue<string_type, string_adaptor>(false)));
XPathExpression<string_type, string_adaptor> equals2(new impl::EqualsOperator<string_type, string_adaptor>(new BoolValue<string_type, string_adaptor>(false), new BoolValue<string_type, string_adaptor>(true)));
assertEquals(false, equals1->evaluateAsBool(dummy_));
assertEquals(false, equals2->evaluateAsBool(dummy_));
assertEquals(false, equals1.evaluateAsBool(dummy_));
assertEquals(false, equals2.evaluateAsBool(dummy_));
} // test7
void testLessThan1()
{
using namespace Arabica::XPath;
XPathExpressionPtr<string_type, string_adaptor> lessThan1(new impl::LessThanOperator<string_type, string_adaptor>(new BoolValue<string_type, string_adaptor>(true), new BoolValue<string_type, string_adaptor>(true)));
XPathExpressionPtr<string_type, string_adaptor> lessThan2(new impl::LessThanOperator<string_type, string_adaptor>(new BoolValue<string_type, string_adaptor>(false), new BoolValue<string_type, string_adaptor>(false)));
XPathExpressionPtr<string_type, string_adaptor> lessThan3(new impl::LessThanOperator<string_type, string_adaptor>(new BoolValue<string_type, string_adaptor>(true), new BoolValue<string_type, string_adaptor>(false)));
XPathExpressionPtr<string_type, string_adaptor> lessThan4(new impl::LessThanOperator<string_type, string_adaptor>(new BoolValue<string_type, string_adaptor>(false), new BoolValue<string_type, string_adaptor>(true)));
XPathExpression<string_type, string_adaptor> lessThan1(new impl::LessThanOperator<string_type, string_adaptor>(new BoolValue<string_type, string_adaptor>(true), new BoolValue<string_type, string_adaptor>(true)));
XPathExpression<string_type, string_adaptor> lessThan2(new impl::LessThanOperator<string_type, string_adaptor>(new BoolValue<string_type, string_adaptor>(false), new BoolValue<string_type, string_adaptor>(false)));
XPathExpression<string_type, string_adaptor> lessThan3(new impl::LessThanOperator<string_type, string_adaptor>(new BoolValue<string_type, string_adaptor>(true), new BoolValue<string_type, string_adaptor>(false)));
XPathExpression<string_type, string_adaptor> lessThan4(new impl::LessThanOperator<string_type, string_adaptor>(new BoolValue<string_type, string_adaptor>(false), new BoolValue<string_type, string_adaptor>(true)));
assertEquals(false, lessThan1->evaluateAsBool(dummy_));
assertEquals(false, lessThan2->evaluateAsBool(dummy_));
assertEquals(false, lessThan3->evaluateAsBool(dummy_));
assertEquals(true, lessThan4->evaluateAsBool(dummy_));
assertEquals(false, lessThan1.evaluateAsBool(dummy_));
assertEquals(false, lessThan2.evaluateAsBool(dummy_));
assertEquals(false, lessThan3.evaluateAsBool(dummy_));
assertEquals(true, lessThan4.evaluateAsBool(dummy_));
} // testLessThan1
void testLessThan2()
{
using namespace Arabica::XPath;
XPathExpressionPtr<string_type, string_adaptor> lessThan1(new impl::LessThanOperator<string_type, string_adaptor>(new NumericValue<string_type, string_adaptor>(1.0), new NumericValue<string_type, string_adaptor>(1.0)));
XPathExpressionPtr<string_type, string_adaptor> lessThan2(new impl::LessThanOperator<string_type, string_adaptor>(new NumericValue<string_type, string_adaptor>(3.0), new NumericValue<string_type, string_adaptor>(2.0)));
XPathExpressionPtr<string_type, string_adaptor> lessThan3(new impl::LessThanOperator<string_type, string_adaptor>(new NumericValue<string_type, string_adaptor>(2.0), new NumericValue<string_type, string_adaptor>(3.0)));
XPathExpressionPtr<string_type, string_adaptor> lessThan4(new impl::LessThanOperator<string_type, string_adaptor>(new NumericValue<string_type, string_adaptor>(-1), new NumericValue<string_type, string_adaptor>(1)));
XPathExpression<string_type, string_adaptor> lessThan1(new impl::LessThanOperator<string_type, string_adaptor>(new NumericValue<string_type, string_adaptor>(1.0), new NumericValue<string_type, string_adaptor>(1.0)));
XPathExpression<string_type, string_adaptor> lessThan2(new impl::LessThanOperator<string_type, string_adaptor>(new NumericValue<string_type, string_adaptor>(3.0), new NumericValue<string_type, string_adaptor>(2.0)));
XPathExpression<string_type, string_adaptor> lessThan3(new impl::LessThanOperator<string_type, string_adaptor>(new NumericValue<string_type, string_adaptor>(2.0), new NumericValue<string_type, string_adaptor>(3.0)));
XPathExpression<string_type, string_adaptor> lessThan4(new impl::LessThanOperator<string_type, string_adaptor>(new NumericValue<string_type, string_adaptor>(-1), new NumericValue<string_type, string_adaptor>(1)));
assertEquals(false, lessThan1->evaluateAsBool(dummy_));
assertEquals(false, lessThan2->evaluateAsBool(dummy_));
assertEquals(true, lessThan3->evaluateAsBool(dummy_));
assertEquals(true, lessThan4->evaluateAsBool(dummy_));
assertEquals(false, lessThan1.evaluateAsBool(dummy_));
assertEquals(false, lessThan2.evaluateAsBool(dummy_));
assertEquals(true, lessThan3.evaluateAsBool(dummy_));
assertEquals(true, lessThan4.evaluateAsBool(dummy_));
} // testLessThan2
void testLessThan3()
{
using namespace Arabica::XPath;
XPathExpressionPtr<string_type, string_adaptor> lessThan1(new impl::LessThanOperator<string_type, string_adaptor>(new StringValue<string_type, string_adaptor>("1.0"), new StringValue<string_type, string_adaptor>("1.0")));
XPathExpressionPtr<string_type, string_adaptor> lessThan2(new impl::LessThanOperator<string_type, string_adaptor>(new StringValue<string_type, string_adaptor>("3.0"), new StringValue<string_type, string_adaptor>("2.0")));
XPathExpressionPtr<string_type, string_adaptor> lessThan3(new impl::LessThanOperator<string_type, string_adaptor>(new StringValue<string_type, string_adaptor>("2.0"), new StringValue<string_type, string_adaptor>("3.0")));
XPathExpressionPtr<string_type, string_adaptor> lessThan4(new impl::LessThanOperator<string_type, string_adaptor>(new StringValue<string_type, string_adaptor>("-1"), new StringValue<string_type, string_adaptor>("1")));
XPathExpression<string_type, string_adaptor> lessThan1(new impl::LessThanOperator<string_type, string_adaptor>(new StringValue<string_type, string_adaptor>("1.0"), new StringValue<string_type, string_adaptor>("1.0")));
XPathExpression<string_type, string_adaptor> lessThan2(new impl::LessThanOperator<string_type, string_adaptor>(new StringValue<string_type, string_adaptor>("3.0"), new StringValue<string_type, string_adaptor>("2.0")));
XPathExpression<string_type, string_adaptor> lessThan3(new impl::LessThanOperator<string_type, string_adaptor>(new StringValue<string_type, string_adaptor>("2.0"), new StringValue<string_type, string_adaptor>("3.0")));
XPathExpression<string_type, string_adaptor> lessThan4(new impl::LessThanOperator<string_type, string_adaptor>(new StringValue<string_type, string_adaptor>("-1"), new StringValue<string_type, string_adaptor>("1")));
assertEquals(false, lessThan1->evaluateAsBool(dummy_));
assertEquals(false, lessThan2->evaluateAsBool(dummy_));
assertEquals(true, lessThan3->evaluateAsBool(dummy_));
assertEquals(true, lessThan4->evaluateAsBool(dummy_));
assertEquals(false, lessThan1.evaluateAsBool(dummy_));
assertEquals(false, lessThan2.evaluateAsBool(dummy_));
assertEquals(true, lessThan3.evaluateAsBool(dummy_));
assertEquals(true, lessThan4.evaluateAsBool(dummy_));
} // testLessThan3
void testLessThanEquals1()
{
using namespace Arabica::XPath;
XPathExpressionPtr<string_type, string_adaptor> lessThanEquals1(new impl::LessThanEqualsOperator<string_type, string_adaptor>(new BoolValue<string_type, string_adaptor>(true), new BoolValue<string_type, string_adaptor>(true)));
XPathExpressionPtr<string_type, string_adaptor> lessThanEquals2(new impl::LessThanEqualsOperator<string_type, string_adaptor>(new BoolValue<string_type, string_adaptor>(false), new BoolValue<string_type, string_adaptor>(false)));
XPathExpressionPtr<string_type, string_adaptor> lessThanEquals3(new impl::LessThanEqualsOperator<string_type, string_adaptor>(new BoolValue<string_type, string_adaptor>(true), new BoolValue<string_type, string_adaptor>(false)));
XPathExpressionPtr<string_type, string_adaptor> lessThanEquals4(new impl::LessThanEqualsOperator<string_type, string_adaptor>(new BoolValue<string_type, string_adaptor>(false), new BoolValue<string_type, string_adaptor>(true)));
XPathExpression<string_type, string_adaptor> lessThanEquals1(new impl::LessThanEqualsOperator<string_type, string_adaptor>(new BoolValue<string_type, string_adaptor>(true), new BoolValue<string_type, string_adaptor>(true)));
XPathExpression<string_type, string_adaptor> lessThanEquals2(new impl::LessThanEqualsOperator<string_type, string_adaptor>(new BoolValue<string_type, string_adaptor>(false), new BoolValue<string_type, string_adaptor>(false)));
XPathExpression<string_type, string_adaptor> lessThanEquals3(new impl::LessThanEqualsOperator<string_type, string_adaptor>(new BoolValue<string_type, string_adaptor>(true), new BoolValue<string_type, string_adaptor>(false)));
XPathExpression<string_type, string_adaptor> lessThanEquals4(new impl::LessThanEqualsOperator<string_type, string_adaptor>(new BoolValue<string_type, string_adaptor>(false), new BoolValue<string_type, string_adaptor>(true)));
assertEquals(true, lessThanEquals1->evaluateAsBool(dummy_));
assertEquals(true, lessThanEquals2->evaluateAsBool(dummy_));
assertEquals(false, lessThanEquals3->evaluateAsBool(dummy_));
assertEquals(true, lessThanEquals4->evaluateAsBool(dummy_));
assertEquals(true, lessThanEquals1.evaluateAsBool(dummy_));
assertEquals(true, lessThanEquals2.evaluateAsBool(dummy_));
assertEquals(false, lessThanEquals3.evaluateAsBool(dummy_));
assertEquals(true, lessThanEquals4.evaluateAsBool(dummy_));
} // testLessThanEquals1
void testLessThanEquals2()
{
using namespace Arabica::XPath;
XPathExpressionPtr<string_type, string_adaptor> lessThanEquals1(new impl::LessThanEqualsOperator<string_type, string_adaptor>(new NumericValue<string_type, string_adaptor>(1.0), new NumericValue<string_type, string_adaptor>(1.0)));
XPathExpressionPtr<string_type, string_adaptor> lessThanEquals2(new impl::LessThanEqualsOperator<string_type, string_adaptor>(new NumericValue<string_type, string_adaptor>(3.0), new NumericValue<string_type, string_adaptor>(2.0)));
XPathExpressionPtr<string_type, string_adaptor> lessThanEquals3(new impl::LessThanEqualsOperator<string_type, string_adaptor>(new NumericValue<string_type, string_adaptor>(2.0), new NumericValue<string_type, string_adaptor>(3.0)));
XPathExpressionPtr<string_type, string_adaptor> lessThanEquals4(new impl::LessThanEqualsOperator<string_type, string_adaptor>(new NumericValue<string_type, string_adaptor>(-1), new NumericValue<string_type, string_adaptor>(1)));
XPathExpression<string_type, string_adaptor> lessThanEquals1(new impl::LessThanEqualsOperator<string_type, string_adaptor>(new NumericValue<string_type, string_adaptor>(1.0), new NumericValue<string_type, string_adaptor>(1.0)));
XPathExpression<string_type, string_adaptor> lessThanEquals2(new impl::LessThanEqualsOperator<string_type, string_adaptor>(new NumericValue<string_type, string_adaptor>(3.0), new NumericValue<string_type, string_adaptor>(2.0)));
XPathExpression<string_type, string_adaptor> lessThanEquals3(new impl::LessThanEqualsOperator<string_type, string_adaptor>(new NumericValue<string_type, string_adaptor>(2.0), new NumericValue<string_type, string_adaptor>(3.0)));
XPathExpression<string_type, string_adaptor> lessThanEquals4(new impl::LessThanEqualsOperator<string_type, string_adaptor>(new NumericValue<string_type, string_adaptor>(-1), new NumericValue<string_type, string_adaptor>(1)));
assertEquals(true, lessThanEquals1->evaluateAsBool(dummy_));
assertEquals(false, lessThanEquals2->evaluateAsBool(dummy_));
assertEquals(true, lessThanEquals3->evaluateAsBool(dummy_));
assertEquals(true, lessThanEquals4->evaluateAsBool(dummy_));
assertEquals(true, lessThanEquals1.evaluateAsBool(dummy_));
assertEquals(false, lessThanEquals2.evaluateAsBool(dummy_));
assertEquals(true, lessThanEquals3.evaluateAsBool(dummy_));
assertEquals(true, lessThanEquals4.evaluateAsBool(dummy_));
} // testLessThanEquals2
void testLessThanEquals3()
{
using namespace Arabica::XPath;
XPathExpressionPtr<string_type, string_adaptor> lessThanEquals1(new impl::LessThanEqualsOperator<string_type, string_adaptor>(new StringValue<string_type, string_adaptor>("1.0"), new StringValue<string_type, string_adaptor>("1.0")));
XPathExpressionPtr<string_type, string_adaptor> lessThanEquals2(new impl::LessThanEqualsOperator<string_type, string_adaptor>(new StringValue<string_type, string_adaptor>("3.0"), new StringValue<string_type, string_adaptor>("2.0")));
XPathExpressionPtr<string_type, string_adaptor> lessThanEquals3(new impl::LessThanEqualsOperator<string_type, string_adaptor>(new StringValue<string_type, string_adaptor>("2.0"), new StringValue<string_type, string_adaptor>("3.0")));
XPathExpressionPtr<string_type, string_adaptor> lessThanEquals4(new impl::LessThanEqualsOperator<string_type, string_adaptor>(new StringValue<string_type, string_adaptor>("-1"), new StringValue<string_type, string_adaptor>("1")));
XPathExpression<string_type, string_adaptor> lessThanEquals1(new impl::LessThanEqualsOperator<string_type, string_adaptor>(new StringValue<string_type, string_adaptor>("1.0"), new StringValue<string_type, string_adaptor>("1.0")));
XPathExpression<string_type, string_adaptor> lessThanEquals2(new impl::LessThanEqualsOperator<string_type, string_adaptor>(new StringValue<string_type, string_adaptor>("3.0"), new StringValue<string_type, string_adaptor>("2.0")));
XPathExpression<string_type, string_adaptor> lessThanEquals3(new impl::LessThanEqualsOperator<string_type, string_adaptor>(new StringValue<string_type, string_adaptor>("2.0"), new StringValue<string_type, string_adaptor>("3.0")));
XPathExpression<string_type, string_adaptor> lessThanEquals4(new impl::LessThanEqualsOperator<string_type, string_adaptor>(new StringValue<string_type, string_adaptor>("-1"), new StringValue<string_type, string_adaptor>("1")));
assertEquals(true, lessThanEquals1->evaluateAsBool(dummy_));
assertEquals(false, lessThanEquals2->evaluateAsBool(dummy_));
assertEquals(true, lessThanEquals3->evaluateAsBool(dummy_));
assertEquals(true, lessThanEquals4->evaluateAsBool(dummy_));
assertEquals(true, lessThanEquals1.evaluateAsBool(dummy_));
assertEquals(false, lessThanEquals2.evaluateAsBool(dummy_));
assertEquals(true, lessThanEquals3.evaluateAsBool(dummy_));
assertEquals(true, lessThanEquals4.evaluateAsBool(dummy_));
} // testLessThanEquals3
private:

View file

@ -56,9 +56,9 @@ public:
void test1()
{
using namespace Arabica::XPath;
XPathExpressionPtr<string_type, string_adaptor> step(new impl::TestStepExpression<string_type, string_adaptor>(CHILD, new impl::AnyNodeTest<string_type, string_adaptor>()));
XPathExpression<string_type, string_adaptor> step(new impl::TestStepExpression<string_type, string_adaptor>(CHILD, new impl::AnyNodeTest<string_type, string_adaptor>()));
XPathValue<string_type, string_adaptor> value = step->evaluate(root_);
XPathValue<string_type, string_adaptor> value = step.evaluate(root_);
const NodeSet<string_type, string_adaptor>& set = value.asNodeSet();
assertEquals(set.size(), 3);
@ -70,9 +70,9 @@ public:
void test2()
{
using namespace Arabica::XPath;
XPathExpressionPtr<string_type, string_adaptor> step(new impl::TestStepExpression<string_type, string_adaptor>(ATTRIBUTE, new impl::AnyNodeTest<string_type, string_adaptor>()));
XPathExpression<string_type, string_adaptor> step(new impl::TestStepExpression<string_type, string_adaptor>(ATTRIBUTE, new impl::AnyNodeTest<string_type, string_adaptor>()));
NodeSet<string_type, string_adaptor> set = step->evaluateAsNodeSet(element2_);
NodeSet<string_type, string_adaptor> set = step.evaluateAsNodeSet(element2_);
assertEquals(4, set.size());
Arabica::DOM::Attr<string_type, string_adaptor> attr = static_cast<Arabica::DOM::Attr<string_type, string_adaptor> >(set[0]);
@ -88,10 +88,10 @@ public:
void test3()
{
using namespace Arabica::XPath;
XPathExpressionPtr<string_type, string_adaptor> step(new impl::TestStepExpression<string_type,
XPathExpression<string_type, string_adaptor> step(new impl::TestStepExpression<string_type,
string_adaptor>(CHILD, new impl::NameNodeTest<string_type, string_adaptor>(SA::construct_from_utf8("child2"))));
XPathValue<string_type, string_adaptor> value = step->evaluate(root_);
XPathValue<string_type, string_adaptor> value = step.evaluate(root_);
const NodeSet<string_type, string_adaptor>& set = value.asNodeSet();
assertEquals(1, set.size());

View file

@ -26,147 +26,147 @@ public:
void test1()
{
using namespace Arabica::XPath;
XPathExpressionPtr<string_type, string_adaptor> b(new BoolValue<string_type, string_adaptor>(true));
assertEquals(true, b->evaluateAsBool(dummy_));
assertEquals(1.0, b->evaluateAsNumber(dummy_), 0.0);
assertTrue(SA::construct_from_utf8("true") == b->evaluateAsString(dummy_));
XPathExpression<string_type, string_adaptor> b(new BoolValue<string_type, string_adaptor>(true));
assertEquals(true, b.evaluateAsBool(dummy_));
assertEquals(1.0, b.evaluateAsNumber(dummy_), 0.0);
assertTrue(SA::construct_from_utf8("true") == b.evaluateAsString(dummy_));
}
void test2()
{
using namespace Arabica::XPath;
XPathExpressionPtr<string_type, string_adaptor> b2(new BoolValue<string_type, string_adaptor>(false));
assertEquals(false, b2->evaluateAsBool(dummy_));
assertEquals(0.0, b2->evaluateAsNumber(dummy_), 0.0);
assertTrue(SA::construct_from_utf8("false") == b2->evaluateAsString(dummy_));
XPathExpression<string_type, string_adaptor> b2(new BoolValue<string_type, string_adaptor>(false));
assertEquals(false, b2.evaluateAsBool(dummy_));
assertEquals(0.0, b2.evaluateAsNumber(dummy_), 0.0);
assertTrue(SA::construct_from_utf8("false") == b2.evaluateAsString(dummy_));
} // test2
void test3()
{
using namespace Arabica::XPath;
XPathExpressionPtr<string_type, string_adaptor> n(new NumericValue<string_type, string_adaptor>(99.5));
assertEquals(true, n->evaluateAsBool(dummy_));
assertEquals(99.5, n->evaluateAsNumber(dummy_), 0.0);
assertTrue(SA::construct_from_utf8("99.5") == n->evaluateAsString(dummy_));
XPathExpression<string_type, string_adaptor> n(new NumericValue<string_type, string_adaptor>(99.5));
assertEquals(true, n.evaluateAsBool(dummy_));
assertEquals(99.5, n.evaluateAsNumber(dummy_), 0.0);
assertTrue(SA::construct_from_utf8("99.5") == n.evaluateAsString(dummy_));
}
void test4()
{
using namespace Arabica::XPath;
XPathExpressionPtr<string_type, string_adaptor> n(new NumericValue<string_type, string_adaptor>(0.0));
assertEquals(false, n->evaluateAsBool(dummy_));
assertEquals(0, n->evaluateAsNumber(dummy_), 0);
assertTrue(SA::construct_from_utf8("0") == n->evaluateAsString(dummy_));
XPathExpression<string_type, string_adaptor> n(new NumericValue<string_type, string_adaptor>(0.0));
assertEquals(false, n.evaluateAsBool(dummy_));
assertEquals(0, n.evaluateAsNumber(dummy_), 0);
assertTrue(SA::construct_from_utf8("0") == n.evaluateAsString(dummy_));
}
void test5()
{
using namespace Arabica::XPath;
XPathExpressionPtr<string_type, string_adaptor> s(new StringValue<string_type, string_adaptor>("hello"));
assertEquals(true, s->evaluateAsBool(dummy_));
assertTrue(SA::construct_from_utf8("hello") == s->evaluateAsString(dummy_));
XPathExpression<string_type, string_adaptor> s(new StringValue<string_type, string_adaptor>("hello"));
assertEquals(true, s.evaluateAsBool(dummy_));
assertTrue(SA::construct_from_utf8("hello") == s.evaluateAsString(dummy_));
} // test5
void test6()
{
using namespace Arabica::XPath;
XPathExpressionPtr<string_type, string_adaptor> s(new StringValue<string_type, string_adaptor>(""));
assertEquals(false, s->evaluateAsBool(dummy_));
XPathExpression<string_type, string_adaptor> s(new StringValue<string_type, string_adaptor>(""));
assertEquals(false, s.evaluateAsBool(dummy_));
}
void test7()
{
using namespace Arabica::XPath;
XPathExpressionPtr<string_type, string_adaptor> s(new StringValue<string_type, string_adaptor>("100"));
assertEquals(true, s->evaluateAsBool(dummy_));
assertEquals(100.0, s->evaluateAsNumber(dummy_), 0.0);
assertTrue(SA::construct_from_utf8("100") == s->evaluateAsString(dummy_));
XPathExpression<string_type, string_adaptor> s(new StringValue<string_type, string_adaptor>("100"));
assertEquals(true, s.evaluateAsBool(dummy_));
assertEquals(100.0, s.evaluateAsNumber(dummy_), 0.0);
assertTrue(SA::construct_from_utf8("100") == s.evaluateAsString(dummy_));
} // test7
void test8()
{
using namespace Arabica::XPath;
XPathExpressionPtr<string_type, string_adaptor> s(new StringValue<string_type, string_adaptor>("0"));
assertEquals(true, s->evaluateAsBool(dummy_));
assertEquals(0.0, s->evaluateAsNumber(dummy_), 0.0);
assertTrue(SA::construct_from_utf8("0") == s->evaluateAsString(dummy_));
XPathExpression<string_type, string_adaptor> s(new StringValue<string_type, string_adaptor>("0"));
assertEquals(true, s.evaluateAsBool(dummy_));
assertEquals(0.0, s.evaluateAsNumber(dummy_), 0.0);
assertTrue(SA::construct_from_utf8("0") == s.evaluateAsString(dummy_));
} // test8
void test9()
{
using namespace Arabica::XPath;
XPathExpressionPtr<string_type, string_adaptor> bt(new BoolValue<string_type, string_adaptor>(true));
XPathExpressionPtr<string_type, string_adaptor> st(new StringValue<string_type, string_adaptor>("true"));
XPathExpressionPtr<string_type, string_adaptor> bf(new BoolValue<string_type, string_adaptor>(false));
XPathExpressionPtr<string_type, string_adaptor> sf(new StringValue<string_type, string_adaptor>(""));
XPathExpression<string_type, string_adaptor> bt(new BoolValue<string_type, string_adaptor>(true));
XPathExpression<string_type, string_adaptor> st(new StringValue<string_type, string_adaptor>("true"));
XPathExpression<string_type, string_adaptor> bf(new BoolValue<string_type, string_adaptor>(false));
XPathExpression<string_type, string_adaptor> sf(new StringValue<string_type, string_adaptor>(""));
assertTrue((impl::areEqual<string_type, string_adaptor>(bt->evaluate(dummy_), (st->evaluate(dummy_)))));
assertTrue((impl::areEqual<string_type, string_adaptor>(st->evaluate(dummy_), (bt->evaluate(dummy_)))));
assertTrue((impl::areEqual<string_type, string_adaptor>(bt.evaluate(dummy_), (st.evaluate(dummy_)))));
assertTrue((impl::areEqual<string_type, string_adaptor>(st.evaluate(dummy_), (bt.evaluate(dummy_)))));
assertTrue((impl::areEqual<string_type, string_adaptor>(sf->evaluate(dummy_), (bf->evaluate(dummy_)))));
assertTrue((impl::areEqual<string_type, string_adaptor>(bf->evaluate(dummy_), (sf->evaluate(dummy_)))));
assertTrue((impl::areEqual<string_type, string_adaptor>(sf.evaluate(dummy_), (bf.evaluate(dummy_)))));
assertTrue((impl::areEqual<string_type, string_adaptor>(bf.evaluate(dummy_), (sf.evaluate(dummy_)))));
assertTrue((impl::areEqual<string_type, string_adaptor>(bt->evaluate(dummy_), (bt->evaluate(dummy_)))));
assertTrue((impl::areEqual<string_type, string_adaptor>(bf->evaluate(dummy_), (bf->evaluate(dummy_)))));
assertTrue((impl::areEqual<string_type, string_adaptor>(st->evaluate(dummy_), (st->evaluate(dummy_)))));
assertTrue((impl::areEqual<string_type, string_adaptor>(sf->evaluate(dummy_), (sf->evaluate(dummy_)))));
assertTrue((impl::areEqual<string_type, string_adaptor>(bt.evaluate(dummy_), (bt.evaluate(dummy_)))));
assertTrue((impl::areEqual<string_type, string_adaptor>(bf.evaluate(dummy_), (bf.evaluate(dummy_)))));
assertTrue((impl::areEqual<string_type, string_adaptor>(st.evaluate(dummy_), (st.evaluate(dummy_)))));
assertTrue((impl::areEqual<string_type, string_adaptor>(sf.evaluate(dummy_), (sf.evaluate(dummy_)))));
} // test9
void test10()
{
using namespace Arabica::XPath;
XPathExpressionPtr<string_type, string_adaptor> bt(new BoolValue<string_type, string_adaptor>(true));
XPathExpressionPtr<string_type, string_adaptor> nt(new NumericValue<string_type, string_adaptor>(1.0));
XPathExpressionPtr<string_type, string_adaptor> bf(new BoolValue<string_type, string_adaptor>(false));
XPathExpressionPtr<string_type, string_adaptor> nf(new NumericValue<string_type, string_adaptor>(0.0));
XPathExpression<string_type, string_adaptor> bt(new BoolValue<string_type, string_adaptor>(true));
XPathExpression<string_type, string_adaptor> nt(new NumericValue<string_type, string_adaptor>(1.0));
XPathExpression<string_type, string_adaptor> bf(new BoolValue<string_type, string_adaptor>(false));
XPathExpression<string_type, string_adaptor> nf(new NumericValue<string_type, string_adaptor>(0.0));
assertTrue((impl::areEqual<string_type, string_adaptor>(bt->evaluate(dummy_), (nt->evaluate(dummy_)))));
assertTrue((impl::areEqual<string_type, string_adaptor>(nt->evaluate(dummy_), (bt->evaluate(dummy_)))));
assertTrue((impl::areEqual<string_type, string_adaptor>(bt.evaluate(dummy_), (nt.evaluate(dummy_)))));
assertTrue((impl::areEqual<string_type, string_adaptor>(nt.evaluate(dummy_), (bt.evaluate(dummy_)))));
assertTrue((impl::areEqual<string_type, string_adaptor>(bf->evaluate(dummy_), (nf->evaluate(dummy_)))));
assertTrue((impl::areEqual<string_type, string_adaptor>(nf->evaluate(dummy_), (bf->evaluate(dummy_)))));
assertTrue((impl::areEqual<string_type, string_adaptor>(bf.evaluate(dummy_), (nf.evaluate(dummy_)))));
assertTrue((impl::areEqual<string_type, string_adaptor>(nf.evaluate(dummy_), (bf.evaluate(dummy_)))));
} // test10
void test11()
{
using namespace Arabica::XPath;
XPathExpressionPtr<string_type, string_adaptor> nt(new NumericValue<string_type, string_adaptor>(1.0));
XPathValue<string_type, string_adaptor> ns = nt->evaluate(dummy_);
XPathExpression<string_type, string_adaptor> nt(new NumericValue<string_type, string_adaptor>(1.0));
XPathValue<string_type, string_adaptor> ns = nt.evaluate(dummy_);
assertTrue((impl::areEqual<string_type, string_adaptor>(ns, (nt->evaluate(dummy_)))));
assertTrue((impl::areEqual<string_type, string_adaptor>(ns, (nt.evaluate(dummy_)))));
} // test11
void test12()
{
using namespace Arabica::XPath;
XPathExpressionPtr<string_type, string_adaptor> n(new NumericValue<string_type, string_adaptor>(NaN));
assertEquals(false, n->evaluateAsBool(dummy_));
assertTrue(isNaN(n->evaluateAsNumber(dummy_)));
assertTrue(SA::construct_from_utf8("NaN") == n->evaluateAsString(dummy_));
XPathExpression<string_type, string_adaptor> n(new NumericValue<string_type, string_adaptor>(NaN));
assertEquals(false, n.evaluateAsBool(dummy_));
assertTrue(isNaN(n.evaluateAsNumber(dummy_)));
assertTrue(SA::construct_from_utf8("NaN") == n.evaluateAsString(dummy_));
}
void test13()
{
using namespace Arabica::XPath;
XPathExpressionPtr<string_type, string_adaptor> s(new StringValue<string_type, string_adaptor>(" 100 "));
assertEquals(true, s->evaluateAsBool(dummy_));
assertEquals(100.0, s->evaluateAsNumber(dummy_), 0.0);
XPathExpression<string_type, string_adaptor> s(new StringValue<string_type, string_adaptor>(" 100 "));
assertEquals(true, s.evaluateAsBool(dummy_));
assertEquals(100.0, s.evaluateAsNumber(dummy_), 0.0);
} // test13
void test14()
{
using namespace Arabica::XPath;
XPathExpressionPtr<string_type, string_adaptor> s(new StringValue<string_type, string_adaptor>(" -100 "));
assertEquals(true, s->evaluateAsBool(dummy_));
assertEquals(-100.0, s->evaluateAsNumber(dummy_), 0.0);
XPathExpression<string_type, string_adaptor> s(new StringValue<string_type, string_adaptor>(" -100 "));
assertEquals(true, s.evaluateAsBool(dummy_));
assertEquals(-100.0, s.evaluateAsNumber(dummy_), 0.0);
} // test14
void test15()
{
using namespace Arabica::XPath;
XPathExpressionPtr<string_type, string_adaptor> s(new StringValue<string_type, string_adaptor>("trousers"));
assertEquals(true, s->evaluateAsBool(dummy_));
assertTrue(isNaN(s->evaluateAsNumber(dummy_)));
XPathExpression<string_type, string_adaptor> s(new StringValue<string_type, string_adaptor>("trousers"));
assertEquals(true, s.evaluateAsBool(dummy_));
assertTrue(isNaN(s.evaluateAsNumber(dummy_)));
} // test15
}; // ValueTest