[C++-sig] byte containers

David Abrahams dave at boost-consulting.com
Thu Oct 3 23:39:07 CEST 2002

From: "Leonardo Rochael Almeida" <leo at hiper.com.br>

> I'm officially working with the TerraLib mantainers
> (http://www.terralib.org/) to make Python bindings for it (Dave, you can
> count this one as another boost.python project :-).
> Part of the functionality of that library concerns map tiling: large
> geo-referenced images are sliced and the tiles are stored in a Database.
> Later on, you can ask the library to return the map of an area and it
> will reassemble the image and return it. What is the best way to pass a
> lump of bytes (with nulls in it) back and forth? Something that I could
> get as a Python String would be nice, but std::string doesn't seem null
> friendly... Ultimately I'll probably be feeding this lump of bytes to
> PIL (Python Imaging Library) to make some final tweaks to the image
> before publishing it on the Web (it's actually a Zope project).
> Any tips?

How about just using boost::python::str, i.e. a Python string object?
You can always extract<char*>(...) from it. If you think that's too
semantically loose on the Python side, you could wrap a C++ class which
contains a str.

           David Abrahams * Boost Consulting
dave at boost-consulting.com * http://www.boost-consulting.com

More information about the Cplusplus-sig mailing list