#ifndef ARABICA_XPATH_VARIABLE_RESOLVER_HPP #define ARABICA_XPATH_VARIABLE_RESOLVER_HPP #include #include "xpath_object.hpp" namespace Arabica { namespace XPath { class UnboundVariableException : public std::runtime_error { public: UnboundVariableException(const std::string& thing) : std::runtime_error("The variable '" + thing + "' is undefined.") { } }; // class UnboundVariableException template > class VariableResolver { public: virtual ~VariableResolver() { } virtual XPathValue resolveVariable(const string_type& namespace_uri_, const string_type& name) const = 0; }; // class VariableResolver template class VariableResolverPtr : public boost::shared_ptr > { public: explicit VariableResolverPtr(VariableResolver* vr) : boost::shared_ptr >(vr) { } // VariableResolverPtr }; // class VariableResolverPtr template class NullVariableResolver : public VariableResolver { public: virtual XPathValue resolveVariable(const string_type& namespace_uri, const string_type& name) 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 UnboundVariableException(string_adaptor().asStdString(error)); } // resolveVariable }; // NullVariableResolver } // namespace XPath } // namespace Arabica #endif