From: David P. <dpi...@me...> - 2007-10-30 21:48:56
|
Whoops, my last message included unnecessary char* typemaps. Here's the string stuff alone. Again, it's not tested yet and it can only do what you want for returning strings from C++ to C#. %include std_string.i %insert(runtime) %{ #include <ole2.h> %} namespace std { // string %typemap(ctype, out=3D"/*ANSI*/BSTR") string, const string & "char *" %typemap(imtype, outattributes=3D"[return:MarshalAs(UnmanagedType.AnsiBStr)]", inattributes=3D"[MarshalAs(UnmanagedType.LPStr)]") string, const string = & "string" %typemap(out) string, const string& %{ $result =3D SysAllocStringByteLen($1.c_str(), $1.size()); %} %typemap(out) const string& %{ $result =3D SysAllocStringByteLen($1->c_str(), $1->size()); %} } |