Boost logo

Boost :

From: David Abrahams (david.abrahams_at_[hidden])
Date: 2001-09-30 22:28:41


First of all, you'll need to pick a different interface for "function" (or
wrap a different function and have it call your function), because
Boost.Python can only convert a single Python object into a single function

Probably the easiest thing you can do is to write a function taking a
boost::python::ref (which is kind of a smart pointer to a PyObject), and
just use the regular Python 'C' API to extract the buffer data.

If you want to get fancier, you could create a type which corresponds to a
Python buffer (perhaps struct my_buffer { void* data; int size; };) and
write a family of from_python(PyObject*, type<buffer>) functions which check
the argument type and convert Python buffers into your buffer type. You can
look at boost/python/conversions.hpp for some examples. That would allow you
to automatically wrap functions which accept my_buffer arguments.


  David Abrahams, C++ library designer for hire

        C++ Booster (
          email: david.abrahams_at_[hidden]

----- Original Message -----
From: "Mike Ensor" <MikeEnsor_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Saturday, September 29, 2001 7:47 PM
Subject: [boost] Boost::Python

> I am using Boost.Python to build c++ to python wrappers. I am
> trying to make binary data available to python and visa versa. I have
> many different approaches. The functions in C++ look similar to this:
> void function(const void* buffer, int size);
> and in python I can create a "buffer" of information. When I check
> the type of the "buffer" it is a "buffer".
> When I compile the c++ it won't let me because "none of the 425
> overloads can convert prameter 2 from type 'struct
> const*>'"
> How do I make the const void * be seen in Python and how do I send
> in binary data into this function from python?
> Thank you for your help,
> Mike Ensor
> mikeensor_at_[hidden]
> Info: Unsubscribe:
> Your use of Yahoo! Groups is subject to

Boost list run by bdawes at, gregod at, cpdaniel at, john at