mirror of
https://github.com/jezhiggins/arabica
synced 2025-01-06 05:24:35 +01:00
90 lines
2.3 KiB
C++
90 lines
2.3 KiB
C++
#ifndef ARABICA_XPATHIC_XPATH_EXPRESSION_H
|
|
#define ARABICA_XPATHIC_XPATH_EXPRESSION_H
|
|
|
|
#include <string>
|
|
#include <DOM/Node.h>
|
|
#include "xpath_object.hpp"
|
|
#include "xpath_execution_context.hpp"
|
|
|
|
namespace Arabica
|
|
{
|
|
namespace XPath
|
|
{
|
|
|
|
class XPathExpression
|
|
{
|
|
protected:
|
|
XPathExpression() { }
|
|
|
|
public:
|
|
virtual ~XPathExpression() { }
|
|
|
|
XPathValuePtr<std::string> evaluate(const DOM::Node<std::string>& context) const
|
|
{
|
|
ExecutionContext executionContext;
|
|
return evaluate(context, executionContext);
|
|
} // evaluate
|
|
|
|
virtual bool evaluateAsBool(const DOM::Node<std::string>& context) const { return evaluate(context)->asBool(); }
|
|
virtual double evaluateAsNumber(const DOM::Node<std::string>& context) const { return evaluate(context)->asNumber(); }
|
|
virtual std::string evaluateAsString(const DOM::Node<std::string>& context) const { return evaluate(context)->asString(); }
|
|
virtual NodeSet<std::string> evaluateAsNodeSet(const DOM::Node<std::string>& context) const { return evaluate(context)->asNodeSet(); }
|
|
|
|
virtual XPathValuePtr<std::string> evaluate(const DOM::Node<std::string>& context,
|
|
const Arabica::XPath::ExecutionContext& executionContext) const = 0;
|
|
|
|
private:
|
|
XPathExpression(const XPathExpression&);
|
|
bool operator==(const XPathExpression&);
|
|
XPathExpression& operator=(const XPathExpression&);
|
|
}; // class XPathExpression
|
|
|
|
class XPathExpressionPtr : public boost::shared_ptr<XPathExpression>
|
|
{
|
|
public:
|
|
explicit XPathExpressionPtr(XPathExpression* xp) : boost::shared_ptr<XPathExpression>(xp) { }
|
|
};
|
|
|
|
class UnaryExpression
|
|
{
|
|
public:
|
|
UnaryExpression(XPathExpression* expr) :
|
|
expr_(expr) { }
|
|
|
|
protected:
|
|
~UnaryExpression()
|
|
{
|
|
delete expr_;
|
|
} // ~UnaryExpression
|
|
|
|
XPathExpression* expr() const { return expr_; }
|
|
|
|
private:
|
|
XPathExpression* expr_;
|
|
}; // class UnaryExpression
|
|
|
|
class BinaryExpression
|
|
{
|
|
public:
|
|
BinaryExpression(XPathExpression* lhs, XPathExpression* rhs) :
|
|
lhs_(lhs), rhs_(rhs) { }
|
|
|
|
protected:
|
|
~BinaryExpression()
|
|
{
|
|
delete lhs_;
|
|
delete rhs_;
|
|
} // ~BinaryExpression
|
|
|
|
XPathExpression* lhs() const { return lhs_; }
|
|
XPathExpression* rhs() const { return rhs_; }
|
|
|
|
private:
|
|
XPathExpression* lhs_;
|
|
XPathExpression* rhs_;
|
|
}; // class BinaryExpression
|
|
|
|
} // namespace XPath
|
|
} // namespace Arabica
|
|
|
|
#endif
|