arabica/include/XPath/impl/xpath_relational.hpp

131 lines
6.3 KiB
C++
Raw Normal View History

2005-08-04 22:42:30 +02:00
#ifndef ARABICA_XPATHIC_XPATH_RELATIONAL_HPP
#define ARABICA_XPATHIC_XPATH_RELATIONAL_HPP
#include "xpath_value.hpp"
namespace Arabica
{
namespace XPath
{
namespace impl
{
2005-08-04 22:42:30 +02:00
2005-08-17 14:24:25 +02:00
template<class string_type, class string_adaptor>
class EqualsOperator : public BinaryExpression<string_type, string_adaptor>
2005-08-04 22:42:30 +02:00
{
2005-08-17 14:24:25 +02:00
typedef BinaryExpression<string_type, string_adaptor> baseT;
2005-08-04 22:42:30 +02:00
public:
EqualsOperator(XPathExpression_impl<string_type, string_adaptor>* lhs,
XPathExpression_impl<string_type, string_adaptor>* rhs) :
2005-08-17 14:24:25 +02:00
BinaryExpression<string_type, string_adaptor>(lhs, rhs) { }
2005-08-04 22:42:30 +02:00
virtual ValueType type() const { return BOOL; }
virtual XPathValue<string_type, string_adaptor> evaluate(const DOM::Node<string_type, string_adaptor>& context,
2005-08-17 14:24:25 +02:00
const ExecutionContext<string_type, string_adaptor>& executionContext) const
2005-08-04 22:42:30 +02:00
{
2005-08-23 21:19:17 +02:00
return BoolValue<string_type, string_adaptor>::createValue(areEqual<string_type, string_adaptor>(baseT::lhs()->evaluate(context, executionContext),
2005-08-17 14:24:25 +02:00
baseT::rhs()->evaluate(context, executionContext)));
2005-08-04 22:42:30 +02:00
} // evaluate
}; // class EqualsOperator
2005-08-17 14:24:25 +02:00
template<class string_type, class string_adaptor>
class NotEqualsOperator : public BinaryExpression<string_type, string_adaptor>
2005-08-04 22:42:30 +02:00
{
2005-08-17 14:24:25 +02:00
typedef BinaryExpression<string_type, string_adaptor> baseT;
2005-08-04 22:42:30 +02:00
public:
NotEqualsOperator(XPathExpression_impl<string_type, string_adaptor>* lhs,
XPathExpression_impl<string_type, string_adaptor>* rhs) :
2005-08-17 14:24:25 +02:00
BinaryExpression<string_type, string_adaptor>(lhs, rhs) { }
2005-08-04 22:42:30 +02:00
virtual ValueType type() const { return BOOL; }
virtual XPathValue<string_type, string_adaptor> evaluate(const DOM::Node<string_type, string_adaptor>& context,
2005-08-17 14:24:25 +02:00
const ExecutionContext<string_type, string_adaptor>& executionContext) const
2005-08-04 22:42:30 +02:00
{
2007-07-19 19:01:31 +02:00
return BoolValue<string_type, string_adaptor>::createValue(areNotEqual<string_type, string_adaptor>(baseT::lhs()->evaluate(context, executionContext),
2005-08-17 14:24:25 +02:00
baseT::rhs()->evaluate(context, executionContext)));
2005-08-04 22:42:30 +02:00
} // evaluate
}; // class NotEqualsOperator
2005-08-17 14:24:25 +02:00
template<class string_type, class string_adaptor>
class LessThanOperator : public BinaryExpression<string_type, string_adaptor>
2005-08-04 22:42:30 +02:00
{
2005-08-17 14:24:25 +02:00
typedef BinaryExpression<string_type, string_adaptor> baseT;
2005-08-04 22:42:30 +02:00
public:
LessThanOperator(XPathExpression_impl<string_type, string_adaptor>* lhs,
XPathExpression_impl<string_type, string_adaptor>* rhs) :
2005-08-17 14:24:25 +02:00
BinaryExpression<string_type, string_adaptor>(lhs, rhs) { }
2005-08-04 22:42:30 +02:00
virtual ValueType type() const { return BOOL; }
virtual XPathValue<string_type, string_adaptor> evaluate(const DOM::Node<string_type, string_adaptor>& context,
2005-08-17 14:24:25 +02:00
const ExecutionContext<string_type, string_adaptor>& executionContext) const
2005-08-04 22:42:30 +02:00
{
2005-08-23 21:19:17 +02:00
return BoolValue<string_type, string_adaptor>::createValue(isLessThan<string_type, string_adaptor>(baseT::lhs()->evaluate(context, executionContext),
2005-08-17 14:24:25 +02:00
baseT::rhs()->evaluate(context, executionContext)));
2005-08-04 22:42:30 +02:00
} // evaluate
}; // class LessThanOperator
2005-08-17 14:24:25 +02:00
template<class string_type, class string_adaptor>
class LessThanEqualsOperator : public BinaryExpression<string_type, string_adaptor>
2005-08-04 22:42:30 +02:00
{
2005-08-17 14:24:25 +02:00
typedef BinaryExpression<string_type, string_adaptor> baseT;
2005-08-04 22:42:30 +02:00
public:
LessThanEqualsOperator(XPathExpression_impl<string_type, string_adaptor>* lhs,
XPathExpression_impl<string_type, string_adaptor>* rhs) :
2005-08-17 14:24:25 +02:00
BinaryExpression<string_type, string_adaptor>(lhs, rhs) { }
2005-08-04 22:42:30 +02:00
virtual ValueType type() const { return BOOL; }
virtual XPathValue<string_type, string_adaptor> evaluate(const DOM::Node<string_type, string_adaptor>& context,
2005-08-17 14:24:25 +02:00
const ExecutionContext<string_type, string_adaptor>& executionContext) const
2005-08-04 22:42:30 +02:00
{
2005-08-23 21:19:17 +02:00
return BoolValue<string_type, string_adaptor>::createValue(isLessThanEquals<string_type, string_adaptor>(baseT::lhs()->evaluate(context, executionContext),
2005-08-17 14:24:25 +02:00
baseT::rhs()->evaluate(context, executionContext)));
2005-08-04 22:42:30 +02:00
} // evaluate
}; // class LessThanEqualsOperator
2005-08-17 14:24:25 +02:00
template<class string_type, class string_adaptor>
class GreaterThanOperator : public BinaryExpression<string_type, string_adaptor>
2005-08-04 22:42:30 +02:00
{
2005-08-17 14:24:25 +02:00
typedef BinaryExpression<string_type, string_adaptor> baseT;
2005-08-04 22:42:30 +02:00
public:
GreaterThanOperator(XPathExpression_impl<string_type, string_adaptor>* lhs,
XPathExpression_impl<string_type, string_adaptor>* rhs) :
2005-08-17 14:24:25 +02:00
BinaryExpression<string_type, string_adaptor>(lhs, rhs) { }
2005-08-04 22:42:30 +02:00
virtual ValueType type() const { return BOOL; }
virtual XPathValue<string_type, string_adaptor> evaluate(const DOM::Node<string_type, string_adaptor>& context,
2005-08-17 14:24:25 +02:00
const ExecutionContext<string_type, string_adaptor>& executionContext) const
2005-08-04 22:42:30 +02:00
{
2005-08-23 21:19:17 +02:00
return BoolValue<string_type, string_adaptor>::createValue(isGreaterThan<string_type, string_adaptor>(baseT::lhs()->evaluate(context, executionContext),
2005-08-17 14:24:25 +02:00
baseT::rhs()->evaluate(context, executionContext)));
2005-08-04 22:42:30 +02:00
} // evaluate
}; // class GreaterThanOperator
2005-08-17 14:24:25 +02:00
template<class string_type, class string_adaptor>
class GreaterThanEqualsOperator : public BinaryExpression<string_type, string_adaptor>
2005-08-04 22:42:30 +02:00
{
2005-08-17 14:24:25 +02:00
typedef BinaryExpression<string_type, string_adaptor> baseT;
2005-08-04 22:42:30 +02:00
public:
GreaterThanEqualsOperator(XPathExpression_impl<string_type, string_adaptor>* lhs,
XPathExpression_impl<string_type, string_adaptor>* rhs) :
2005-08-17 14:24:25 +02:00
BinaryExpression<string_type, string_adaptor>(lhs, rhs) { }
2005-08-04 22:42:30 +02:00
virtual ValueType type() const { return BOOL; }
virtual XPathValue<string_type, string_adaptor> evaluate(const DOM::Node<string_type, string_adaptor>& context,
2005-08-17 14:24:25 +02:00
const ExecutionContext<string_type, string_adaptor>& executionContext) const
2005-08-04 22:42:30 +02:00
{
2005-08-23 21:19:17 +02:00
return BoolValue<string_type, string_adaptor>::createValue(isGreaterThanEquals<string_type, string_adaptor>(baseT::lhs()->evaluate(context, executionContext),
2005-08-17 14:24:25 +02:00
baseT::rhs()->evaluate(context, executionContext)));
2005-08-04 22:42:30 +02:00
} // evaluate
}; // class GreaterThanEqualsOperator
} // namespace impl
2005-08-04 22:42:30 +02:00
} // namespace XPath
} // namespace Arabica
#endif