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
Working .i file based on Dietmar's suggestion to use shared pointers:
%module ptrtest
%include "boost_shared_ptr.i"
%include "std_string.i"
%shared_ptr( std::ostream )
%{
#include
#include
#include
typedef boost::shared_ptr< std::ostream > ostream_ptr;
ostream_ptr mk_out(const std::string& fname ){
return ostream_ptr( new std::ofstream( fname.c_str() ) );
}
void writeTo(std::ostream& ostr){
ostr<<"OK"< ostream_ptr;
ostream_ptr mk_out(const std::string& fname );
void writeTo(std::ostream& ostr);
// Usage:
//>>>ostr=mk_out('/path/to/file.txt')
//>>>writeTo(ostr) # no need to cast/call-function!