5 #ifndef __pinocchio_python_utils_pickle_map_hpp__ 6 #define __pinocchio_python_utils_pickle_map_hpp__ 8 #include <boost/python.hpp> 9 #include <boost/python/tuple.hpp> 23 template<
typename MapType>
28 return boost::python::make_tuple();
31 static boost::python::tuple
getstate(boost::python::object op)
33 boost::python::extract<const MapType&> get_map(op);
36 const MapType & map = get_map();
37 boost::python::list list;
38 for(
typename MapType::const_iterator it = map.begin();
42 list.append(boost::python::make_tuple(it->first,it->second));
44 return boost::python::make_tuple(list);
46 return boost::python::make_tuple();
49 static void setstate(bp::object op, bp::tuple tup)
51 typedef typename MapType::key_type
key_type;
52 typedef typename MapType::mapped_type mapped_type;
56 bp::extract<MapType&> get_map(op);
59 MapType & map = get_map();
60 boost::python::list list = bp::extract<boost::python::list>(tup[0])();
61 for(boost::python::ssize_t k = 0; k < boost::python::len(list); ++k)
63 boost::python::tuple entry = bp::extract<boost::python::tuple>(list[k])();
64 key_type key = bp::extract<key_type>(entry[0])();
65 map[key] = bp::extract<mapped_type>(entry[1])();
76 #endif // ifndef __pinocchio_python_utils_pickle_map_hpp__ static boost::python::tuple getstate(boost::python::object op)
static bool getstate_manages_dict()
static boost::python::tuple getinitargs(const MapType &)
Main pinocchio namespace.
static void setstate(bp::object op, bp::tuple tup)
Create a pickle interface for the std::map and aligned map.