From 99b84c0fab90b776e66c9c7f27bce70aaa0800da Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Sat, 6 Jun 2009 16:35:26 +0000 Subject: [PATCH] Attempt to add a set_object method for scoping rules --- boxedcpp/boxedcpp.hpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/boxedcpp/boxedcpp.hpp b/boxedcpp/boxedcpp.hpp index bcf7066..589b20e 100644 --- a/boxedcpp/boxedcpp.hpp +++ b/boxedcpp/boxedcpp.hpp @@ -41,6 +41,17 @@ class BoxedCPP_System m_functions.insert(std::make_pair(name, boost::shared_ptr(new Proxy_Function_Impl(func)))); } + + template + void set_object(const std::string &name, const Class &obj) + { + try { + get_object(name) = Boxed_Value(obj); + } catch (const std::range_error &) { + add_object(name, obj); + } + } + template void add_object(const std::string &name, const Class &obj) {