From 8e761289a2446367267c6c0d9a26e734f0f78306 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Wed, 16 Dec 2020 20:29:05 +0300 Subject: Get rid of legacy build systems and rename cutl/ to libcutl/ --- libcutl/compiler/context.hxx | 136 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 136 insertions(+) create mode 100644 libcutl/compiler/context.hxx (limited to 'libcutl/compiler/context.hxx') diff --git a/libcutl/compiler/context.hxx b/libcutl/compiler/context.hxx new file mode 100644 index 0000000..fc120cc --- /dev/null +++ b/libcutl/compiler/context.hxx @@ -0,0 +1,136 @@ +// file : libcutl/compiler/context.hxx +// license : MIT; see accompanying LICENSE file + +#ifndef LIBCUTL_COMPILER_CONTEXT_HXX +#define LIBCUTL_COMPILER_CONTEXT_HXX + +#include +#include +#include // std::size_t +#include + +#include +#include + +#include + +namespace cutl +{ + namespace compiler + { + class LIBCUTL_EXPORT context + { + public: + struct no_entry: exception {}; + struct typing: exception {}; + + public: + context () {} + + void + swap (context& c) + { + map_.swap (c.map_); + } + + private: + context (context const&); + + context& + operator= (context const&); + + public: + std::size_t + count (char const* key) const + { + return count (std::string (key)); + } + + std::size_t + count (std::string const& key) const + { + return map_.count (key); + } + + template + X& + get (char const* key) + { + return get (std::string (key)); + } + + template + X& + get (std::string const& key); + + template + X const& + get (char const* key) const + { + return get (std::string (key)); + } + + template + X const& + get (std::string const& key) const; + + template + X const& + get (char const* key, X const& default_value) const + { + return get (std::string (key), default_value); + } + + template + X const& + get (std::string const& key, X const& default_value) const; + + template + X& + set (char const* key, X const& value) + { + return set (std::string (key), value); + } + + template + X& + set (std::string const& key, X const& value); + + void + set (char const* key, container::any const& value) + { + return set (std::string (key), value); + } + + void + set (std::string const& key, container::any const& value); + + void + remove (char const* key) + { + remove (std::string (key)); + } + + void + remove (std::string const& key); + + std::type_info const& + type_info (char const* key) const + { + return type_info (std::string (key)); + } + + std::type_info const& + type_info (std::string const& key) const; + + private: + typedef std::map map; + + map map_; + }; + } +} + +#include + +#endif // LIBCUTL_COMPILER_CONTEXT_HXX -- cgit v1.1