mirror of
https://github.com/jezhiggins/arabica
synced 2025-01-29 08:36:45 +01:00
split xpath_expression.hpp out from xpath_object.hpp
This commit is contained in:
parent
4014643f71
commit
1249293bdc
4 changed files with 88 additions and 69 deletions
86
XPath/impl/xpath_expression.hpp
Normal file
86
XPath/impl/xpath_expression.hpp
Normal file
|
@ -0,0 +1,86 @@
|
|||
#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 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 evaluateAsNodeSet(const DOM::Node<std::string>& context) const { return evaluate(context)->asNodeSet(); }
|
||||
|
||||
virtual XPathValuePtr 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
|
||||
|
||||
typedef boost::shared_ptr<XPathExpression> XPathExpressionPtr;
|
||||
|
||||
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
|
|
@ -7,7 +7,6 @@
|
|||
#include <DOM/Node.h>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <cmath>
|
||||
#include "xpath_execution_context.hpp"
|
||||
|
||||
namespace Arabica
|
||||
{
|
||||
|
@ -154,74 +153,6 @@ bool isLessThanEquals(const XPathValuePtr& lhs, const XPathValuePtr& rhs);
|
|||
bool isGreaterThan(const XPathValuePtr& lhs, const XPathValuePtr& rhs);
|
||||
bool isGreaterThanEquals(const XPathValuePtr& lhs, const XPathValuePtr& rhs);
|
||||
|
||||
|
||||
class XPathExpression
|
||||
{
|
||||
protected:
|
||||
XPathExpression() { }
|
||||
|
||||
public:
|
||||
virtual ~XPathExpression() { }
|
||||
|
||||
XPathValuePtr 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 evaluateAsNodeSet(const DOM::Node<std::string>& context) const { return evaluate(context)->asNodeSet(); }
|
||||
|
||||
virtual XPathValuePtr 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 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
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "xpath_grammar.hpp"
|
||||
#include "xpath_namespace_context.hpp"
|
||||
#include "xpath_function_resolver.hpp"
|
||||
#include "xpath_variable_resolver.hpp"
|
||||
#include "xpath_resolver_holder.hpp"
|
||||
|
||||
namespace Arabica
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include <boost/lexical_cast.hpp>
|
||||
#include <vector>
|
||||
#include "xpath_object.hpp"
|
||||
#include "xpath_expression.hpp"
|
||||
|
||||
namespace Arabica
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue