Is there a way to use std::[io]fstream
\'s in python via swig?
I have a c-class with functions like:
void readFrom(std::istream& istr
I don't know swig but assuming you need to create a copyable object, you might get away using a function like
std::shared_ptr make_ostream(std::string const& filename) {
return std::make_shared(filename);
}
... and then use a forwarding function to call the function you actually want to call:
void writeTo(std::shared_ptr stream) {
if (stream) {
writeTo(*stream);
}
}
(if overloading the names causes issues, you could call the forwarding function differently, of course).