From 7385921ace0e0b130de43709cd09bb973915657f Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 2 Apr 2010 14:28:37 +0200 Subject: Add std::string overload for context functions --- cutl/compiler/context.cxx | 2 +- cutl/compiler/context.hxx | 50 ++++++++++++++++++++++++++++++++++++++++++----- cutl/compiler/context.txx | 8 ++++---- 3 files changed, 50 insertions(+), 10 deletions(-) diff --git a/cutl/compiler/context.cxx b/cutl/compiler/context.cxx index 7238b33..0488e1f 100644 --- a/cutl/compiler/context.cxx +++ b/cutl/compiler/context.cxx @@ -10,7 +10,7 @@ namespace cutl namespace compiler { void context:: - remove (char const* key) + remove (std::string const& key) { map::iterator i (map_.find (key)); diff --git a/cutl/compiler/context.hxx b/cutl/compiler/context.hxx index 120986c..e603f97 100644 --- a/cutl/compiler/context.hxx +++ b/cutl/compiler/context.hxx @@ -36,27 +36,67 @@ namespace cutl 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); + 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 (char const* key) const; + get (std::string const& key) const; template X const& - get (char const* key, X const& default_value) 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 + void + set (char const* key, X const& value) + { + set (std::string (key), value); + } template void - set (char const* key, X const& value); + set (std::string const& key, X const& value); + + void + remove (char const* key) + { + remove (std::string (key)); + } void - remove (char const* key); + remove (std::string const& key); private: typedef std::map map; diff --git a/cutl/compiler/context.txx b/cutl/compiler/context.txx index ba73b6d..7f47cd9 100644 --- a/cutl/compiler/context.txx +++ b/cutl/compiler/context.txx @@ -9,7 +9,7 @@ namespace cutl { template X& context:: - get (char const* key) + get (std::string const& key) { map::iterator i (map_.find (key)); @@ -28,7 +28,7 @@ namespace cutl template X const& context:: - get (char const* key) const + get (std::string const& key) const { map::const_iterator i (map_.find (key)); @@ -47,7 +47,7 @@ namespace cutl template X const& context:: - get (char const* key, X const& default_value) const + get (std::string const& key, X const& default_value) const { map::const_iterator i (map_.find (key)); @@ -66,7 +66,7 @@ namespace cutl template void context:: - set (char const* key, X const& value) + set (std::string const& key, X const& value) { try { -- cgit v1.1