Boost logo

Boost :

From: rwgk_at_[hidden]
Date: 2001-08-27 21:06:28


I have added a new example "nested.cpp" to the CVS tree:
http://cvs.sourceforge.net/cgi-
bin/viewcvs.cgi/boost/boost/libs/python/example/
This should answer your question.
Ralf

--- In boost_at_y..., elaine_y_at_y... wrote:
> Hi,
>
> I have the basic functionality of creating an empty vector and being
> able to pass the vectors from c++ to python. Now, I want to be able
> to do it the other way. I'm having trouble fleshing out
>
> matrix_double_wrapper::matrix_double_wrapper(PyObject* self,
> python::tuple tuple)
> : std::vector< std::vector<double> >(tuple.size())
> {
> std::vector< std::vector<double> >::iterator vd = begin();
> for (int i = 0; i < tuple.size(); i++) {
> std::vector<double> vrow;
> // what to do next?
> // tuple[i].get() gives me a reference
> // how can I convert that reference to a tuple?
> // then, I could parse that tuple to create a
> // vector I could add to my row vector.
> // python::tuple row = tuple[i].get() converted to
tuple
>
> for (int j=0; j<row.size(); j++){
> vrow.push_back(BOOST_PYTHON_CONVERSION::from_python(row[i].get
(),
> python::type<double>()));
> }
> vd[i] = vrow;
> }
> }
>
> The other alternative I see is to do something like
> vd[i] = BOOST_PYTHON_CONVERSION::from_python(tuple[i].get(),
> python::type< vector<double> >());
> I did create a wrapper for vector<double> which works. However,
> the above didn't work though it compiled. Not sure why.
>
> Thanks,
> Elaine


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk