summaryrefslogtreecommitdiff
path: root/impl/Variable.h
diff options
context:
space:
mode:
Diffstat (limited to 'impl/Variable.h')
-rw-r--r--impl/Variable.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/impl/Variable.h b/impl/Variable.h
new file mode 100644
index 0000000..7433426
--- /dev/null
+++ b/impl/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