summaryrefslogtreecommitdiff
path: root/impl/Variable.h
diff options
context:
space:
mode:
authorCarlo Zancanaro <carlo@carlo-laptop>2012-04-06 14:02:26 +1000
committerCarlo Zancanaro <carlo@carlo-laptop>2012-04-06 14:02:26 +1000
commit5d7252681da3b26845fc4e5dcf0b0e94ed9fabb1 (patch)
tree20bc0a6b62390aabda0b8c446d3a2177990863f6 /impl/Variable.h
parent83e2c574bdefe2d040cdfbe20a73380a0f0123dd (diff)
Move everything into impl/ and add a Makefile.
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