XPathExpressionNode.h [plain text]
#ifndef XPathExpressionNode_h
#define XPathExpressionNode_h
#include "XPathValue.h"
namespace WebCore {
namespace XPath {
struct EvaluationContext {
RefPtr<Node> node;
unsigned size;
unsigned position;
HashMap<String, String> variableBindings;
bool hadTypeConversionError;
};
class Expression {
WTF_MAKE_NONCOPYABLE(Expression); WTF_MAKE_FAST_ALLOCATED;
public:
static EvaluationContext& evaluationContext();
virtual ~Expression() { }
virtual Value evaluate() const = 0;
virtual Value::Type resultType() const = 0;
bool isContextNodeSensitive() const { return m_isContextNodeSensitive; }
bool isContextPositionSensitive() const { return m_isContextPositionSensitive; }
bool isContextSizeSensitive() const { return m_isContextSizeSensitive; }
protected:
Expression();
unsigned subexpressionCount() const { return m_subexpressions.size(); }
const Expression& subexpression(unsigned i) const { return *m_subexpressions[i]; }
void addSubexpression(std::unique_ptr<Expression> expression)
{
m_isContextNodeSensitive |= expression->m_isContextNodeSensitive;
m_isContextPositionSensitive |= expression->m_isContextPositionSensitive;
m_isContextSizeSensitive |= expression->m_isContextSizeSensitive;
m_subexpressions.append(WTF::move(expression));
}
void setSubexpressions(Vector<std::unique_ptr<Expression>>);
void setIsContextNodeSensitive(bool value) { m_isContextNodeSensitive = value; }
void setIsContextPositionSensitive(bool value) { m_isContextPositionSensitive = value; }
void setIsContextSizeSensitive(bool value) { m_isContextSizeSensitive = value; }
private:
Vector<std::unique_ptr<Expression>> m_subexpressions;
bool m_isContextNodeSensitive;
bool m_isContextPositionSensitive;
bool m_isContextSizeSensitive;
};
} }
#endif // XPathExpressionNode_h