From ab5a37ec04dbf27899f6303fa22a5c145442fb92 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 10 Mar 2011 09:19:33 +0200 Subject: Add support for querying type_info of context entries --- cutl/compiler/context.cxx | 11 +++++++++++ cutl/compiler/context.hxx | 12 +++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/cutl/compiler/context.cxx b/cutl/compiler/context.cxx index 7961388..9623588 100644 --- a/cutl/compiler/context.cxx +++ b/cutl/compiler/context.cxx @@ -19,5 +19,16 @@ namespace cutl map_.erase (i); } + + std::type_info const& context:: + type_info (std::string const& key) const + { + map::const_iterator i (map_.find (key)); + + if (i == map_.end ()) + throw no_entry (); + + return i->second.type_info (); + } } } diff --git a/cutl/compiler/context.hxx b/cutl/compiler/context.hxx index 9cfd4be..c8e35e6 100644 --- a/cutl/compiler/context.hxx +++ b/cutl/compiler/context.hxx @@ -9,6 +9,7 @@ #include #include #include // std::size_t +#include #include #include @@ -79,7 +80,7 @@ namespace cutl X const& get (char const* key, X const& default_value) const { - return get (std::string (key) ,default_value); + return get (std::string (key), default_value); } template @@ -106,6 +107,15 @@ namespace cutl 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; -- cgit v1.1