SWIG std::string& passing

Leonard J. Reder lreder at worldnet.att.net
Sun May 29 02:02:37 EDT 2005


Hello,

I have been trying to get this simple call to work with a SWIG 
interface.  The problem is I do not know how to pass a const char * or a 
std::string & in python to SWIG wrapped code.  I tried several of the 
*.i libraries at http://www.swig.org/Doc1.3/Library.html.  Most notably 
the "std_string.i" And get the following:

 >>> w.SetDestFilename("test.bmp")
Traceback (most recent call last):
   File "<stdin>", line 1, in ?
   File 
"/home/soa/dev/users/reder/Dshell++Pkg-reder01/lib/PYTHON/Dspace/Dnoise_Py.py", 
line 1340, in SetDestFilename
     def SetDestFilename(*args): return 
_Dnoise_Py.WriterBMP_SetDestFilename(*args)
TypeError: argument number 2: a 'std::string *' is expected, 
'str(test.bmp)' is received

The C++ method is:

void WriterBMP::SetDestFilename (const std::string& filename)

This should be easy to pass the filename to?  Do you have an example? 
What do I add to the *.i file?

Thanks for any and all replies,

Len

-- 
===================================
Leonard J. Reder
Home office email : reder at ieee.org
Lab email         : reder at jpl.nasa.gov
Lab web page      : http://reder.jpl.nasa.gov
===================================


-- 
===================================
Leonard J. Reder
Home office email : reder at ieee.org
Lab email         : reder at jpl.nasa.gov
Lab web page      : http://reder.jpl.nasa.gov
===================================



More information about the Python-list mailing list