aboutsummaryrefslogtreecommitdiff
path: root/cutl/compiler/context.hxx
diff options
context:
space:
mode:
Diffstat (limited to 'cutl/compiler/context.hxx')
-rw-r--r--cutl/compiler/context.hxx70
1 files changed, 70 insertions, 0 deletions
diff --git a/cutl/compiler/context.hxx b/cutl/compiler/context.hxx
new file mode 100644
index 0000000..4bae010
--- /dev/null
+++ b/cutl/compiler/context.hxx
@@ -0,0 +1,70 @@
+// file : cutl/compiler/context.hxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2009 Code Synthesis Tools CC
+// license : MIT; see accompanying LICENSE file
+
+#ifndef CUTL_COMPILER_CONTEXT_HXX
+#define CUTL_COMPILER_CONTEXT_HXX
+
+#include <map>
+#include <string>
+#include <cstddef> // std::size_t
+
+#include <cutl/container/any.hxx>
+
+namespace cutl
+{
+ namespace compiler
+ {
+ class context
+ {
+ public:
+ struct no_entry {};
+ struct typing {};
+
+ public:
+ context () {}
+
+ private:
+ context (context const&);
+
+ context&
+ operator= (context const&);
+
+ public:
+ std::size_t
+ count (char const* key) const
+ {
+ return map_.count (key);
+ }
+
+ template <typename X>
+ X&
+ get (char const* key);
+
+ template <typename X>
+ X const&
+ get (char const* key) const;
+
+ template <typename X>
+ X const&
+ get (char const* key, X const& default_value) const;
+
+ template <typename X>
+ void
+ set (char const* key, X const& value);
+
+ void
+ remove (char const* key);
+
+ private:
+ typedef std::map<std::string, container::any> map;
+
+ map map_;
+ };
+ }
+}
+
+#include <cutl/compiler/context.txx>
+
+#endif // CUTL_COMPILER_CONTEXT_HXX