From d745a537bfc82982d79a0c3d6dddc32a0aaa646e Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Fri, 10 Jun 2005 11:55:59 +0000 Subject: [PATCH] Fix conversion of Python objects to strings [SVN r29515] --- src/python/basic_graph.cpp | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/src/python/basic_graph.cpp b/src/python/basic_graph.cpp index c5f819b1..bb4fbe8f 100644 --- a/src/python/basic_graph.cpp +++ b/src/python/basic_graph.cpp @@ -50,7 +50,8 @@ class copying_dynamic_property_map virtual void copy_value(const any& to, const any& from) = 0; }; -template +template::value_type> class copying_dynamic_adaptor : public boost::detail::dynamic_property_map_adaptor, public copying_dynamic_property_map @@ -70,6 +71,35 @@ public: } }; +template +class copying_dynamic_adaptor + : public boost::detail::dynamic_property_map_adaptor, + public copying_dynamic_property_map +{ + typedef boost::detail::dynamic_property_map_adaptor inherited; + +public: + typedef typename property_traits::key_type key_type; + + explicit copying_dynamic_adaptor(const PropertyMap& property_map) + : inherited(property_map) { } + + virtual void copy_value(const any& to, const any& from) + { + boost::put(this->base(), any_cast(to), + boost::get(this->base(), any_cast(from))); + } + + virtual std::string get_string(const any& key) + { + using boost::python::extract; + using boost::python::str; + return std::string( + extract(str(boost::get(this->base(), + any_cast(key))))); + } +}; + template struct build_string_property_maps {