arabica/XPath/impl/xpath_relational.hpp

122 lines
6 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
{
2005-08-17 14:24:25 +02:00
template<class string_type, class string_adaptor>
class EqualsOperator : private BinaryExpression<string_type, string_adaptor>,
public XPathExpression<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:
2005-08-17 14:24:25 +02:00
EqualsOperator(XPathExpression<string_type, string_adaptor>* lhs,
XPathExpression<string_type, string_adaptor>* rhs) :
BinaryExpression<string_type, string_adaptor>(lhs, rhs) { }
2005-08-04 22:42:30 +02:00
2005-08-17 14:24:25 +02:00
virtual XPathValuePtr<string_type> evaluate(const DOM::Node<string_type>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const
2005-08-04 22:42:30 +02:00
{
2005-08-17 14:24:25 +02:00
return BoolValue<string_type, string_adaptor>::createValue(areEqual(baseT::lhs()->evaluate(context, executionContext),
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 : private BinaryExpression<string_type, string_adaptor>,
public XPathExpression<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:
2005-08-17 14:24:25 +02:00
NotEqualsOperator(XPathExpression<string_type, string_adaptor>* lhs,
XPathExpression<string_type, string_adaptor>* rhs) :
BinaryExpression<string_type, string_adaptor>(lhs, rhs) { }
2005-08-04 22:42:30 +02:00
2005-08-17 14:24:25 +02:00
virtual XPathValuePtr<string_type> evaluate(const DOM::Node<string_type>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const
2005-08-04 22:42:30 +02:00
{
2005-08-17 14:24:25 +02:00
return BoolValue<string_type, string_adaptor>::createValue(!areEqual(baseT::lhs()->evaluate(context, executionContext),
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 : private BinaryExpression<string_type, string_adaptor>,
public XPathExpression<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:
2005-08-17 14:24:25 +02:00
LessThanOperator(XPathExpression<string_type, string_adaptor>* lhs,
XPathExpression<string_type, string_adaptor>* rhs) :
BinaryExpression<string_type, string_adaptor>(lhs, rhs) { }
2005-08-04 22:42:30 +02:00
2005-08-17 14:24:25 +02:00
virtual XPathValuePtr<string_type> evaluate(const DOM::Node<string_type>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const
2005-08-04 22:42:30 +02:00
{
2005-08-17 14:24:25 +02:00
return BoolValue<string_type, string_adaptor>::createValue(isLessThan(baseT::lhs()->evaluate(context, executionContext),
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 : private BinaryExpression<string_type, string_adaptor>,
public XPathExpression<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:
2005-08-17 14:24:25 +02:00
LessThanEqualsOperator(XPathExpression<string_type, string_adaptor>* lhs,
XPathExpression<string_type, string_adaptor>* rhs) :
BinaryExpression<string_type, string_adaptor>(lhs, rhs) { }
2005-08-04 22:42:30 +02:00
2005-08-17 14:24:25 +02:00
virtual XPathValuePtr<string_type> evaluate(const DOM::Node<string_type>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const
2005-08-04 22:42:30 +02:00
{
2005-08-17 14:24:25 +02:00
return BoolValue<string_type, string_adaptor>::createValue(isLessThanEquals(baseT::lhs()->evaluate(context, executionContext),
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 : private BinaryExpression<string_type, string_adaptor>,
public XPathExpression<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:
2005-08-17 14:24:25 +02:00
GreaterThanOperator(XPathExpression<string_type, string_adaptor>* lhs,
XPathExpression<string_type, string_adaptor>* rhs) :
BinaryExpression<string_type, string_adaptor>(lhs, rhs) { }
2005-08-04 22:42:30 +02:00
2005-08-17 14:24:25 +02:00
virtual XPathValuePtr<string_type> evaluate(const DOM::Node<string_type>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const
2005-08-04 22:42:30 +02:00
{
2005-08-17 14:24:25 +02:00
return BoolValue<string_type, string_adaptor>::createValue(isGreaterThan(baseT::lhs()->evaluate(context, executionContext),
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 : private BinaryExpression<string_type, string_adaptor>,
public XPathExpression<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:
2005-08-17 14:24:25 +02:00
GreaterThanEqualsOperator(XPathExpression<string_type, string_adaptor>* lhs,
XPathExpression<string_type, string_adaptor>* rhs) :
BinaryExpression<string_type, string_adaptor>(lhs, rhs) { }
2005-08-04 22:42:30 +02:00
2005-08-17 14:24:25 +02:00
virtual XPathValuePtr<string_type> evaluate(const DOM::Node<string_type>& context,
const ExecutionContext<string_type, string_adaptor>& executionContext) const
2005-08-04 22:42:30 +02:00
{
2005-08-17 14:24:25 +02:00
return BoolValue<string_type, string_adaptor>::createValue(isGreaterThanEquals(baseT::lhs()->evaluate(context, executionContext),
baseT::rhs()->evaluate(context, executionContext)));
2005-08-04 22:42:30 +02:00
} // evaluate
}; // class GreaterThanEqualsOperator
} // namespace XPath
} // namespace Arabica
#endif