#ifndef ARABICA_XPATH_FUNCTION_RESOLVER_HPP #define ARABICA_XPATH_FUNCTION_RESOLVER_HPP namespace Arabica { namespace XPath { template class XPathFunction; template class XPathExpression; class UndefinedFunctionException : public std::runtime_error { public: UndefinedFunctionException(const std::string& thing) : std::runtime_error("The function '" + thing + "' is undefined.") { } }; // class UndefinedFunctionException template > class FunctionResolver { public: virtual ~FunctionResolver() { } virtual XPathFunction* resolveFunction(const string_type& namespace_uri, const string_type& name, const std::vector >& argExprs) const = 0; }; // class FunctionResolver template class FunctionResolverPtr : public boost::shared_ptr > { public: explicit FunctionResolverPtr(FunctionResolver* fr) : boost::shared_ptr >(fr) { } // FunctionResolverPtr }; // class FunctionResolverPtr template class NullFunctionResolver : public FunctionResolver { public: virtual XPathFunction* resolveFunction(const string_type& namespace_uri, const string_type& name, const std::vector >& argExprs) const { string_type error; if(!string_adaptor::empty(namespace_uri)) { string_adaptor::append(error, string_adaptor::construct_from_utf8("{")); string_adaptor::append(error, namespace_uri); string_adaptor::append(error, string_adaptor::construct_from_utf8("}")); } // if ... string_adaptor::append(error, name); throw UndefinedFunctionException(string_adaptor().asStdString(error)); } // resolveVariable }; // NullFunctionResolver } // namespace XPath } // namespace Arabica #endif