5 #ifndef __pinocchio_python_utils_map_hpp__ 6 #define __pinocchio_python_utils_map_hpp__ 8 #include <boost/python/suite/indexing/map_indexing_suite.hpp> 16 template<
typename Container>
18 :
public boost::python::def_visitor< overload_base_get_item_for_std_map<Container> >
21 typedef typename Container::value_type::second_type
data_type;
25 template <
class Class>
34 static boost::python::object
35 base_get_item(boost::python::back_reference<Container&> container, PyObject* i_)
37 namespace bp = ::boost::python;
40 typename Container::iterator
i = container.get().find(idx);
41 if (i == container.get().end())
43 PyErr_SetString(PyExc_KeyError,
"Invalid key");
44 bp::throw_error_already_set();
47 typename bp::to_python_indirect<data_type&,bp::detail::make_reference_holder> convert;
48 return bp::object(bp::handle<>(convert(i->second)));
54 namespace bp = ::boost::python;
55 bp::extract<key_type const&>
i(i_);
62 bp::extract<key_type>
i(i_);
67 PyErr_SetString(PyExc_TypeError,
"Invalid index type");
68 bp::throw_error_already_set();
77 #endif // ifndef __pinocchio_python_utils_map_hpp__
static index_type convert_index(Container &, PyObject *i_)
Container::value_type::second_type data_type
static boost::python::object base_get_item(boost::python::back_reference< Container &> container, PyObject *i_)
Container::key_type index_type
Container::value_type value_type
void visit(Class &cl) const
Container::key_type key_type
Main pinocchio namespace.