mirror of
https://github.com/jezhiggins/arabica
synced 2025-01-06 05:24:35 +01:00
44 lines
1.1 KiB
C++
44 lines
1.1 KiB
C++
#ifndef ARABICA_XPATH_VARIABLE_RESOLVER_HPP
|
|
#define ARABICA_XPATH_VARIABLE_RESOLVER_HPP
|
|
|
|
#include <stdexcept>
|
|
#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
|
|
|
|
class VariableResolver
|
|
{
|
|
public:
|
|
virtual ~VariableResolver() { }
|
|
|
|
virtual XPathValuePtr resolveVariable(const std::string& name) const = 0;
|
|
}; // class VariableResolver
|
|
|
|
class VariableResolverPtr : public boost::shared_ptr<VariableResolver>
|
|
{
|
|
public:
|
|
explicit VariableResolverPtr(VariableResolver* vr) : boost::shared_ptr<VariableResolver>(vr) { }
|
|
}; // class VariableResolverPtr
|
|
|
|
class NullVariableResolver : public VariableResolver
|
|
{
|
|
public:
|
|
virtual XPathValuePtr resolveVariable(const std::string& name) const
|
|
{
|
|
throw UnboundVariableException(name);
|
|
} // resolveVariable
|
|
}; // NullVariableResolver
|
|
|
|
} // namespace XPath
|
|
} // namespace Arabica
|
|
|
|
#endif
|