diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2009-09-06 12:52:53 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2009-09-06 12:52:53 +0200 |
commit | cb9ea47e7825b5073d4d645afb94f6326cb7cf4d (patch) | |
tree | 201c215b08df918924153a60520046c294438a6b /cutl/compiler/context.hxx |
Start the libcutl repository
Diffstat (limited to 'cutl/compiler/context.hxx')
-rw-r--r-- | cutl/compiler/context.hxx | 70 |
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 |