arabica/XPath/impl/xpath_function_resolver.hpp

48 lines
1.2 KiB
C++
Raw Normal View History

2005-08-04 22:42:30 +02:00
#ifndef ARABICA_XPATH_FUNCTION_RESOLVER_HPP
#define ARABICA_XPATH_FUNCTION_RESOLVER_HPP
namespace Arabica
{
namespace XPath
{
class XPathFunction;
class XPathExpressionPtr;
2005-08-04 22:42:30 +02:00
class UndefinedFunctionException : public std::runtime_error
{
public:
UndefinedFunctionException(const std::string& thing) : std::runtime_error("The function '" + thing + "' is undefined.") { }
}; // class UndefinedFunctionException
class FunctionResolver
{
public:
2005-08-07 22:16:02 +02:00
virtual ~FunctionResolver() { }
2005-08-04 22:42:30 +02:00
// TODO: should make this a QName
virtual XPathFunction* resolveFunction(const std::string& name,
const std::vector<XPathExpressionPtr>& argExprs) const = 0;
}; // class FunctionResolver
class FunctionResolverPtr : public boost::shared_ptr<FunctionResolver>
{
public:
explicit FunctionResolverPtr(FunctionResolver* fr) : boost::shared_ptr<FunctionResolver>(fr) { }
};
2005-08-04 22:42:30 +02:00
class NullFunctionResolver : public FunctionResolver
{
public:
virtual XPathFunction* resolveFunction(const std::string& name,
const std::vector<XPathExpressionPtr>& argExprs) const
{
throw UndefinedFunctionException(name);
} // resolveVariable
}; // NullFunctionResolver
} // namespace XPath
} // namespace Arabica
#endif