Boost logo

Boost :

From: Preston A. Elder (prez_at_[hidden])
Date: 2005-01-22 19:42:50


I have some functions in C++ that take a void *, for example hexdump().
The main use of this, obviously, is to pass a buffer and get the hex dump
as a return value - without having to worry about the type passed, eg:

std::string str("This is a test");
hexdump(str.data(), str.length());

std::wstring wstr(L"This is a test")
hexdump(str.data(), str.length() * sizeof(wchar_t));

I want to know the best way of exposing such a function to python without
being too 'string specific' (theres no reason I couldn't do
hexdump(&some_int, sizeof(int)) in C++, so I want something similar in
python, if I can get it).

Now hexdump is only an example, I have a few other functions that do the
same (for example, recv() and send() in a socket class).

Any ideas would be appreciated. Right now, the best thing I can think of
is to create a wrapper function (for use in the python interface only)
that accepts a std::string/std::wstring and calls hexdump, however this
hamstrings me when I want to do things like integers, or complex
structures.

Also, on another note, is there somewhere that has all of boost already
pythonized? I manually converted boost::date_time (at least all the
gregorian and posix_time stuff) myself, however I would have expected most
of boost to have been converted to python already ;)

-- 
PreZ :)
Founder. The Neuromancy Society (http://www.neuromancy.net)

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