added type() to XPath expressions. I need this to allow XSLT match patterns to be rewritten properly - see http://www.jezuk.co.uk/cgi-bin/view/arabica/log?id=3546 - but it will also be useful for compile time checking (should I get sufficiently keen :)

This commit is contained in:
jez 2007-12-18 23:03:16 +00:00
parent fc982bf8e8
commit cdac22542e
12 changed files with 111 additions and 1 deletions

View file

@ -19,6 +19,8 @@ public:
PlusOperator(XPathExpression_impl<string_type, string_adaptor>* lhs, XPathExpression_impl<string_type, string_adaptor>* rhs) : PlusOperator(XPathExpression_impl<string_type, string_adaptor>* lhs, XPathExpression_impl<string_type, string_adaptor>* rhs) :
BinaryExpression<string_type, string_adaptor>(lhs, rhs) { } BinaryExpression<string_type, string_adaptor>(lhs, rhs) { }
virtual ValueType type() const { return NUMBER; }
virtual XPathValue<string_type, string_adaptor> evaluate(const DOM::Node<string_type, string_adaptor>& context, virtual XPathValue<string_type, string_adaptor> evaluate(const DOM::Node<string_type, string_adaptor>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const const ExecutionContext<string_type, string_adaptor>& executionContext) const
{ {
@ -35,6 +37,8 @@ public:
MinusOperator(XPathExpression_impl<string_type, string_adaptor>* lhs, XPathExpression_impl<string_type, string_adaptor>* rhs) : MinusOperator(XPathExpression_impl<string_type, string_adaptor>* lhs, XPathExpression_impl<string_type, string_adaptor>* rhs) :
BinaryExpression<string_type, string_adaptor>(lhs, rhs) { } BinaryExpression<string_type, string_adaptor>(lhs, rhs) { }
virtual ValueType type() const { return NUMBER; }
virtual XPathValue<string_type, string_adaptor> evaluate(const DOM::Node<string_type, string_adaptor>& context, virtual XPathValue<string_type, string_adaptor> evaluate(const DOM::Node<string_type, string_adaptor>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const const ExecutionContext<string_type, string_adaptor>& executionContext) const
{ {
@ -51,6 +55,8 @@ public:
MultiplyOperator(XPathExpression_impl<string_type, string_adaptor>* lhs, XPathExpression_impl<string_type, string_adaptor>* rhs) : MultiplyOperator(XPathExpression_impl<string_type, string_adaptor>* lhs, XPathExpression_impl<string_type, string_adaptor>* rhs) :
BinaryExpression<string_type, string_adaptor>(lhs, rhs) { } BinaryExpression<string_type, string_adaptor>(lhs, rhs) { }
virtual ValueType type() const { return NUMBER; }
virtual XPathValue<string_type, string_adaptor> evaluate(const DOM::Node<string_type, string_adaptor>& context, virtual XPathValue<string_type, string_adaptor> evaluate(const DOM::Node<string_type, string_adaptor>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const const ExecutionContext<string_type, string_adaptor>& executionContext) const
{ {
@ -67,6 +73,8 @@ public:
DivideOperator(XPathExpression_impl<string_type, string_adaptor>* lhs, XPathExpression_impl<string_type, string_adaptor>* rhs) : DivideOperator(XPathExpression_impl<string_type, string_adaptor>* lhs, XPathExpression_impl<string_type, string_adaptor>* rhs) :
BinaryExpression<string_type, string_adaptor>(lhs, rhs) { } BinaryExpression<string_type, string_adaptor>(lhs, rhs) { }
virtual ValueType type() const { return NUMBER; }
virtual XPathValue<string_type, string_adaptor> evaluate(const DOM::Node<string_type, string_adaptor>& context, virtual XPathValue<string_type, string_adaptor> evaluate(const DOM::Node<string_type, string_adaptor>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const const ExecutionContext<string_type, string_adaptor>& executionContext) const
{ {
@ -83,6 +91,8 @@ public:
ModOperator(XPathExpression_impl<string_type, string_adaptor>* lhs, XPathExpression_impl<string_type, string_adaptor>* rhs) : ModOperator(XPathExpression_impl<string_type, string_adaptor>* lhs, XPathExpression_impl<string_type, string_adaptor>* rhs) :
BinaryExpression<string_type, string_adaptor>(lhs, rhs) { } BinaryExpression<string_type, string_adaptor>(lhs, rhs) { }
virtual ValueType type() const { return NUMBER; }
virtual XPathValue<string_type, string_adaptor> evaluate(const DOM::Node<string_type, string_adaptor>& context, virtual XPathValue<string_type, string_adaptor> evaluate(const DOM::Node<string_type, string_adaptor>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const const ExecutionContext<string_type, string_adaptor>& executionContext) const
{ {
@ -104,6 +114,8 @@ public:
UnaryNegative(XPathExpression_impl<string_type, string_adaptor>* expr) : UnaryNegative(XPathExpression_impl<string_type, string_adaptor>* expr) :
UnaryExpression<string_type, string_adaptor>(expr) { } UnaryExpression<string_type, string_adaptor>(expr) { }
virtual ValueType type() const { return NUMBER; }
virtual XPathValue<string_type, string_adaptor> evaluate(const DOM::Node<string_type, string_adaptor>& context, virtual XPathValue<string_type, string_adaptor> evaluate(const DOM::Node<string_type, string_adaptor>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const const ExecutionContext<string_type, string_adaptor>& executionContext) const
{ {

View file

@ -20,6 +20,8 @@ protected:
public: public:
virtual ~XPathExpression_impl() { } virtual ~XPathExpression_impl() { }
virtual ValueType type() const = 0;
XPathValue<string_type, string_adaptor> evaluate(const DOM::Node<string_type, string_adaptor>& context) const XPathValue<string_type, string_adaptor> evaluate(const DOM::Node<string_type, string_adaptor>& context) const
{ {
ExecutionContext<string_type, string_adaptor> executionContext; ExecutionContext<string_type, string_adaptor> executionContext;
@ -65,6 +67,8 @@ public:
return *this; return *this;
} // operator= } // operator=
ValueType type() const { return ptr_->type(); }
const XPathExpression_impl<string_type, string_adaptor>* get() const { return ptr_.get(); } const XPathExpression_impl<string_type, string_adaptor>* get() const { return ptr_.get(); }
operator bool() const { return ptr_.get(); } operator bool() const { return ptr_.get(); }

View file

@ -29,6 +29,8 @@ protected:
public: public:
virtual ~XPathFunction() { } virtual ~XPathFunction() { }
virtual ValueType type() const = 0;
virtual XPathValue_impl<string_type, string_adaptor>* evaluate(const DOM::Node<string_type, string_adaptor>& context, virtual XPathValue_impl<string_type, string_adaptor>* evaluate(const DOM::Node<string_type, string_adaptor>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const = 0; const ExecutionContext<string_type, string_adaptor>& executionContext) const = 0;
@ -85,6 +87,8 @@ class LastFn : public XPathFunction<string_type, string_adaptor>
public: public:
LastFn(const std::vector<XPathExpression<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 ValueType type() const { return NUMBER; }
virtual XPathValue_impl<string_type, string_adaptor>* evaluate(const DOM::Node<string_type, string_adaptor>& context, virtual XPathValue_impl<string_type, string_adaptor>* evaluate(const DOM::Node<string_type, string_adaptor>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const const ExecutionContext<string_type, string_adaptor>& executionContext) const
{ {
@ -99,6 +103,8 @@ class PositionFn : public XPathFunction<string_type, string_adaptor>
public: public:
PositionFn(const std::vector<XPathExpression<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 ValueType type() const { return NUMBER; }
virtual XPathValue_impl<string_type, string_adaptor>* evaluate(const DOM::Node<string_type, string_adaptor>& context, virtual XPathValue_impl<string_type, string_adaptor>* evaluate(const DOM::Node<string_type, string_adaptor>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const const ExecutionContext<string_type, string_adaptor>& executionContext) const
{ {
@ -114,6 +120,8 @@ class CountFn : public XPathFunction<string_type, string_adaptor>
public: public:
CountFn(const std::vector<XPathExpression<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 ValueType type() const { return NUMBER; }
virtual XPathValue_impl<string_type, string_adaptor>* evaluate(const DOM::Node<string_type, string_adaptor>& context, virtual XPathValue_impl<string_type, string_adaptor>* evaluate(const DOM::Node<string_type, string_adaptor>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const const ExecutionContext<string_type, string_adaptor>& executionContext) const
{ {
@ -130,6 +138,8 @@ class LocalNameFn : public XPathFunction<string_type, string_adaptor>
public: public:
LocalNameFn(const std::vector<XPathExpression<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 ValueType type() const { return STRING; }
virtual XPathValue_impl<string_type, string_adaptor>* evaluate(const DOM::Node<string_type, string_adaptor>& context, virtual XPathValue_impl<string_type, string_adaptor>* evaluate(const DOM::Node<string_type, string_adaptor>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const const ExecutionContext<string_type, string_adaptor>& executionContext) const
{ {
@ -166,6 +176,8 @@ class NamespaceURIFn : public XPathFunction<string_type, string_adaptor>
public: public:
NamespaceURIFn(const std::vector<XPathExpression<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 ValueType type() const { return STRING; }
virtual XPathValue_impl<string_type, string_adaptor>* evaluate(const DOM::Node<string_type, string_adaptor>& context, virtual XPathValue_impl<string_type, string_adaptor>* evaluate(const DOM::Node<string_type, string_adaptor>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const const ExecutionContext<string_type, string_adaptor>& executionContext) const
{ {
@ -200,6 +212,8 @@ class NameFn : public XPathFunction<string_type, string_adaptor>
public: public:
NameFn(const std::vector<XPathExpression<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 ValueType type() const { return STRING; }
virtual XPathValue_impl<string_type, string_adaptor>* evaluate(const DOM::Node<string_type, string_adaptor>& context, virtual XPathValue_impl<string_type, string_adaptor>* evaluate(const DOM::Node<string_type, string_adaptor>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const const ExecutionContext<string_type, string_adaptor>& executionContext) const
{ {
@ -239,6 +253,8 @@ class StringFn : public XPathFunction<string_type, string_adaptor>
public: public:
StringFn(const std::vector<XPathExpression<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 ValueType type() const { return STRING; }
virtual XPathValue_impl<string_type, string_adaptor>* evaluate(const DOM::Node<string_type, string_adaptor>& context, virtual XPathValue_impl<string_type, string_adaptor>* evaluate(const DOM::Node<string_type, string_adaptor>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const const ExecutionContext<string_type, string_adaptor>& executionContext) const
{ {
@ -254,6 +270,8 @@ class ConcatFn : public XPathFunction<string_type, string_adaptor>
public: public:
ConcatFn(const std::vector<XPathExpression<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 ValueType type() const { return STRING; }
virtual XPathValue_impl<string_type, string_adaptor>* evaluate(const DOM::Node<string_type, string_adaptor>& context, virtual XPathValue_impl<string_type, string_adaptor>* evaluate(const DOM::Node<string_type, string_adaptor>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const const ExecutionContext<string_type, string_adaptor>& executionContext) const
{ {
@ -272,6 +290,8 @@ class StartsWithFn : public XPathFunction<string_type, string_adaptor>
public: public:
StartsWithFn(const std::vector<XPathExpression<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 ValueType type() const { return BOOL; }
virtual XPathValue_impl<string_type, string_adaptor>* evaluate(const DOM::Node<string_type, string_adaptor>& context, virtual XPathValue_impl<string_type, string_adaptor>* evaluate(const DOM::Node<string_type, string_adaptor>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const const ExecutionContext<string_type, string_adaptor>& executionContext) const
{ {
@ -300,6 +320,8 @@ class ContainsFn : public XPathFunction<string_type, string_adaptor>
public: public:
ContainsFn(const std::vector<XPathExpression<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 ValueType type() const { return BOOL; }
virtual XPathValue_impl<string_type, string_adaptor>* evaluate(const DOM::Node<string_type, string_adaptor>& context, virtual XPathValue_impl<string_type, string_adaptor>* evaluate(const DOM::Node<string_type, string_adaptor>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const const ExecutionContext<string_type, string_adaptor>& executionContext) const
{ {
@ -316,6 +338,8 @@ class SubstringBeforeFn : public XPathFunction<string_type, string_adaptor>
public: public:
SubstringBeforeFn(const std::vector<XPathExpression<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 ValueType type() const { return STRING; }
virtual XPathValue_impl<string_type, string_adaptor>* evaluate(const DOM::Node<string_type, string_adaptor>& context, virtual XPathValue_impl<string_type, string_adaptor>* evaluate(const DOM::Node<string_type, string_adaptor>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const const ExecutionContext<string_type, string_adaptor>& executionContext) const
{ {
@ -337,6 +361,8 @@ class SubstringAfterFn : public XPathFunction<string_type, string_adaptor>
public: public:
SubstringAfterFn(const std::vector<XPathExpression<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 ValueType type() const { return STRING; }
virtual XPathValue_impl<string_type, string_adaptor>* evaluate(const DOM::Node<string_type, string_adaptor>& context, virtual XPathValue_impl<string_type, string_adaptor>* evaluate(const DOM::Node<string_type, string_adaptor>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const const ExecutionContext<string_type, string_adaptor>& executionContext) const
{ {
@ -359,6 +385,8 @@ class SubstringFn : public XPathFunction<string_type, string_adaptor>
public: public:
SubstringFn(const std::vector<XPathExpression<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 ValueType type() const { return STRING; }
virtual XPathValue_impl<string_type, string_adaptor>* evaluate(const DOM::Node<string_type, string_adaptor>& context, virtual XPathValue_impl<string_type, string_adaptor>* evaluate(const DOM::Node<string_type, string_adaptor>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const const ExecutionContext<string_type, string_adaptor>& executionContext) const
{ {
@ -389,6 +417,8 @@ class StringLengthFn : public XPathFunction<string_type, string_adaptor>
public: public:
StringLengthFn(const std::vector<XPathExpression<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 ValueType type() const { return NUMBER; }
virtual XPathValue_impl<string_type, string_adaptor>* evaluate(const DOM::Node<string_type, string_adaptor>& context, virtual XPathValue_impl<string_type, string_adaptor>* evaluate(const DOM::Node<string_type, string_adaptor>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const const ExecutionContext<string_type, string_adaptor>& executionContext) const
{ {
@ -405,6 +435,8 @@ class NormalizeSpaceFn : public XPathFunction<string_type, string_adaptor>
public: public:
NormalizeSpaceFn(const std::vector<XPathExpression<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 ValueType type() const { return STRING; }
virtual XPathValue_impl<string_type, string_adaptor>* evaluate(const DOM::Node<string_type, string_adaptor>& context, virtual XPathValue_impl<string_type, string_adaptor>* evaluate(const DOM::Node<string_type, string_adaptor>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const const ExecutionContext<string_type, string_adaptor>& executionContext) const
{ {
@ -422,6 +454,8 @@ class TranslateFn : public XPathFunction<string_type, string_adaptor>
public: public:
TranslateFn(const std::vector<XPathExpression<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 ValueType type() const { return STRING; }
virtual XPathValue_impl<string_type, string_adaptor>* evaluate(const DOM::Node<string_type, string_adaptor>& context, virtual XPathValue_impl<string_type, string_adaptor>* evaluate(const DOM::Node<string_type, string_adaptor>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const const ExecutionContext<string_type, string_adaptor>& executionContext) const
{ {
@ -456,6 +490,8 @@ class BooleanFn : public XPathFunction<string_type, string_adaptor>
public: public:
BooleanFn(const std::vector<XPathExpression<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 ValueType type() const { return BOOL; }
virtual XPathValue_impl<string_type, string_adaptor>* evaluate(const DOM::Node<string_type, string_adaptor>& context, virtual XPathValue_impl<string_type, string_adaptor>* evaluate(const DOM::Node<string_type, string_adaptor>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const const ExecutionContext<string_type, string_adaptor>& executionContext) const
{ {
@ -471,6 +507,8 @@ class NotFn : public XPathFunction<string_type, string_adaptor>
public: public:
NotFn(const std::vector<XPathExpression<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 ValueType type() const { return BOOL; }
virtual XPathValue_impl<string_type, string_adaptor>* evaluate(const DOM::Node<string_type, string_adaptor>& context, virtual XPathValue_impl<string_type, string_adaptor>* evaluate(const DOM::Node<string_type, string_adaptor>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const const ExecutionContext<string_type, string_adaptor>& executionContext) const
{ {
@ -485,6 +523,8 @@ class TrueFn : public XPathFunction<string_type, string_adaptor>
public: public:
TrueFn(const std::vector<XPathExpression<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 ValueType type() const { return BOOL; }
virtual XPathValue_impl<string_type, string_adaptor>* evaluate(const DOM::Node<string_type, string_adaptor>& context, virtual XPathValue_impl<string_type, string_adaptor>* evaluate(const DOM::Node<string_type, string_adaptor>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const const ExecutionContext<string_type, string_adaptor>& executionContext) const
{ {
@ -499,6 +539,8 @@ class FalseFn : public XPathFunction<string_type, string_adaptor>
public: public:
FalseFn(const std::vector<XPathExpression<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 ValueType type() const { return BOOL; }
virtual XPathValue_impl<string_type, string_adaptor>* evaluate(const DOM::Node<string_type, string_adaptor>& context, virtual XPathValue_impl<string_type, string_adaptor>* evaluate(const DOM::Node<string_type, string_adaptor>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const const ExecutionContext<string_type, string_adaptor>& executionContext) const
{ {
@ -519,6 +561,8 @@ class NumberFn : public XPathFunction<string_type, string_adaptor>
public: public:
NumberFn(const std::vector<XPathExpression<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 ValueType type() const { return NUMBER; }
virtual XPathValue_impl<string_type, string_adaptor>* evaluate(const DOM::Node<string_type, string_adaptor>& context, virtual XPathValue_impl<string_type, string_adaptor>* evaluate(const DOM::Node<string_type, string_adaptor>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const const ExecutionContext<string_type, string_adaptor>& executionContext) const
{ {
@ -536,6 +580,8 @@ class SumFn : public XPathFunction<string_type, string_adaptor>
public: public:
SumFn(const std::vector<XPathExpression<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 ValueType type() const { return NUMBER; }
virtual XPathValue_impl<string_type, string_adaptor>* evaluate(const DOM::Node<string_type, string_adaptor>& context, virtual XPathValue_impl<string_type, string_adaptor>* evaluate(const DOM::Node<string_type, string_adaptor>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const const ExecutionContext<string_type, string_adaptor>& executionContext) const
{ {
@ -555,6 +601,8 @@ class FloorFn : public XPathFunction<string_type, string_adaptor>
public: public:
FloorFn(const std::vector<XPathExpression<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 ValueType type() const { return NUMBER; }
virtual XPathValue_impl<string_type, string_adaptor>* evaluate(const DOM::Node<string_type, string_adaptor>& context, virtual XPathValue_impl<string_type, string_adaptor>* evaluate(const DOM::Node<string_type, string_adaptor>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const const ExecutionContext<string_type, string_adaptor>& executionContext) const
{ {
@ -570,6 +618,8 @@ class CeilingFn : public XPathFunction<string_type, string_adaptor>
public: public:
CeilingFn(const std::vector<XPathExpression<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 ValueType type() const { return NUMBER; }
virtual XPathValue_impl<string_type, string_adaptor>* evaluate(const DOM::Node<string_type, string_adaptor>& context, virtual XPathValue_impl<string_type, string_adaptor>* evaluate(const DOM::Node<string_type, string_adaptor>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const const ExecutionContext<string_type, string_adaptor>& executionContext) const
{ {
@ -585,6 +635,8 @@ class RoundFn : public XPathFunction<string_type, string_adaptor>
public: public:
RoundFn(const std::vector<XPathExpression<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 ValueType type() const { return NUMBER; }
virtual XPathValue_impl<string_type, string_adaptor>* evaluate(const DOM::Node<string_type, string_adaptor>& context, virtual XPathValue_impl<string_type, string_adaptor>* evaluate(const DOM::Node<string_type, string_adaptor>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const const ExecutionContext<string_type, string_adaptor>& executionContext) const
{ {

View file

@ -29,6 +29,8 @@ public:
delete func_; delete func_;
} // ~FunctionHolder } // ~FunctionHolder
virtual ValueType type() const { return func_->type(); }
virtual XPathValue<string_type, string_adaptor> evaluate(const DOM::Node<string_type, string_adaptor>& context, virtual XPathValue<string_type, string_adaptor> evaluate(const DOM::Node<string_type, string_adaptor>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const const ExecutionContext<string_type, string_adaptor>& executionContext) const
{ {

View file

@ -20,6 +20,8 @@ public:
XPathExpression_impl<string_type, string_adaptor>* rhs) : XPathExpression_impl<string_type, string_adaptor>* rhs) :
BinaryExpression<string_type, string_adaptor>(lhs, rhs) { } BinaryExpression<string_type, string_adaptor>(lhs, rhs) { }
virtual ValueType type() const { return BOOL; }
virtual XPathValue<string_type, string_adaptor> evaluate(const DOM::Node<string_type, string_adaptor>& context, virtual XPathValue<string_type, string_adaptor> evaluate(const DOM::Node<string_type, string_adaptor>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const const ExecutionContext<string_type, string_adaptor>& executionContext) const
{ {
@ -44,6 +46,8 @@ public:
XPathExpression_impl<string_type, string_adaptor>* rhs) : XPathExpression_impl<string_type, string_adaptor>* rhs) :
BinaryExpression<string_type, string_adaptor>(lhs, rhs) { } BinaryExpression<string_type, string_adaptor>(lhs, rhs) { }
virtual ValueType type() const { return BOOL; }
virtual XPathValue<string_type, string_adaptor> evaluate(const DOM::Node<string_type, string_adaptor>& context, virtual XPathValue<string_type, string_adaptor> evaluate(const DOM::Node<string_type, string_adaptor>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const const ExecutionContext<string_type, string_adaptor>& executionContext) const
{ {

View file

@ -21,7 +21,7 @@ public:
MatchExpr& operator=(const MatchExpr& rhs) MatchExpr& operator=(const MatchExpr& rhs)
{ match_ = rhs.match_; priority_ = rhs.priority_; return *this; } { match_ = rhs.match_; priority_ = rhs.priority_; return *this; }
double priority() const { return priority_; } double priority() const { return priority_; }
bool evaluate(const DOM::Node<string_type, string_adaptor>& context, bool evaluate(const DOM::Node<string_type, string_adaptor>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const const ExecutionContext<string_type, string_adaptor>& executionContext) const
{ {
@ -52,6 +52,8 @@ public:
add_matches(expr); add_matches(expr);
} // MatchExpressionWrapper } // MatchExpressionWrapper
virtual ValueType type() const { return BOOL; }
virtual XPathValue<string_type, string_adaptor> evaluate(const DOM::Node<string_type, string_adaptor>& context, virtual XPathValue<string_type, string_adaptor> evaluate(const DOM::Node<string_type, string_adaptor>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const const ExecutionContext<string_type, string_adaptor>& executionContext) const
{ {

View file

@ -20,6 +20,8 @@ public:
XPathExpression_impl<string_type, string_adaptor>* rhs) : XPathExpression_impl<string_type, string_adaptor>* rhs) :
BinaryExpression<string_type, string_adaptor>(lhs, rhs) { } BinaryExpression<string_type, string_adaptor>(lhs, rhs) { }
virtual ValueType type() const { return BOOL; }
virtual XPathValue<string_type, string_adaptor> evaluate(const DOM::Node<string_type, string_adaptor>& context, virtual XPathValue<string_type, string_adaptor> evaluate(const DOM::Node<string_type, string_adaptor>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const const ExecutionContext<string_type, string_adaptor>& executionContext) const
{ {
@ -38,6 +40,8 @@ public:
XPathExpression_impl<string_type, string_adaptor>* rhs) : XPathExpression_impl<string_type, string_adaptor>* rhs) :
BinaryExpression<string_type, string_adaptor>(lhs, rhs) { } BinaryExpression<string_type, string_adaptor>(lhs, rhs) { }
virtual ValueType type() const { return BOOL; }
virtual XPathValue<string_type, string_adaptor> evaluate(const DOM::Node<string_type, string_adaptor>& context, virtual XPathValue<string_type, string_adaptor> evaluate(const DOM::Node<string_type, string_adaptor>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const const ExecutionContext<string_type, string_adaptor>& executionContext) const
{ {
@ -56,6 +60,8 @@ public:
XPathExpression_impl<string_type, string_adaptor>* rhs) : XPathExpression_impl<string_type, string_adaptor>* rhs) :
BinaryExpression<string_type, string_adaptor>(lhs, rhs) { } BinaryExpression<string_type, string_adaptor>(lhs, rhs) { }
virtual ValueType type() const { return BOOL; }
virtual XPathValue<string_type, string_adaptor> evaluate(const DOM::Node<string_type, string_adaptor>& context, virtual XPathValue<string_type, string_adaptor> evaluate(const DOM::Node<string_type, string_adaptor>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const const ExecutionContext<string_type, string_adaptor>& executionContext) const
{ {
@ -74,6 +80,8 @@ public:
XPathExpression_impl<string_type, string_adaptor>* rhs) : XPathExpression_impl<string_type, string_adaptor>* rhs) :
BinaryExpression<string_type, string_adaptor>(lhs, rhs) { } BinaryExpression<string_type, string_adaptor>(lhs, rhs) { }
virtual ValueType type() const { return BOOL; }
virtual XPathValue<string_type, string_adaptor> evaluate(const DOM::Node<string_type, string_adaptor>& context, virtual XPathValue<string_type, string_adaptor> evaluate(const DOM::Node<string_type, string_adaptor>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const const ExecutionContext<string_type, string_adaptor>& executionContext) const
{ {
@ -92,6 +100,8 @@ public:
XPathExpression_impl<string_type, string_adaptor>* rhs) : XPathExpression_impl<string_type, string_adaptor>* rhs) :
BinaryExpression<string_type, string_adaptor>(lhs, rhs) { } BinaryExpression<string_type, string_adaptor>(lhs, rhs) { }
virtual ValueType type() const { return BOOL; }
virtual XPathValue<string_type, string_adaptor> evaluate(const DOM::Node<string_type, string_adaptor>& context, virtual XPathValue<string_type, string_adaptor> evaluate(const DOM::Node<string_type, string_adaptor>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const const ExecutionContext<string_type, string_adaptor>& executionContext) const
{ {
@ -110,6 +120,8 @@ public:
XPathExpression_impl<string_type, string_adaptor>* rhs) : XPathExpression_impl<string_type, string_adaptor>* rhs) :
BinaryExpression<string_type, string_adaptor>(lhs, rhs) { } BinaryExpression<string_type, string_adaptor>(lhs, rhs) { }
virtual ValueType type() const { return BOOL; }
virtual XPathValue<string_type, string_adaptor> evaluate(const DOM::Node<string_type, string_adaptor>& context, virtual XPathValue<string_type, string_adaptor> evaluate(const DOM::Node<string_type, string_adaptor>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const const ExecutionContext<string_type, string_adaptor>& executionContext) const
{ {

View file

@ -32,6 +32,8 @@ public:
delete *p; delete *p;
} // ~StepExpression } // ~StepExpression
virtual ValueType type() const { return NODE_SET; }
virtual XPathValue<string_type, string_adaptor> evaluate(const DOM::Node<string_type, string_adaptor>& context, const ExecutionContext<string_type, string_adaptor>& executionContext) const = 0; virtual XPathValue<string_type, string_adaptor> evaluate(const DOM::Node<string_type, string_adaptor>& context, const ExecutionContext<string_type, string_adaptor>& executionContext) const = 0;
virtual XPathValue<string_type, string_adaptor> evaluate(NodeSet<string_type, string_adaptor>& context, const ExecutionContext<string_type, string_adaptor>& executionContext) const = 0; virtual XPathValue<string_type, string_adaptor> evaluate(NodeSet<string_type, string_adaptor>& context, const ExecutionContext<string_type, string_adaptor>& executionContext) const = 0;
@ -453,6 +455,8 @@ public:
delete *i; delete *i;
} // ~RelativeLocationPath } // ~RelativeLocationPath
virtual ValueType type() const { return NODE_SET; }
virtual XPathValue<string_type, string_adaptor> evaluate(const DOM::Node<string_type, string_adaptor>& context, const ExecutionContext<string_type, string_adaptor>& executionContext) const virtual XPathValue<string_type, string_adaptor> evaluate(const DOM::Node<string_type, string_adaptor>& context, const ExecutionContext<string_type, string_adaptor>& executionContext) const
{ {
NodeSet<string_type, string_adaptor> nodes; NodeSet<string_type, string_adaptor> nodes;

View file

@ -21,6 +21,8 @@ public:
XPathExpression_impl<string_type, string_adaptor>* rhs) : XPathExpression_impl<string_type, string_adaptor>* rhs) :
BinaryExpression<string_type, string_adaptor>(lhs, rhs) { } BinaryExpression<string_type, string_adaptor>(lhs, rhs) { }
virtual ValueType type() const { return NODE_SET; }
virtual XPathValue<string_type, string_adaptor> evaluate(const DOM::Node<string_type, string_adaptor>& context, virtual XPathValue<string_type, string_adaptor> evaluate(const DOM::Node<string_type, string_adaptor>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const const ExecutionContext<string_type, string_adaptor>& executionContext) const
{ {

View file

@ -21,6 +21,8 @@ public:
{ {
} // Variable } // Variable
virtual ValueType type() const { return ANY; }
virtual XPathValue<string_type, string_adaptor> evaluate(const DOM::Node<string_type, string_adaptor>& context, virtual XPathValue<string_type, string_adaptor> evaluate(const DOM::Node<string_type, string_adaptor>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const const ExecutionContext<string_type, string_adaptor>& executionContext) const
{ {

View file

@ -18,6 +18,8 @@ public:
CurrentFunction(const std::vector<Arabica::XPath::XPathExpression<std::string> >& args) : CurrentFunction(const std::vector<Arabica::XPath::XPathExpression<std::string> >& args) :
Arabica::XPath::XPathFunction<std::string>(0, 0, args) { } Arabica::XPath::XPathFunction<std::string>(0, 0, args) { }
virtual Arabica::XPath::ValueType type() const { return Arabica::XPath::NODE_SET; }
virtual Arabica::XPath::XPathValue_impl<std::string>* evaluate(const DOM::Node<std::string>& context, virtual Arabica::XPath::XPathValue_impl<std::string>* evaluate(const DOM::Node<std::string>& context,
const Arabica::XPath::ExecutionContext<std::string>& executionContext) const const Arabica::XPath::ExecutionContext<std::string>& executionContext) const
{ {
@ -39,6 +41,8 @@ public:
baseURI_(currentBase) baseURI_(currentBase)
{ } { }
virtual Arabica::XPath::ValueType type() const { return Arabica::XPath::NODE_SET; }
virtual Arabica::XPath::XPathValue_impl<std::string>* evaluate(const DOM::Node<std::string>& context, virtual Arabica::XPath::XPathValue_impl<std::string>* evaluate(const DOM::Node<std::string>& context,
const Arabica::XPath::ExecutionContext<std::string>& executionContext) const const Arabica::XPath::ExecutionContext<std::string>& executionContext) const
{ {
@ -84,6 +88,8 @@ public:
SystemPropertyFunction (const std::vector<Arabica::XPath::XPathExpression<std::string> >& args) : SystemPropertyFunction (const std::vector<Arabica::XPath::XPathExpression<std::string> >& args) :
Arabica::XPath::XPathFunction<std::string>(1, 1, args) { } Arabica::XPath::XPathFunction<std::string>(1, 1, args) { }
virtual Arabica::XPath::ValueType type() const { return Arabica::XPath::STRING; }
virtual Arabica::XPath::XPathValue_impl<std::string>* evaluate(const DOM::Node<std::string>& context, virtual Arabica::XPath::XPathValue_impl<std::string>* evaluate(const DOM::Node<std::string>& context,
const Arabica::XPath::ExecutionContext<std::string>& executionContext) const const Arabica::XPath::ExecutionContext<std::string>& executionContext) const
{ {

View file

@ -65,6 +65,8 @@ public:
TestFunction(const std::vector<Arabica::XPath::XPathExpression<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) { } Arabica::XPath::XPathFunction<string_type, string_adaptor>(0, 0, args) { }
virtual Arabica::XPath::ValueType type() const { return Arabica::XPath::STRING; }
virtual Arabica::XPath::XPathValue_impl<string_type, string_adaptor>* evaluate(const Arabica::DOM::Node<string_type, string_adaptor>& context, virtual Arabica::XPath::XPathValue_impl<string_type, string_adaptor>* evaluate(const Arabica::DOM::Node<string_type, string_adaptor>& context,
const Arabica::XPath::ExecutionContext<string_type, string_adaptor>& executionContext) const const Arabica::XPath::ExecutionContext<string_type, string_adaptor>& executionContext) const
{ {
@ -178,6 +180,7 @@ public:
using namespace Arabica::XPath; using namespace Arabica::XPath;
XPathExpression<string_type, string_adaptor> xpath; XPathExpression<string_type, string_adaptor> xpath;
xpath = parser.compile(SA::construct_from_utf8("root")); xpath = parser.compile(SA::construct_from_utf8("root"));
assertValuesEqual(NODE_SET, xpath.type());
XPathValue<string_type, string_adaptor> result = xpath.evaluate(document_); XPathValue<string_type, string_adaptor> result = xpath.evaluate(document_);
assertValuesEqual(NODE_SET, result.type()); assertValuesEqual(NODE_SET, result.type());
@ -190,6 +193,7 @@ public:
{ {
using namespace Arabica::XPath; using namespace Arabica::XPath;
XPathExpression<string_type, string_adaptor> xpath = parser.compile(SA::construct_from_utf8("root/child2")); XPathExpression<string_type, string_adaptor> xpath = parser.compile(SA::construct_from_utf8("root/child2"));
assertValuesEqual(NODE_SET, xpath.type());
XPathValue<string_type, string_adaptor> result = xpath.evaluate(document_); XPathValue<string_type, string_adaptor> result = xpath.evaluate(document_);
assertValuesEqual(NODE_SET, result.type()); assertValuesEqual(NODE_SET, result.type());
@ -202,6 +206,7 @@ public:
{ {
using namespace Arabica::XPath; using namespace Arabica::XPath;
XPathExpression<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/*"));
assertValuesEqual(NODE_SET, xpath.type());
XPathValue<string_type, string_adaptor> result = xpath.evaluate(document_); XPathValue<string_type, string_adaptor> result = xpath.evaluate(document_);
assertValuesEqual(NODE_SET, result.type()); assertValuesEqual(NODE_SET, result.type());
@ -215,6 +220,7 @@ public:
{ {
using namespace Arabica::XPath; using namespace Arabica::XPath;
XPathExpression<string_type, string_adaptor> xpath = parser.compile(SA::construct_from_utf8("root/*/text()")); XPathExpression<string_type, string_adaptor> xpath = parser.compile(SA::construct_from_utf8("root/*/text()"));
assertValuesEqual(NODE_SET, xpath.type());
XPathValue<string_type, string_adaptor> result = xpath.evaluate(document_); XPathValue<string_type, string_adaptor> result = xpath.evaluate(document_);
assertValuesEqual(NODE_SET, result.type()); assertValuesEqual(NODE_SET, result.type());
@ -234,6 +240,7 @@ public:
{ {
using namespace Arabica::XPath; using namespace Arabica::XPath;
XPathExpression<string_type, string_adaptor> xpath = parser.compile(SA::construct_from_utf8("*")); XPathExpression<string_type, string_adaptor> xpath = parser.compile(SA::construct_from_utf8("*"));
assertValuesEqual(NODE_SET, xpath.type());
XPathValue<string_type, string_adaptor> result = xpath.evaluate(document_); XPathValue<string_type, string_adaptor> result = xpath.evaluate(document_);
assertValuesEqual(NODE_SET, result.type()); assertValuesEqual(NODE_SET, result.type());
@ -283,6 +290,7 @@ public:
nsContext.addNamespaceDeclaration(SA::construct_from_utf8("urn:something:or:other"), SA::construct_from_utf8("ns")); nsContext.addNamespaceDeclaration(SA::construct_from_utf8("urn:something:or:other"), SA::construct_from_utf8("ns"));
parser.setNamespaceContext(nsContext); parser.setNamespaceContext(nsContext);
XPathExpression<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"));
assertValuesEqual(NODE_SET, xpath.type());
parser.resetNamespaceContext(); parser.resetNamespaceContext();
XPathValue<string_type, string_adaptor> result = xpath.evaluate(document_); XPathValue<string_type, string_adaptor> result = xpath.evaluate(document_);