I have a C++ library I would like to make available to Python. I've got the
basics working and I can call into the library, but one of the functions takes
a Boost shared pointer to a C++ iostream - the actual type is:
typedef boost::shared_ptr<std::iostream> iostream_sptr;
When I call this function I get the error:
TypeError: in method 'MapType_isInstance', argument 2 of type 'iostream_sptr'
Obviously the problem is that I am passing in a Python file object (as
returned by the open() function) instead of the correct type. The problem is,
I am not sure how to create the correct type!
I am using the directive "%shared_ptr(std::iostream)" although I'm not sure
whether it's working or not. I am using this for my other classes and it
seems to work correctly with them.
I get an error trying to create a modulename.iostream_sptr object, and I don't
know if that would even work anyway, as I'm not sure whether Python's I/O
system can be translated into C++ iostreams.
Is what I am trying to do possible with SWIG? The library relies quite
heavily on iostreams, a large part of the functionality involves passing it an
iostream, having it apply filters (using the Boost iostreams library) and
returning another iostream. Reading from this second iostream returns data
pulled from the original iostream after processing (e.g. decompression.) I'm
hoping SWIG is able to not only supply a C++ iostream from a file opened in
Python, but also to read/write from streams returned by the library too.