diff options
Diffstat (limited to 'Variable.h')
-rw-r--r-- | Variable.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/Variable.h b/Variable.h new file mode 100644 index 0000000..7433426 --- /dev/null +++ b/Variable.h @@ -0,0 +1,24 @@ +#ifndef VARIABLE_H +#define VARIABLE_H + +#include <string> +#include "Expression.h" + +template<class T> +struct Variable : public Expression<T> { + Variable(const std::string& name) + : _name(name) { } + + std::string name() const { + return this->_name; + } + + T eval(const std::map<std::string, T>& values) const { + return values.find(_name)->second; + } + + private: + const std::string _name; +}; + +#endif |