From cb9ea47e7825b5073d4d645afb94f6326cb7cf4d Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sun, 6 Sep 2009 12:52:53 +0200 Subject: Start the libcutl repository --- cutl/compiler/context.hxx | 70 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 cutl/compiler/context.hxx (limited to 'cutl/compiler/context.hxx') 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 +// 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 +#include +#include // std::size_t + +#include + +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 + X& + get (char const* key); + + template + X const& + get (char const* key) const; + + template + X const& + get (char const* key, X const& default_value) const; + + template + void + set (char const* key, X const& value); + + void + remove (char const* key); + + private: + typedef std::map map; + + map map_; + }; + } +} + +#include + +#endif // CUTL_COMPILER_CONTEXT_HXX -- cgit v1.1