aboutsummaryrefslogtreecommitdiff
path: root/cutl
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2011-03-10 09:19:33 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2011-03-10 09:19:33 +0200
commitab5a37ec04dbf27899f6303fa22a5c145442fb92 (patch)
treea1bca6c8184e6b47abdf13ce5044990d7f11cc3d /cutl
parent6a0e066b275e0823c5ad745965d182f022512793 (diff)
Add support for querying type_info of context entries
Diffstat (limited to 'cutl')
-rw-r--r--cutl/compiler/context.cxx11
-rw-r--r--cutl/compiler/context.hxx12
2 files changed, 22 insertions, 1 deletions
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 <map>
#include <string>
#include <cstddef> // std::size_t
+#include <typeinfo>
#include <cutl/exception.hxx>
#include <cutl/container/any.hxx>
@@ -79,7 +80,7 @@ namespace cutl
X const&
get (char const* key, X const& default_value) const
{
- return get<X> (std::string (key) ,default_value);
+ return get<X> (std::string (key), default_value);
}
template <typename X>
@@ -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<std::string, container::any> map;