Skip to content
Snippets Groups Projects
Verified Commit 3c3b249e authored by Justin Carpentier's avatar Justin Carpentier
Browse files

python/vector: add conversion tolist for std::vector

parent aecdaeef
Branches
Tags
No related merge requests found
......@@ -38,9 +38,12 @@ namespace pinocchio
static void expose(const std::string & class_name,
const std::string & doc_string = "")
{
::boost::python::class_<vector_type>(class_name.c_str(),
doc_string.c_str())
namespace bp = boost::python;
bp::class_<vector_type>(class_name.c_str(),doc_string.c_str())
.def(StdAlignedVectorPythonVisitor())
.def("tolist",&FromPythonListConverter::tolist,bp::arg("self"),
"Returns the aligned_vector as a Python list.")
.def_pickle(PickleVector<vector_type>());
// Register conversion
......
......@@ -80,6 +80,16 @@ namespace pinocchio
&construct,
::boost::python::type_id<vector_type>());
}
static ::boost::python::list tolist(vector_type & self)
{
namespace bp = boost::python;
typedef bp::iterator<vector_type> iterator;
bp::list python_list(iterator()(self));
return python_list;
}
};
///
......@@ -103,8 +113,12 @@ namespace pinocchio
static void expose(const std::string & class_name,
const std::string & doc_string = "")
{
::boost::python::class_<vector_type>(class_name.c_str(),doc_string.c_str())
namespace bp = boost::python;
bp::class_<vector_type>(class_name.c_str(),doc_string.c_str())
.def(StdVectorPythonVisitor())
.def("tolist",&FromPythonListConverter::tolist,bp::arg("self"),
"Returns the std::vector as a Python list.")
.def_pickle(PickleVector<vector_type>());
// Register conversion
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment